Need to force sync(2) before umounting UFS1 filesystems?

Kirk McKusick mckusick at mckusick.com
Sat Oct 1 21:37:06 UTC 2011


> Date: Sat, 1 Oct 2011 12:44:04 -0700
> Subject: Re: Need to force sync(2) before umounting UFS1 filesystems?
> From: Garrett Cooper <yanegomi at gmail.com>
> To: Attilio Rao <attilio at freebsd.org>
> Cc: Kostik Belousov <kostikbel at gmail.com>,
>         Kirk McKusick <mckusick at mckusick.com>, freebsd-fs at freebsd.org,
>         Xin LI <delphij at freebsd.org>
> 
> Ok. Now that I know this is the direction you guys want to go, I'll
> start testing the change.
> Thanks!
> -Garrett

Thanks for throwing some testing at this. Please test my latest
proposed change (included below so you do not have to dig through
earlier email) as I believe that it has the least likelyhood of
problems and is what I am currently proposing to put in.

	Kirk McKusick

Index: sys/kern/vfs_mount.c
===================================================================
--- sys/kern/vfs_mount.c	(revision 225903)
+++ sys/kern/vfs_mount.c	(working copy)
@@ -1187,6 +1187,7 @@
 
 	mtx_assert(&Giant, MA_OWNED);
 
+top:
 	if ((coveredvp = mp->mnt_vnodecovered) != NULL) {
 		mnt_gen_r = mp->mnt_gen;
 		VI_LOCK(coveredvp);
@@ -1227,21 +1228,19 @@
 		mp->mnt_kern_flag |= MNTK_UNMOUNTF;
 	error = 0;
 	if (mp->mnt_lockref) {
-		if ((flags & MNT_FORCE) == 0) {
-			mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ |
-			    MNTK_UNMOUNTF);
-			if (mp->mnt_kern_flag & MNTK_MWAIT) {
-				mp->mnt_kern_flag &= ~MNTK_MWAIT;
-				wakeup(mp);
-			}
-			MNT_IUNLOCK(mp);
-			if (coveredvp)
-				VOP_UNLOCK(coveredvp, 0);
-			return (EBUSY);
+		if (mp->mnt_kern_flag & MNTK_MWAIT) {
+			mp->mnt_kern_flag &= ~MNTK_MWAIT;
+			wakeup(mp);
 		}
+		if (coveredvp)
+			VOP_UNLOCK(coveredvp, 0);
 		mp->mnt_kern_flag |= MNTK_DRAINING;
 		error = msleep(&mp->mnt_lockref, MNT_MTX(mp), PVFS,
 		    "mount drain", 0);
+		mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ |
+		    MNTK_UNMOUNTF);
+		MNT_IUNLOCK(mp);
+		goto top;
 	}
 	MNT_IUNLOCK(mp);
 	KASSERT(mp->mnt_lockref == 0,


More information about the freebsd-fs mailing list