From owner-freebsd-fs@FreeBSD.ORG Sat Oct 1 21:37:06 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 4D33C106564A; Sat, 1 Oct 2011 21:37:05 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [70.36.157.235]) by mx1.freebsd.org (Postfix) with ESMTP id E4CCE8FC15; Sat, 1 Oct 2011 21:37:04 +0000 (UTC) Received: from chez.mckusick.com (localhost [127.0.0.1]) by chez.mckusick.com (8.14.3/8.14.3) with ESMTP id p91Lb6FI093841; Sat, 1 Oct 2011 14:37:06 -0700 (PDT) (envelope-from mckusick@chez.mckusick.com) Message-Id: <201110012137.p91Lb6FI093841@chez.mckusick.com> To: Garrett Cooper In-reply-to: Date: Sat, 01 Oct 2011 14:37:06 -0700 From: Kirk McKusick X-Spam-Status: No, score=0.0 required=5.0 tests=MISSING_MID, UNPARSEABLE_RELAY autolearn=failed version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on chez.mckusick.com Cc: 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:37:06 -0000 > 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,