[Midnightbsd-cvs] src [10018] trunk/sys/fs/unionfs: sync unionfs with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 18:04:46 EDT 2018


Revision: 10018
          http://svnweb.midnightbsd.org/src/?rev=10018
Author:   laffer1
Date:     2018-05-27 18:04:46 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync unionfs with freebsd

Modified Paths:
--------------
    trunk/sys/fs/unionfs/union.h
    trunk/sys/fs/unionfs/union_subr.c
    trunk/sys/fs/unionfs/union_vfsops.c
    trunk/sys/fs/unionfs/union_vnops.c

Modified: trunk/sys/fs/unionfs/union.h
===================================================================
--- trunk/sys/fs/unionfs/union.h	2018-05-27 22:04:00 UTC (rev 10017)
+++ trunk/sys/fs/unionfs/union.h	2018-05-27 22:04:46 UTC (rev 10018)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994 The Regents of the University of California.
  * Copyright (c) 1994 Jan-Simon Pendry.
@@ -33,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)union.h	8.9 (Berkeley) 12/10/94
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/fs/unionfs/union.h 185283 2008-11-25 03:18:35Z daichi $
  */
 
 #ifdef _KERNEL

Modified: trunk/sys/fs/unionfs/union_subr.c
===================================================================
--- trunk/sys/fs/unionfs/union_subr.c	2018-05-27 22:04:00 UTC (rev 10017)
+++ trunk/sys/fs/unionfs/union_subr.c	2018-05-27 22:04:46 UTC (rev 10018)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994 Jan-Simon Pendry
  * Copyright (c) 1994
@@ -33,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)union_subr.c	8.20 (Berkeley) 5/20/95
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/fs/unionfs/union_subr.c 276500 2015-01-01 10:44:20Z kib $
  */
 
 #include <sys/param.h>
@@ -247,12 +248,6 @@
 		if (dvp == NULLVP)
 			return (EINVAL);
 	}
-
-	/*
-	 * Do the MALLOC before the getnewvnode since doing so afterward
-	 * might cause a bogus v_data pointer to get dereferenced elsewhere
-	 * if MALLOC should block.
-	 */
 	unp = malloc(sizeof(struct unionfs_node),
 	    M_UNIONFSNODE, M_WAITOK | M_ZERO);
 
@@ -331,7 +326,6 @@
 void
 unionfs_noderem(struct vnode *vp, struct thread *td)
 {
-	int		vfslocked;
 	int		count;
 	struct unionfs_node *unp, *unp_t1, *unp_t2;
 	struct unionfs_node_hashhead *hd;
@@ -366,20 +360,12 @@
 	if (lockmgr(vp->v_vnlock, LK_EXCLUSIVE, VI_MTX(vp)) != 0)
 		panic("the lock for deletion is unacquirable.");
 
-	if (lvp != NULLVP) {
-		vfslocked = VFS_LOCK_GIANT(lvp->v_mount);
+	if (lvp != NULLVP)
 		vrele(lvp);
-		VFS_UNLOCK_GIANT(vfslocked);
-	}
-	if (uvp != NULLVP) {
-		vfslocked = VFS_LOCK_GIANT(uvp->v_mount);
+	if (uvp != NULLVP)
 		vrele(uvp);
-		VFS_UNLOCK_GIANT(vfslocked);
-	}
 	if (dvp != NULLVP) {
-		vfslocked = VFS_LOCK_GIANT(dvp->v_mount);
 		vrele(dvp);
-		VFS_UNLOCK_GIANT(vfslocked);
 		unp->un_dvp = NULLVP;
 	}
 	if (unp->un_path != NULL) {
@@ -551,6 +537,8 @@
 		cn->cn_flags |= (cnp->cn_flags & (DOWHITEOUT | SAVESTART));
 	else if (RENAME == nameiop)
 		cn->cn_flags |= (cnp->cn_flags & SAVESTART);
+	else if (nameiop == CREATE)
+		cn->cn_flags |= NOCACHE;
 
 	vref(dvp);
 	VOP_UNLOCK(dvp, LK_RELEASE);
@@ -955,6 +943,8 @@
 		goto unionfs_vn_create_on_upper_free_out1;
 	}
 	VOP_ADD_WRITECOUNT(vp, 1);
+	CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d",  __func__, vp,
+	    vp->v_writecount);
 	*vpp = vp;
 
 unionfs_vn_create_on_upper_free_out1:
@@ -1090,6 +1080,8 @@
 	}
 	VOP_CLOSE(uvp, FWRITE, cred, td);
 	VOP_ADD_WRITECOUNT(uvp, -1);
+	CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", __func__, uvp,
+	    uvp->v_writecount);
 
 	vn_finished_write(mp);
 
@@ -1180,7 +1172,7 @@
 		edp = (struct dirent*)&buf[sizeof(buf) - uio.uio_resid];
 		for (dp = (struct dirent*)buf; !error && dp < edp;
 		     dp = (struct dirent*)((caddr_t)dp + dp->d_reclen)) {
-			if (dp->d_type == DT_WHT ||
+			if (dp->d_type == DT_WHT || dp->d_fileno == 0 ||
 			    (dp->d_namlen == 1 && dp->d_name[0] == '.') ||
 			    (dp->d_namlen == 2 && !bcmp(dp->d_name, "..", 2)))
 				continue;

Modified: trunk/sys/fs/unionfs/union_vfsops.c
===================================================================
--- trunk/sys/fs/unionfs/union_vfsops.c	2018-05-27 22:04:00 UTC (rev 10017)
+++ trunk/sys/fs/unionfs/union_vfsops.c	2018-05-27 22:04:46 UTC (rev 10018)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1994, 1995 The Regents of the University of California.
  * Copyright (c) 1994, 1995 Jan-Simon Pendry.
@@ -33,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)union_vfsops.c	8.20 (Berkeley) 5/20/95
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/fs/unionfs/union_vfsops.c 242833 2012-11-09 18:02:25Z attilio $
  */
 
 #include <sys/param.h>
@@ -266,11 +267,6 @@
 	ump->um_copymode = copymode;
 	ump->um_whitemode = whitemode;
 
-	MNT_ILOCK(mp);
-	if ((lowerrootvp->v_mount->mnt_kern_flag & MNTK_MPSAFE) &&
-	    (upperrootvp->v_mount->mnt_kern_flag & MNTK_MPSAFE))
-		mp->mnt_kern_flag |= MNTK_MPSAFE;
-	MNT_IUNLOCK(mp);
 	mp->mnt_data = ump;
 
 	/*
@@ -352,7 +348,7 @@
 		return (error);
 
 	free(ump, M_UNIONFSMNT);
-	mp->mnt_data = 0;
+	mp->mnt_data = NULL;
 
 	return (0);
 }

Modified: trunk/sys/fs/unionfs/union_vnops.c
===================================================================
--- trunk/sys/fs/unionfs/union_vnops.c	2018-05-27 22:04:00 UTC (rev 10017)
+++ trunk/sys/fs/unionfs/union_vnops.c	2018-05-27 22:04:46 UTC (rev 10018)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry.
  * Copyright (c) 1992, 1993, 1994, 1995
@@ -34,7 +35,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)union_vnops.c	8.32 (Berkeley) 6/23/95
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/fs/unionfs/union_vnops.c 276500 2015-01-01 10:44:20Z kib $
  *
  */
 
@@ -160,8 +161,7 @@
 				    LK_RETRY);
 
 			vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
-		} else if (error == ENOENT && (cnflags & MAKEENTRY) &&
-		    nameiop != CREATE)
+		} else if (error == ENOENT && (cnflags & MAKEENTRY) != 0)
 			cache_enter(dvp, NULLVP, cnp);
 
 		UNIONFS_INTERNAL_DEBUG("unionfs_lookup: leave (%d)\n", error);
@@ -337,7 +337,7 @@
 	if (lvp != NULLVP)
 		vrele(lvp);
 
-	if (error == ENOENT && (cnflags & MAKEENTRY) && nameiop != CREATE)
+	if (error == ENOENT && (cnflags & MAKEENTRY) != 0)
 		cache_enter(dvp, NULLVP, cnp);
 
 	UNIONFS_INTERNAL_DEBUG("unionfs_lookup: leave (%d)\n", error);
@@ -1721,7 +1721,7 @@
 unionfs_inactive(struct vop_inactive_args *ap)
 {
 	ap->a_vp->v_object = NULL;
-	vrecycle(ap->a_vp, ap->a_td);
+	vrecycle(ap->a_vp);
 	return (0);
 }
 
@@ -1867,8 +1867,7 @@
 	if ((revlock = unionfs_get_llt_revlock(vp, flags)) == 0)
 		panic("unknown lock type: 0x%x", flags & LK_TYPE_MASK);
 
-	if ((mp->mnt_kern_flag & MNTK_MPSAFE) != 0 &&
-	    (vp->v_iflag & VI_OWEINACT) != 0)
+	if ((vp->v_iflag & VI_OWEINACT) != 0)
 		flags |= LK_NOWAIT;
 
 	/*



More information about the Midnightbsd-cvs mailing list