diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2017-09-12 06:04:01 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2017-09-12 06:04:01 +0000 |
commit | d092f79489a00e3ccc2d7784e7a18e19aba4c35f (patch) | |
tree | f91dfcf097936cbf5738be1693cf3dab55d92315 /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c | |
parent | f7519dbb7642932b679c64b87e86750afc4cfc45 (diff) | |
download | src-d092f79489a00e3ccc2d7784e7a18e19aba4c35f.tar.gz src-d092f79489a00e3ccc2d7784e7a18e19aba4c35f.zip |
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
Notes
Notes:
svn path=/head/; revision=323480
Diffstat (limited to 'sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index 425aed567404..156c55c59e7a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -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); |