Skip to content

Commit

Permalink
Exit the teardown section later in rename on FreeBSD
Browse files Browse the repository at this point in the history
We have to hold the teardown lock while dereferencing zfsvfs->z_os and,
I believe, when committing to the ZIL.

Note that jumping to the "out" label, "error" is always non-zero.

Signed-off-by: Mark Johnston <[email protected]>
  • Loading branch information
markjdb committed Oct 28, 2021
1 parent 6ce3c64 commit 92b0918
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions module/os/freebsd/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3196,7 +3196,7 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
const char *snm = scnp->cn_nameptr;
const char *tnm = tcnp->cn_nameptr;
int error = 0;
bool want_seqc_end __maybe_unused = false;
bool want_seqc_end __maybe_unused = false;

/* Reject renames across filesystems. */
if ((*svpp)->v_mount != tdvp->v_mount ||
Expand Down Expand Up @@ -3431,7 +3431,6 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
dmu_tx_commit(tx);

unlockout: /* all 4 vnodes are locked, ZFS_ENTER called */
ZFS_EXIT(zfsvfs);
if (want_seqc_end) {
vn_seqc_write_end(*svpp);
vn_seqc_write_end(sdvp);
Expand All @@ -3444,10 +3443,12 @@ zfs_rename_(vnode_t *sdvp, vnode_t **svpp, struct componentname *scnp,
VOP_UNLOCK1(*svpp);
VOP_UNLOCK1(sdvp);

out: /* original two vnodes are locked */
MPASS(!want_seqc_end);
if (error == 0 && zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, 0);
ZFS_EXIT(zfsvfs);

out: /* original two vnodes are locked */
MPASS(!want_seqc_end);

if (*tvpp != NULL)
VOP_UNLOCK1(*tvpp);
Expand Down

0 comments on commit 92b0918

Please sign in to comment.