svn commit: r254982 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

Xin LI delphij at FreeBSD.org
Wed Aug 28 00:39:48 UTC 2013


Author: delphij
Date: Wed Aug 28 00:39:47 2013
New Revision: 254982
URL: http://svnweb.freebsd.org/changeset/base/254982

Log:
  Previously, both zfs_rename and zfs_link does a check on whether
  the passed vnode belongs to the same mount point (v_vfsp or also
  known as v_mount in FreeBSD).  This check prevents the code from
  proceeding further on vnodes that do not belong to ZFS, for
  instance, on UFS or NULLFS.
  
  The recent change (merged as r254585) on upstream changes the
  check of v_vfsp to instead check the znode's z_zfsvfs.  On Illumos
  this would work because when the vnode comes from lofs, the
  VOP_REALVP() would give the right vnode, this is not true on
  FreeBSD where our VOP_REALVP is a no-op, and as such tdvp is
  not guaranteed to be a ZFS vnode, and will later trigger a
  failed assertion when verifying the vnode.
  
  This changeset modifies our local shims (zfs_freebsd_rename and
  zfs_freebsd_link) to check if v_mount matches before proceeding
  further.
  
  Reported by:		many
  Diagnostic work by:	avg

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Tue Aug 27 23:30:02 2013	(r254981)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Wed Aug 28 00:39:47 2013	(r254982)
@@ -6250,8 +6250,11 @@ zfs_freebsd_rename(ap)
 	ASSERT(ap->a_fcnp->cn_flags & (SAVENAME|SAVESTART));
 	ASSERT(ap->a_tcnp->cn_flags & (SAVENAME|SAVESTART));
 
-	error = zfs_rename(fdvp, ap->a_fcnp->cn_nameptr, tdvp,
-	    ap->a_tcnp->cn_nameptr, ap->a_fcnp->cn_cred, NULL, 0);
+	if (fdvp->v_mount == tdvp->v_mount)
+		error = zfs_rename(fdvp, ap->a_fcnp->cn_nameptr, tdvp,
+		    ap->a_tcnp->cn_nameptr, ap->a_fcnp->cn_cred, NULL, 0);
+	else
+		error = EXDEV;
 
 	if (tdvp == tvp)
 		VN_RELE(tdvp);
@@ -6308,10 +6311,15 @@ zfs_freebsd_link(ap)
 	} */ *ap;
 {
 	struct componentname *cnp = ap->a_cnp;
+	vnode_t *vp = ap->a_vp;
+	vnode_t *tdvp = ap->a_tdvp;
+
+	if (tdvp->v_mount != vp->v_mount)
+		return (EXDEV);
 
 	ASSERT(cnp->cn_flags & SAVENAME);
 
-	return (zfs_link(ap->a_tdvp, ap->a_vp, cnp->cn_nameptr, cnp->cn_cred, NULL, 0));
+	return (zfs_link(tdvp, vp, cnp->cn_nameptr, cnp->cn_cred, NULL, 0));
 }
 
 static int


More information about the svn-src-all mailing list