From owner-freebsd-fs@FreeBSD.ORG Sat Oct 1 21:54:12 2011 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B374106564A; Sat, 1 Oct 2011 21:54:12 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by mx1.freebsd.org (Postfix) with ESMTP id D7B338FC08; Sat, 1 Oct 2011 21:54:11 +0000 (UTC) Received: by pzk32 with SMTP id 32so16701810pzk.3 for ; Sat, 01 Oct 2011 14:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=FWE2GkCStzLG58nd9T+D1gx0GlIg6Gu++b1EeiYT1m0=; b=SqjYAhak83KhYlbTMaIWFDeN21Q+cp7bRXlk13haboHgDCakNcQZAUWW2WL1yqswPi g+Jpe6Rnql/NSpPRxJFhWoiTn3Hn+SIrZeV1N46PW0vE0y/4v747niOFPuXYl24FOtYP cna5OeUp/X9qs43MBM2g8fJ9gyoZy67tuBOro= Received: by 10.68.208.229 with SMTP id mh5mr68887269pbc.124.1317506050980; Sat, 01 Oct 2011 14:54:10 -0700 (PDT) Received: from c-24-6-49-154.hsd1.ca.comcast.net (c-24-6-49-154.hsd1.ca.comcast.net. [24.6.49.154]) by mx.google.com with ESMTPS id ji3sm34388214pbc.2.2011.10.01.14.54.09 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 01 Oct 2011 14:54:09 -0700 (PDT) Date: Sat, 1 Oct 2011 14:54:04 -0700 (PDT) From: Garrett Cooper To: Kirk McKusick In-Reply-To: <201110012137.p91Lb6FI093841@chez.mckusick.com> Message-ID: References: <201110012137.p91Lb6FI093841@chez.mckusick.com> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Cc: Garrett Cooper , Attilio Rao , Xin LI , freebsd-fs@freebsd.org Subject: Re: Need to force sync(2) before umounting UFS1 filesystems? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Oct 2011 21:54:12 -0000 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 >> To: Attilio Rao >> Cc: Kostik Belousov , >> Kirk McKusick , freebsd-fs@freebsd.org, >> Xin LI >> >> 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