svn commit: r223982 - in stable/7: sbin/umount sys/nfsclient

Sean Bruno sbruno at FreeBSD.org
Wed Jul 13 17:09:16 UTC 2011


Author: sbruno
Date: Wed Jul 13 17:09:15 2011
New Revision: 223982
URL: http://svn.freebsd.org/changeset/base/223982

Log:
  MFC r222541, r222464, r222466
  
  Modify the umount(8) command so that it doesn't do
  a sync(2) syscall before unmount(2) for the "-f" case.
  This avoids a forced dismount from getting stuck for
  an NFS mountpoint in sync() when the server is not
  responsive. With this commit, forced dismounts should
  normally work for the NFS clients, but can take up to
  about 1minute to complete.
  
  Add a check for MNTK_UNMOUNTF at the beginning of nfs_sync()
  in the old NFS client so that a forced dismount doesn't
  get stuck in the VFS_SYNC() call that happens before
  VFS_UNMOUNT() in dounmount(). Analagous to r222329 for the new NFS client.
  An additional change is needed before forced dismounts will work.
  
  Add a sentence to the umount.8 man page to clarify the behaviour
  for forced dismount when used on an NFS mount point. Requested by
  Jeremy Chadwick.
  This is a content change

Modified:
  stable/7/sbin/umount/umount.8
  stable/7/sbin/umount/umount.c
  stable/7/sys/nfsclient/nfs_vfsops.c

Modified: stable/7/sbin/umount/umount.8
==============================================================================
--- stable/7/sbin/umount/umount.8	Wed Jul 13 14:10:28 2011	(r223981)
+++ stable/7/sbin/umount/umount.8	Wed Jul 13 17:09:15 2011	(r223982)
@@ -28,7 +28,7 @@
 .\"     @(#)umount.8	8.2 (Berkeley) 5/8/95
 .\" $FreeBSD$
 .\"
-.Dd July 18, 2003
+.Dd May 31, 2011
 .Dt UMOUNT 8
 .Os
 .Sh NAME
@@ -77,6 +77,9 @@ The file system is forcibly unmounted.
 Active special devices continue to work,
 but all other files return errors if further accesses are attempted.
 The root file system cannot be forcibly unmounted.
+For NFS, a forced dismount can take up to 1 minute or more to
+complete against an unresponsive server and may throw away
+data not yet written to the server for this case.
 .It Fl h Ar host
 Only file systems mounted from the specified host will be
 unmounted.

Modified: stable/7/sbin/umount/umount.c
==============================================================================
--- stable/7/sbin/umount/umount.c	Wed Jul 13 14:10:28 2011	(r223981)
+++ stable/7/sbin/umount/umount.c	Wed Jul 13 17:09:15 2011	(r223982)
@@ -90,9 +90,6 @@ main(int argc, char *argv[])
 	struct statfs *mntbuf, *sfs;
 	struct addrinfo hints;
 
-	/* Start disks transferring immediately. */
-	sync();
-
 	all = errs = 0;
 	while ((ch = getopt(argc, argv, "AaF:fh:t:v")) != -1)
 		switch (ch) {
@@ -127,6 +124,9 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
+	/* Start disks transferring immediately. */
+	if ((fflag & MNT_FORCE) == 0)
+		sync();
 	if ((argc == 0 && !all) || (argc != 0 && all))
 		usage();
 

Modified: stable/7/sys/nfsclient/nfs_vfsops.c
==============================================================================
--- stable/7/sys/nfsclient/nfs_vfsops.c	Wed Jul 13 14:10:28 2011	(r223981)
+++ stable/7/sys/nfsclient/nfs_vfsops.c	Wed Jul 13 17:09:15 2011	(r223982)
@@ -1297,10 +1297,19 @@ nfs_sync(struct mount *mp, int waitfor, 
 	struct vnode *vp, *mvp;
 	int error, allerror = 0;
 
+	MNT_ILOCK(mp);
+       /*
+	* If a forced dismount is in progress, return from here so that
+	* the umount(2) syscall doesn't get stuck in VFS_SYNC() before
+	* calling VFS_UNMOUNT().
+	*/
+	if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
+		MNT_IUNLOCK(mp);
+		return (EBADF);
+	}
 	/*
 	 * Force stale buffer cache information to be flushed.
 	 */
-	MNT_ILOCK(mp);
 loop:
 	MNT_VNODE_FOREACH(vp, mp, mvp) {
 		VI_LOCK(vp);


More information about the svn-src-stable-7 mailing list