Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Dec 2014 10:00:47 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275638 - in head/sys: fs/msdosfs kern
Message-ID:  <201412091000.sB9A0l9Z054543@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Dec  9 10:00:47 2014
New Revision: 275638
URL: https://svnweb.freebsd.org/changeset/base/275638

Log:
  Do not call VFS_SYNC() before VFS_UNMOUNT() for forced unmount.
  
  Since VFS does not/cannot stop writes, sync might run indefinitely, or
  be a wrong thing to do at all.  E. g. NFS ignores VFS_SYNC() for
  forced unmounts, since non-responding server does not allow sync to
  finish.  On the other hand, filesystems can and do stop writes using
  fs-specific facilities, and should already fully flush caches in
  VFS_UNMOUNT() due to the race.
  
  Adjust msdosfs tp sync in unmount for forced call, to accomodate the
  new behaviour.  Note that it is still racy, since writes are not
  stopped.
  
  Discussed with:	avg, bjk, mckusick
  Reported and tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 weeks

Modified:
  head/sys/fs/msdosfs/msdosfs_vfsops.c
  head/sys/kern/vfs_mount.c

Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Dec  9 09:36:28 2014	(r275637)
+++ head/sys/fs/msdosfs/msdosfs_vfsops.c	Tue Dec  9 10:00:47 2014	(r275638)
@@ -797,11 +797,15 @@ msdosfs_unmount(struct mount *mp, int mn
 	int error, flags;
 
 	flags = 0;
-	if (mntflags & MNT_FORCE)
+	error = msdosfs_sync(mp, MNT_WAIT);
+	if ((mntflags & MNT_FORCE) != 0) {
 		flags |= FORCECLOSE;
+	} else if (error != 0) {
+		return (error);
+	}
 	error = vflush(mp, 0, flags, curthread);
-	if (error && error != ENXIO)
-		return error;
+	if (error != 0 && error != ENXIO)
+		return (error);
 	pmp = VFSTOMSDOSFS(mp);
 	if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0) {
 		error = markvoldirty(pmp, 0);

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Tue Dec  9 09:36:28 2014	(r275637)
+++ head/sys/kern/vfs_mount.c	Tue Dec  9 10:00:47 2014	(r275638)
@@ -1305,8 +1305,8 @@ dounmount(mp, flags, td)
 		}
 		vput(fsrootvp);
 	}
-	if (((mp->mnt_flag & MNT_RDONLY) ||
-	     (error = VFS_SYNC(mp, MNT_WAIT)) == 0) || (flags & MNT_FORCE) != 0)
+	if ((mp->mnt_flag & MNT_RDONLY) != 0 || (flags & MNT_FORCE) != 0 ||
+	    (error = VFS_SYNC(mp, MNT_WAIT)) == 0)
 		error = VFS_UNMOUNT(mp, flags);
 	vn_finished_write(mp);
 	/*



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