Module Name:    src
Committed By:   hannken
Date:           Mon Mar  6 10:11:21 UTC 2017

Modified Files:
        src/sys/kern: vfs_mount.c vfs_trans.c

Log Message:
Always use the lowest mount for fstrans and suspend.  This way we
enter/leave or suspend/resume the stack of layered file systems as a unit.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.38 -r1.39 src/sys/kern/vfs_trans.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.49 src/sys/kern/vfs_mount.c:1.50
--- src/sys/kern/vfs_mount.c:1.49	Mon Mar  6 10:10:43 2017
+++ src/sys/kern/vfs_mount.c	Mon Mar  6 10:11:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -711,12 +711,6 @@ mount_domount(struct lwp *l, vnode_t **v
 		return ENOMEM;
 	}
 
-	if ((error = fstrans_mount(mp)) != 0) {
-		vfs_unbusy(mp, false, NULL);
-		vfs_destroy(mp);
-		return error;
-	}
-
 	mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred);
 
 	/*
@@ -734,6 +728,12 @@ mount_domount(struct lwp *l, vnode_t **v
 	if (error != 0)
 		goto err_unmounted;
 
+	if (mp->mnt_lower == NULL) {
+		error = fstrans_mount(mp);
+		if (error)
+			goto err_mounted;
+	}
+
 	/*
 	 * Validate and prepare the mount point.
 	 */

Index: src/sys/kern/vfs_trans.c
diff -u src/sys/kern/vfs_trans.c:1.38 src/sys/kern/vfs_trans.c:1.39
--- src/sys/kern/vfs_trans.c:1.38	Thu Mar  2 10:41:27 2017
+++ src/sys/kern/vfs_trans.c	Mon Mar  6 10:11:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $	*/
+/*	$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $");
 
 /*
  * File system transaction operations.
@@ -123,6 +123,8 @@ static inline struct mount *
 fstrans_normalize_mount(struct mount *mp)
 {
 
+	while (mp && mp->mnt_lower)
+		mp = mp->mnt_lower;
 	if (mp == NULL)
 		return NULL;
 	if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)

Reply via email to