Module Name:    src
Committed By:   martin
Date:           Wed Apr 22 18:05:11 UTC 2020

Modified Files:
        src/sys/kern [netbsd-9]: vfs_mount.c

Log Message:
Pull up following revision(s) (requested by gson in ticket #839):

        sys/kern/vfs_mount.c: revision 1.79

Destroy anonymous device vnodes on reboot once the last file system
got unmounted and the mount list is empty.

PR kern/54969: Disk cache is no longer flushed on shutdown


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.70.4.1 src/sys/kern/vfs_mount.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.70 src/sys/kern/vfs_mount.c:1.70.4.1
--- src/sys/kern/vfs_mount.c:1.70	Wed Feb 20 10:08:37 2019
+++ src/sys/kern/vfs_mount.c	Wed Apr 22 18:05:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_mount.c,v 1.70 2019/02/20 10:08:37 hannken Exp $	*/
+/*	$NetBSD: vfs_mount.c,v 1.70.4.1 2020/04/22 18:05:11 martin 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.70 2019/02/20 10:08:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.70.4.1 2020/04/22 18:05:11 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -114,6 +114,8 @@ static struct vnode *vfs_vnode_iterator_
 /* Root filesystem. */
 vnode_t *			rootvnode;
 
+extern struct mount		*dead_rootmount;
+
 /* Mounted filesystem list. */
 static TAILQ_HEAD(mountlist, mountlist_entry) mountlist;
 static kmutex_t			mountlist_lock;
@@ -1000,6 +1002,7 @@ bool
 vfs_unmountall1(struct lwp *l, bool force, bool verbose)
 {
 	struct mount *mp;
+	mount_iterator_t *iter;
 	bool any_error = false, progress = false;
 	uint64_t gen;
 	int error;
@@ -1034,6 +1037,24 @@ vfs_unmountall1(struct lwp *l, bool forc
 	if (any_error && verbose) {
 		printf("WARNING: some file systems would not unmount\n");
 	}
+
+	/* If the mountlist is empty destroy anonymous device vnodes. */
+	mountlist_iterator_init(&iter);
+	if (mountlist_iterator_next(iter) == NULL) {
+		struct vnode_iterator *marker;
+		vnode_t *vp;
+
+		vfs_vnode_iterator_init(dead_rootmount, &marker);
+		while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) {
+			if (vp->v_type == VCHR || vp->v_type == VBLK)
+				vgone(vp);
+			else
+				vrele(vp);
+		}
+		vfs_vnode_iterator_destroy(marker);
+	}
+	mountlist_iterator_destroy(iter);
+
 	return progress;
 }
 

Reply via email to