Module Name: src Committed By: hannken Date: Wed May 17 12:45:03 UTC 2017
Modified Files: src/sys/kern: vfs_mount.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 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.61 src/sys/kern/vfs_mount.c:1.62 --- src/sys/kern/vfs_mount.c:1.61 Sun May 7 08:26:58 2017 +++ src/sys/kern/vfs_mount.c Wed May 17 12:45:03 2017 @@ -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 @@ vflush(struct mount *mp, vnode_t *skipvp * 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 @@ dounmount(struct mount *mp, int flags, s */ 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 @@ dounmount(struct mount *mp, int flags, s if (mp->mnt_busynest != 0) { mutex_exit(&mp->mnt_unmounting); mutex_exit(&syncer_mutex); + vfs_resume(mp); return EBUSY; } @@ -933,6 +940,7 @@ dounmount(struct mount *mp, int flags, s 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 @@ dounmount(struct mount *mp, int flags, s */ 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);