summaryrefslogtreecommitdiffstats
path: root/sys/cddl
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2016-05-16 15:13:16 +0000
committeravg <avg@FreeBSD.org>2016-05-16 15:13:16 +0000
commitfd1f834a75d4b8bf74209551230c614be7c9f20b (patch)
tree55d2bbb8dda8df112a15ddc8b3f0d8ede18915c7 /sys/cddl
parenta87f62a9c244af7f3c169764d58edd5ca8e51d64 (diff)
downloadFreeBSD-src-fd1f834a75d4b8bf74209551230c614be7c9f20b.zip
FreeBSD-src-fd1f834a75d4b8bf74209551230c614be7c9f20b.tar.gz
gfs_lookup_dot() does not have to acquire any locks
In fact, that was dangerous. For example, zfsctl_snapshot_reclaim() calls gfs_dir_lookup() on ".." path and that ends up calling gfs_lookup_dot() which violated locking order by acquiring the parent's directory vnode lock after the child's vnode lock. Also, the previous behavior was inconsistent as gfs_dir_lookup() returned a locked vnode for . and .. lookups, but not for any other. Now gfs_lookup_dot() just references a resulting vnode and the locking is done in its consumers, where necessary. Note that we do not enable shared locking support for any gfs / zfsctl vnodes. This commit partially reverts r273641. MFC after: 5 weeks
Diffstat (limited to 'sys/cddl')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c16
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c11
2 files changed, 13 insertions, 14 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
index c5c5c00..27d259d 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
@@ -442,19 +442,9 @@ gfs_lookup_dot(vnode_t **vpp, vnode_t *dvp, vnode_t *pvp, const char *nm)
*vpp = dvp;
return (0);
} else if (strcmp(nm, "..") == 0) {
- if (pvp == NULL) {
- ASSERT(dvp->v_flag & VROOT);
- VN_HOLD(dvp);
- *vpp = dvp;
- ASSERT_VOP_ELOCKED(dvp, "gfs_lookup_dot: non-locked dvp");
- } else {
- ltype = VOP_ISLOCKED(dvp);
- VOP_UNLOCK(dvp, 0);
- VN_HOLD(pvp);
- *vpp = pvp;
- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
- vn_lock(dvp, ltype | LK_RETRY);
- }
+ ASSERT(pvp != NULL);
+ VN_HOLD(pvp);
+ *vpp = pvp;
return (0);
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
index 6404b77..ec4518d 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
@@ -987,6 +987,11 @@ zfsctl_snapdir_lookup(ap)
ZFS_ENTER(zfsvfs);
if (gfs_lookup_dot(vpp, dvp, zfsvfs->z_ctldir, nm) == 0) {
+ if (nm[0] == '.' && nm[1] == '.' && nm[2] =='\0') {
+ VOP_UNLOCK(dvp, 0);
+ VERIFY0(vn_lock(*vpp, LK_EXCLUSIVE));
+ VERIFY0(vn_lock(dvp, LK_EXCLUSIVE));
+ }
ZFS_EXIT(zfsvfs);
return (0);
}
@@ -1151,6 +1156,11 @@ zfsctl_shares_lookup(ap)
strlcpy(nm, cnp->cn_nameptr, cnp->cn_namelen + 1);
if (gfs_lookup_dot(vpp, dvp, zfsvfs->z_ctldir, nm) == 0) {
+ if (nm[0] == '.' && nm[1] == '.' && nm[2] =='\0') {
+ VOP_UNLOCK(dvp, 0);
+ VERIFY0(vn_lock(*vpp, LK_EXCLUSIVE));
+ VERIFY0(vn_lock(dvp, LK_EXCLUSIVE));
+ }
ZFS_EXIT(zfsvfs);
return (0);
}
@@ -1488,7 +1498,6 @@ zfsctl_snapshot_reclaim(ap)
VERIFY(gfs_dir_lookup(vp, "..", &dvp, cr, 0, NULL, NULL) == 0);
sdp = dvp->v_data;
- VOP_UNLOCK(dvp, 0);
/* this may already have been unmounted */
if (sdp == NULL) {
VN_RELE(dvp);
OpenPOWER on IntegriCloud