aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2020-01-22 17:55:56 -0800
committerBrian Behlendorf <[email protected]>2020-01-22 17:55:56 -0800
commit3d91490f7c69986132f374d016de3753ea790567 (patch)
tree0b9a678dd57dd174c2fb45abda5e1fbd3f40aee8 /module/zfs
parente2ef1cbf04c713fcdba33f8183e6a61a18f61119 (diff)
Simplify FreeBSD's locking requirements in zfs_replay.c
Now that the FreeBSD zfs_vnops code avoids asserting that a vnode lock is held when z_replay is true we can limit the FreeBSD specific changes to the couple of changes where it is necessary to drop the vnode locks because a function returns with it held. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #9865
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/zfs_replay.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c
index 6372c004a..cba5e8c9c 100644
--- a/module/zfs/zfs_replay.c
+++ b/module/zfs/zfs_replay.c
@@ -71,6 +71,9 @@ zfs_init_vattr(vattr_t *vap, uint64_t mask, uint64_t mode,
bzero(vap, sizeof (*vap));
vap->va_mask = (uint_t)mask;
vap->va_mode = mode;
+#ifdef __FreeBSD__
+ vap->va_type = IFTOVT(mode);
+#endif
vap->va_uid = (uid_t)(IS_EPHEMERAL(uid)) ? -1 : uid;
vap->va_gid = (gid_t)(IS_EPHEMERAL(gid)) ? -1 : gid;
vap->va_rdev = zfs_cmpldev(rdev);
@@ -419,9 +422,12 @@ zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap)
}
bail:
- if (error == 0 && zp != NULL)
+ if (error == 0 && zp != NULL) {
+#ifdef __FreeBSD__
+ VOP_UNLOCK1(ZTOV(zp));
+#endif
zrele(zp);
-
+ }
zrele(dzp);
if (zfsvfs->z_fuid_replay)
@@ -503,9 +509,6 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap)
lr->lr_uid, lr->lr_gid);
}
-#ifdef __FreeBSD__
- vn_lock(ZTOV(dzp), LK_EXCLUSIVE | LK_RETRY);
-#endif
switch (txtype) {
case TX_CREATE_ATTR:
lrattr = (lr_attr_t *)(caddr_t)(lr + 1);
@@ -556,13 +559,13 @@ zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap)
error = SET_ERROR(ENOTSUP);
}
+out:
+ if (error == 0 && zp != NULL) {
#ifdef __FreeBSD__
- VOP_UNLOCK(ZTOV(dzp), 0);
+ VOP_UNLOCK1(ZTOV(zp));
#endif
-out:
- if (error == 0 && zp != NULL)
zrele(zp);
-
+ }
zrele(dzp);
if (zfsvfs->z_fuid_replay)
@@ -590,9 +593,6 @@ zfs_replay_remove(void *arg1, void *arg2, boolean_t byteswap)
if (lr->lr_common.lrc_txtype & TX_CI)
vflg |= FIGNORECASE;
-#ifdef __FreeBSD__
- vn_lock(ZTOV(dzp), LK_EXCLUSIVE | LK_RETRY);
-#endif
switch ((int)lr->lr_common.lrc_txtype) {
case TX_REMOVE:
error = zfs_remove(dzp, name, kcred, vflg);
@@ -604,9 +604,6 @@ zfs_replay_remove(void *arg1, void *arg2, boolean_t byteswap)
error = SET_ERROR(ENOTSUP);
}
-#ifdef __FreeBSD__
- VOP_UNLOCK(ZTOV(dzp), 0);
-#endif
zrele(dzp);
return (error);
@@ -636,15 +633,7 @@ zfs_replay_link(void *arg1, void *arg2, boolean_t byteswap)
if (lr->lr_common.lrc_txtype & TX_CI)
vflg |= FIGNORECASE;
-#ifdef __FreeBSD__
- vn_lock(ZTOV(dzp), LK_EXCLUSIVE | LK_RETRY);
- vn_lock(ZTOV(zp), LK_EXCLUSIVE | LK_RETRY);
-#endif
error = zfs_link(dzp, zp, name, kcred, vflg);
-#ifdef __FreeBSD__
- VOP_UNLOCK(ZTOV(zp), 0);
- VOP_UNLOCK(ZTOV(dzp), 0);
-#endif
zrele(zp);
zrele(dzp);
@@ -680,7 +669,6 @@ zfs_replay_rename(void *arg1, void *arg2, boolean_t byteswap)
zrele(tdzp);
zrele(sdzp);
-
return (error);
}