From owner-svn-src-stable@FreeBSD.ORG Wed Jul 13 17:09:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB5F4106566C; Wed, 13 Jul 2011 17:09:15 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DA2528FC0A; Wed, 13 Jul 2011 17:09:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6DH9F9c092762; Wed, 13 Jul 2011 17:09:15 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6DH9Fo6092758; Wed, 13 Jul 2011 17:09:15 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201107131709.p6DH9Fo6092758@svn.freebsd.org> From: Sean Bruno Date: Wed, 13 Jul 2011 17:09:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223982 - in stable/7: sbin/umount sys/nfsclient X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2011 17:09:16 -0000 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);