svn commit: r302736 - in stable/9/sys/cddl: compat/opensolaris/kern contrib/opensolaris/uts/common/fs/zfs
Andriy Gapon
avg at FreeBSD.org
Wed Jul 13 09:41:06 UTC 2016
Author: avg
Date: Wed Jul 13 09:41:04 2016
New Revision: 302736
URL: https://svnweb.freebsd.org/changeset/base/302736
Log:
MFC r299902,299938: mount_snapshot: consolidate all error handling
Modified:
stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
Modified: stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
==============================================================================
--- stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Wed Jul 13 09:40:53 2016 (r302735)
+++ stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Wed Jul 13 09:41:04 2016 (r302736)
@@ -121,34 +121,39 @@ mount_snapshot(kthread_t *td, vnode_t **
struct ucred *cr;
int error;
+ ASSERT_VOP_ELOCKED(*vpp, "mount_snapshot");
+
+ vp = *vpp;
+ *vpp = NULL;
+ error = 0;
+
/*
* Be ultra-paranoid about making sure the type and fspath
* variables will fit in our mp buffers, including the
* terminating NUL.
*/
if (strlen(fstype) >= MFSNAMELEN || strlen(fspath) >= MNAMELEN)
- return (ENAMETOOLONG);
-
- vfsp = vfs_byname_kld(fstype, td, &error);
- if (vfsp == NULL)
- return (ENODEV);
-
- vp = *vpp;
- if (vp->v_type != VDIR)
- return (ENOTDIR);
+ error = ENAMETOOLONG;
+ if (error == 0 && (vfsp = vfs_byname_kld(fstype, td, &error)) == NULL)
+ error = ENODEV;
+ if (error == 0 && vp->v_type != VDIR)
+ error = ENOTDIR;
/*
* We need vnode lock to protect v_mountedhere and vnode interlock
* to protect v_iflag.
*/
- vn_lock(vp, LK_SHARED | LK_RETRY);
- VI_LOCK(vp);
- if ((vp->v_iflag & VI_MOUNT) != 0 || vp->v_mountedhere != NULL) {
+ if (error == 0) {
+ VI_LOCK(vp);
+ if ((vp->v_iflag & VI_MOUNT) == 0 && vp->v_mountedhere == NULL)
+ vp->v_iflag |= VI_MOUNT;
+ else
+ error = EBUSY;
VI_UNLOCK(vp);
- VOP_UNLOCK(vp, 0);
- return (EBUSY);
}
- vp->v_iflag |= VI_MOUNT;
- VI_UNLOCK(vp);
+ if (error != 0) {
+ vput(vp);
+ return (error);
+ }
VOP_UNLOCK(vp, 0);
/*
@@ -198,7 +203,6 @@ mount_snapshot(kthread_t *td, vnode_t **
vfs_unbusy(mp);
vfs_freeopts(mp->mnt_optnew);
vfs_mount_destroy(mp);
- *vpp = NULL;
return (error);
}
Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Wed Jul 13 09:40:53 2016 (r302735)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c Wed Jul 13 09:41:04 2016 (r302736)
@@ -1072,6 +1072,7 @@ domount:
(void) snprintf(mountpoint, mountpoint_len,
"%s/" ZFS_CTLDIR_NAME "/snapshot/%s",
dvp->v_vfsp->mnt_stat.f_mntonname, nm);
+ VERIFY0(vn_lock(*vpp, LK_EXCLUSIVE));
err = mount_snapshot(curthread, vpp, "zfs", mountpoint, snapname, 0);
kmem_free(mountpoint, mountpoint_len);
if (err == 0) {
More information about the svn-src-stable-9
mailing list