Skip to content

Commit

Permalink
Revert "[FreeBSD] zfs_znode_alloc: lock the vnode earlier"
Browse files Browse the repository at this point in the history
This reverts commit 28bf26a.
  • Loading branch information
ryao committed Jan 21, 2024
1 parent 26654e8 commit 6a0fb48
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions module/os/freebsd/zfs/zfs_znode.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,6 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
zp->z_vnode = vp;
vp->v_data = zp;

/*
* Acquire the vnode lock before any possible interaction with the
* outside world. Specifically, there is an error path that calls
* zfs_vnode_forget() and the vnode should be exclusively locked.
*/
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);

ASSERT(!POINTER_IS_VALID(zp->z_zfsvfs));

zp->z_sa_hdl = NULL;
Expand All @@ -472,6 +465,8 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
atomic_store_ptr(&zp->z_cached_symlink, NULL);
#endif

vp = ZTOV(zp);

zfs_znode_sa_init(zfsvfs, zp, db, obj_type, hdl);

SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MODE(zfsvfs), NULL, &mode, 8);
Expand Down Expand Up @@ -540,6 +535,10 @@ zfs_znode_alloc(zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz,
zp->z_zfsvfs = zfsvfs;
mutex_exit(&zfsvfs->z_znodes_lock);

/*
* Acquire vnode lock before making it available to the world.
*/
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
#if __FreeBSD_version >= 1400077
vn_set_state(vp, VSTATE_CONSTRUCTED);
#endif
Expand Down

0 comments on commit 6a0fb48

Please sign in to comment.