Skip to content
Permalink
Browse files

Fix zfs_znode_sa_init() panic by updating ZFS_OBJ_MUTEX()

The time at which a zp's z_zfsvfs is assigned was changed in
upstream here:

illumos/illumos-gate@b5fca8f

Although we had already merged in most of that change, we had
neglected to update the definition of ZFS_OBJ_MUTEX() to the new
two-argument version. Yet, when actually invoking the macro, we
were supplying two arguments.

In an attempt to reconcile the discrepancy, the panic was
introduced by

8881f60

which erroneously reverted the new code where the two-argument
version was used, rather than updating ZFS_OBJ_MUTEX() to the new
two-argument version.

This results in panic because ZFS_OBJ_MUTEX() happens to be used
before zp->z_zfsvfs has been assigned, while the one-argument
version of ZFS_OBJ_MUTEX() expects to be able to retrieve the
zfsvfs from the zp.
  • Loading branch information...
ilovezfs committed Jul 24, 2014
1 parent 10bade5 commit b223a573025bb5ef84e6e08b74c9f24b61eacc0b
Showing with 4 additions and 5 deletions.
  1. +2 −3 include/sys/zfs_znode.h
  2. +2 −2 module/zfs/zfs_znode.c
@@ -310,9 +310,8 @@ typedef struct znode {
* Macros for dealing with dmu_buf_hold
*/
#define ZFS_OBJ_HASH(obj_num) ((obj_num) & (ZFS_OBJ_MTX_SZ - 1))

#define ZFS_OBJ_MUTEX(zp) \
(&zp->z_zfsvfs->z_hold_mtx[ZFS_OBJ_HASH(zp->z_id)])
#define ZFS_OBJ_MUTEX(zfsvfs, obj_num) \
(&(zfsvfs)->z_hold_mtx[ZFS_OBJ_HASH(obj_num)])
#define ZFS_OBJ_HOLD_ENTER(zfsvfs, obj_num) \
mutex_enter(&zfsvfs->z_hold_mtx[ZFS_OBJ_HASH(obj_num)])
#define ZFS_OBJ_HELD(zfsvfs, obj_num) \
@@ -624,7 +624,7 @@ zfs_znode_sa_init(zfsvfs_t *zfsvfs, znode_t *zp,
sa_handle_t *sa_hdl)
{
ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs) || (zfsvfs == zp->z_zfsvfs));
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zp)));
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zfsvfs, zp->z_id)));

mutex_enter(&zp->z_lock);

@@ -655,7 +655,7 @@ zfs_znode_sa_init(zfsvfs_t *zfsvfs, znode_t *zp,
void
zfs_znode_dmu_fini(znode_t *zp)
{
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zp)) ||
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zp->z_zfsvfs, zp->z_id)) ||
zp->z_unlinked ||
RW_WRITE_HELD(&zp->z_zfsvfs->z_teardown_inactive_lock));

0 comments on commit b223a57

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.