Skip to content
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:


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


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) \
#define ZFS_OBJ_MUTEX(zfsvfs, obj_num) \
#define ZFS_OBJ_HOLD_ENTER(zfsvfs, 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(zfsvfs, zp->z_id)));


@@ -655,7 +655,7 @@ zfs_znode_sa_init(zfsvfs_t *zfsvfs, znode_t *zp,
zfs_znode_dmu_fini(znode_t *zp)
ASSERT(MUTEX_HELD(ZFS_OBJ_MUTEX(zp->z_zfsvfs, zp->z_id)) ||
zp->z_unlinked ||

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.