Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jan 2014 22:49:37 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r260174 - in stable/9/sys/fs: nfs nfsserver
Message-ID:  <201401012249.s01MnbCI071661@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed Jan  1 22:49:37 2014
New Revision: 260174
URL: http://svnweb.freebsd.org/changeset/base/260174

Log:
  MFC: r259854
  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.

Modified:
  stable/9/sys/fs/nfs/nfs_var.h
  stable/9/sys/fs/nfsserver/nfs_nfsdport.c
  stable/9/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/nfs/nfs_var.h
==============================================================================
--- stable/9/sys/fs/nfs/nfs_var.h	Wed Jan  1 22:43:16 2014	(r260173)
+++ stable/9/sys/fs/nfs/nfs_var.h	Wed Jan  1 22:49:37 2014	(r260174)
@@ -561,7 +561,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: stable/9/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- stable/9/sys/fs/nfsserver/nfs_nfsdport.c	Wed Jan  1 22:43:16 2014	(r260173)
+++ stable/9/sys/fs/nfsserver/nfs_nfsdport.c	Wed Jan  1 22:49:37 2014	(r260174)
@@ -1470,8 +1470,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)
 {
@@ -1479,8 +1480,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: stable/9/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- stable/9/sys/fs/nfsserver/nfs_nfsdstate.c	Wed Jan  1 22:43:16 2014	(r260173)
+++ stable/9/sys/fs/nfsserver/nfs_nfsdstate.c	Wed Jan  1 22:49:37 2014	(r260174)
@@ -4852,15 +4852,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);



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