From owner-svn-src-all@FreeBSD.ORG Sun Apr 17 23:04:04 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F6E5106566B; Sun, 17 Apr 2011 23:04:04 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34A118FC15; Sun, 17 Apr 2011 23:04:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3HN44V9052339; Sun, 17 Apr 2011 23:04:04 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3HN44mq052335; Sun, 17 Apr 2011 23:04:04 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104172304.p3HN44mq052335@svn.freebsd.org> From: Rick Macklem Date: Sun, 17 Apr 2011 23:04:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220761 - head/sys/fs/nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Apr 2011 23:04:04 -0000 Author: rmacklem Date: Sun Apr 17 23:04:03 2011 New Revision: 220761 URL: http://svn.freebsd.org/changeset/base/220761 Log: Add checks for MNTK_UNMOUNTF at the beginning of three functions, so that threads don't get stuck in them during a forced dismount. nfs_sync/VFS_SYNC() needs this, since it is called by dounmount() before VFS_UNMOUNT(). The nfscl_nget() case makes sure that a thread doing an VOP_OPEN() or VOP_ADVLOCK() call doesn't get blocked before attempting the RPC. Attempting RPCs don't block, since they all fail once a forced dismount is in progress. The third one at the beginning of nfsrpc_close() is done so threads don't get blocked while doing VOP_INACTIVE() as the vnodes are cleared out. With these three changes plus a change to the umount(1) command so that it doesn't do "sync()" for the forced case seem to make forced dismounts work for the experimental NFS client. MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clstate.c head/sys/fs/nfsclient/nfs_clvfsops.c Modified: head/sys/fs/nfsclient/nfs_clrpcops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clrpcops.c Sun Apr 17 22:31:36 2011 (r220760) +++ head/sys/fs/nfsclient/nfs_clrpcops.c Sun Apr 17 23:04:03 2011 (r220761) @@ -567,6 +567,11 @@ nfsrpc_close(vnode_t vp, int doclose, NF if (vnode_vtype(vp) != VREG) return (0); + + /* For forced unmounts, just return. */ + if ((vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + return (0); + if (doclose) error = nfscl_doclose(vp, &clp, p); else Modified: head/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clstate.c Sun Apr 17 22:31:36 2011 (r220760) +++ head/sys/fs/nfsclient/nfs_clstate.c Sun Apr 17 23:04:03 2011 (r220761) @@ -692,6 +692,10 @@ nfscl_getcl(vnode_t vp, struct ucred *cr int igotlock = 0, error, trystalecnt, clidinusedelay, i; u_int16_t idlen = 0; + /* For forced unmounts, just return an error. */ + if ((vnode_mount(vp)->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + return (EPERM); + if (cred != NULL) { getcredhostuuid(cred, uuid, sizeof uuid); idlen = strlen(uuid); Modified: head/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvfsops.c Sun Apr 17 22:31:36 2011 (r220760) +++ head/sys/fs/nfsclient/nfs_clvfsops.c Sun Apr 17 23:04:03 2011 (r220761) @@ -1386,6 +1386,10 @@ nfs_sync(struct mount *mp, int waitfor) td = curthread; + /* For a forced unmount, just return EPERM. */ + if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) + return (EPERM); + /* * Force stale buffer cache information to be flushed. */