svn commit: r323480 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Andriy Gapon
avg at FreeBSD.org
Tue Sep 12 06:04:02 UTC 2017
Author: avg
Date: Tue Sep 12 06:04:01 2017
New Revision: 323480
URL: https://svnweb.freebsd.org/changeset/base/323480
Log:
zfs_get_vfs: reference a requested filesystem instead of vfs_busy-ing it
The only consumer of zfs_get_vfs, zfs_unmount_snap, does not need
the filesystem to be busy, it just need a reference that it can pass
to dounmount.
Also, previously the code was racy as it unbusied the filesystem
before taking a reference on it.
Now the code should be simpler and safer.
MFC after: 2 weeks
Sponsored by: Panzura
Modified:
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Sep 12 06:02:21 2017 (r323479)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Sep 12 06:04:01 2017 (r323480)
@@ -3049,13 +3049,11 @@ zfs_get_vfs(const char *resource)
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH(vfsp, &mountlist, mnt_list) {
if (strcmp(refstr_value(vfsp->vfs_resource), resource) == 0) {
- if (vfs_busy(vfsp, MBF_MNTLSTLOCK) != 0)
- vfsp = NULL;
+ vfs_ref(vfsp);
break;
}
}
- if (vfsp == NULL)
- mtx_unlock(&mountlist_mtx);
+ mtx_unlock(&mountlist_mtx);
return (vfsp);
}
@@ -3545,7 +3543,9 @@ zfs_unmount_snap(const char *snapname)
{
vfs_t *vfsp;
zfsvfs_t *zfsvfs;
+#ifdef illumos
int err;
+#endif
if (strchr(snapname, '@') == NULL)
return (0);
@@ -3557,23 +3557,19 @@ zfs_unmount_snap(const char *snapname)
zfsvfs = vfsp->vfs_data;
ASSERT(!dsl_pool_config_held(dmu_objset_pool(zfsvfs->z_os)));
- err = vn_vfswlock(vfsp->vfs_vnodecovered);
#ifdef illumos
+ err = vn_vfswlock(vfsp->vfs_vnodecovered);
VFS_RELE(vfsp);
-#else
- vfs_unbusy(vfsp);
-#endif
if (err != 0)
return (SET_ERROR(err));
+#endif
/*
* Always force the unmount for snapshots.
*/
-
#ifdef illumos
(void) dounmount(vfsp, MS_FORCE, kcred);
#else
- vfs_ref(vfsp);
(void) dounmount(vfsp, MS_FORCE, curthread);
#endif
return (0);
More information about the svn-src-all
mailing list