From owner-svn-src-all@FreeBSD.ORG Wed Dec 25 01:03:15 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A5593B4D; Wed, 25 Dec 2013 01:03:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 853051023; Wed, 25 Dec 2013 01:03:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBP13FZK062282; Wed, 25 Dec 2013 01:03:15 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBP13EX1062277; Wed, 25 Dec 2013 01:03:14 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201312250103.rBP13EX1062277@svn.freebsd.org> From: Rick Macklem Date: Wed, 25 Dec 2013 01:03:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259854 - in head/sys/fs: nfs nfsserver X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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: Wed, 25 Dec 2013 01:03:15 -0000 Author: rmacklem Date: Wed Dec 25 01:03:14 2013 New Revision: 259854 URL: http://svnweb.freebsd.org/changeset/base/259854 Log: The NFSv4 server would call VOP_SETATTR() with a shared locked vnode when a Getattr for a file is done by a client other than the one that holds the file's delegation. This would only happen when delegations are enabled and the problem is fixed by this patch. MFC after: 1 week Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfs/nfs_var.h ============================================================================== --- head/sys/fs/nfs/nfs_var.h Wed Dec 25 00:53:48 2013 (r259853) +++ head/sys/fs/nfs/nfs_var.h Wed Dec 25 01:03:14 2013 (r259854) @@ -613,7 +613,7 @@ void nfsvno_open(struct nfsrv_descript * nfsv4stateid_t *, struct nfsstate *, int *, struct nfsvattr *, int32_t *, int, NFSACL_T *, nfsattrbit_t *, struct ucred *, NFSPROC_T *, struct nfsexstuff *, vnode_t *); -void nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct ucred *, +int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct ucred *, NFSPROC_T *); int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *, Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Wed Dec 25 00:53:48 2013 (r259853) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Wed Dec 25 01:03:14 2013 (r259854) @@ -1469,8 +1469,9 @@ nfsvno_open(struct nfsrv_descript *nd, s * Updates the file rev and sets the mtime and ctime * to the current clock time, returning the va_filerev and va_Xtime * values. + * Return ESTALE to indicate the vnode is VI_DOOMED. */ -void +int nfsvno_updfilerev(struct vnode *vp, struct nfsvattr *nvap, struct ucred *cred, struct thread *p) { @@ -1478,8 +1479,14 @@ nfsvno_updfilerev(struct vnode *vp, stru VATTR_NULL(&va); vfs_timestamp(&va.va_mtime); + if (NFSVOPISLOCKED(vp) != LK_EXCLUSIVE) { + NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY); + if ((vp->v_iflag & VI_DOOMED) != 0) + return (ESTALE); + } (void) VOP_SETATTR(vp, &va, cred); (void) nfsvno_getattr(vp, nvap, cred, p, 1); + return (0); } /* Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdstate.c Wed Dec 25 00:53:48 2013 (r259853) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Wed Dec 25 01:03:14 2013 (r259854) @@ -4853,15 +4853,15 @@ nfsrv_checkgetattr(struct nfsrv_descript nva.na_filerev > delegfilerev) || (NFSVNO_ISSETSIZE(&nva) && nva.na_size != nvap->na_size)) { - nfsvno_updfilerev(vp, nvap, cred, p); + error = nfsvno_updfilerev(vp, nvap, cred, p); if (NFSVNO_ISSETSIZE(&nva)) nvap->na_size = nva.na_size; } - } + } else + error = 0; /* Ignore callback errors for now. */ } else { NFSUNLOCKSTATE(); } - error = 0; out: NFSEXITCODE2(error, nd);