Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 01 Oct 2011 14:37:06 -0700
From:      Kirk McKusick <mckusick@mckusick.com>
To:        Garrett Cooper <yanegomi@gmail.com>
Cc:        Attilio Rao <attilio@freebsd.org>, Xin LI <delphij@freebsd.org>, freebsd-fs@freebsd.org
Subject:   Re: Need to force sync(2) before umounting UFS1 filesystems? 
Message-ID:  <201110012137.p91Lb6FI093841@chez.mckusick.com>
In-Reply-To: <CAGH67wSYmcxJCbTMVL%2BqWzbLojiCiBmRF98yaNL4b3d3LbvbYw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Sat, 1 Oct 2011 12:44:04 -0700
> Subject: Re: Need to force sync(2) before umounting UFS1 filesystems?
> From: Garrett Cooper <yanegomi@gmail.com>
> To: Attilio Rao <attilio@freebsd.org>
> Cc: Kostik Belousov <kostikbel@gmail.com>,
>         Kirk McKusick <mckusick@mckusick.com>, freebsd-fs@freebsd.org,
>         Xin LI <delphij@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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110012137.p91Lb6FI093841>