Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Oct 2011 14:54:04 -0700 (PDT)
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Kirk McKusick <mckusick@mckusick.com>
Cc:        Garrett Cooper <yanegomi@gmail.com>, 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:  <alpine.BSF.2.00.1110011453200.3854@toaster.local>
In-Reply-To: <201110012137.p91Lb6FI093841@chez.mckusick.com>
References:  <201110012137.p91Lb6FI093841@chez.mckusick.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 1 Oct 2011, Kirk McKusick wrote:

>> 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,

I'll run it through a few other filesystems (ntfs, smbfs, etc) just in 
case. I should have results by either Monday or Tuesday.
Thanks,
-Garrett



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