Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Suspend file system while unmounting. This way no ...



details:   https://anonhg.NetBSD.org/src/rev/1a3ebe26565f
branches:  trunk
changeset: 823981:1a3ebe26565f
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 17 12:45:03 2017 +0000

description:
Suspend file system while unmounting.  This way no operations run
on the mounted file system during unmount and all operations see
the state before or after the (possibly failed) unmount.

diffstat:

 sys/kern/vfs_mount.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (64 lines):

diff -r 9d0261ce7a78 -r 1a3ebe26565f sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Wed May 17 12:11:41 2017 +0000
+++ b/sys/kern/vfs_mount.c      Wed May 17 12:45:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.61 2017/05/07 08:26:58 hannken Exp $   */
+/*     $NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 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.61 2017/05/07 08:26:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.62 2017/05/17 12:45:03 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -599,7 +599,7 @@
                 * First, flush out any vnode references from the
                 * deferred vrele list.
                 */
-               vfs_drainvnodes();
+               vrele_flush(mp);
 
                vfs_vnode_iterator_init(mp, &marker);
 
@@ -875,6 +875,12 @@
         */
        mutex_enter(&syncer_mutex);
 
+       error = vfs_suspend(mp, 0);
+       if (error) {
+               mutex_exit(&syncer_mutex);
+               return error;
+       }
+
        /*
         * Abort unmount attempt when the filesystem is in use
         */
@@ -882,6 +888,7 @@
        if (mp->mnt_busynest != 0) {
                mutex_exit(&mp->mnt_unmounting);
                mutex_exit(&syncer_mutex);
+               vfs_resume(mp);
                return EBUSY;
        }
 
@@ -933,6 +940,7 @@
                        vfs_syncer_add_to_worklist(mp);
                mp->mnt_flag |= async;
                mutex_exit(&mp->mnt_updating);
+               vfs_resume(mp);
                if (used_syncer)
                        mutex_exit(&syncer_mutex);
                if (used_extattr) {
@@ -955,6 +963,7 @@
         */
        mp->mnt_iflag |= IMNT_GONE;
        mutex_exit(&mp->mnt_unmounting);
+       vfs_resume(mp);
 
        if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
                vn_lock(coveredvp, LK_EXCLUSIVE | LK_RETRY);



Home | Main Index | Thread Index | Old Index