svn commit: r252072 - head/sys/fs/nfsclient

Rick Macklem rmacklem at FreeBSD.org
Fri Jun 21 22:26:19 UTC 2013


Author: rmacklem
Date: Fri Jun 21 22:26:18 2013
New Revision: 252072
URL: http://svnweb.freebsd.org/changeset/base/252072

Log:
  When the NFSv4.1 client is writing to a pNFS Data Server (DS), the
  file's size attribute does not get updated. As such, it is necessary
  to invalidate the attribute cache before clearing NMODIFIED for pNFS.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clbio.c
  head/sys/fs/nfsclient/nfs_clvnops.c

Modified: head/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clbio.c	Fri Jun 21 21:59:58 2013	(r252071)
+++ head/sys/fs/nfsclient/nfs_clbio.c	Fri Jun 21 22:26:18 2013	(r252072)
@@ -1372,9 +1372,16 @@ ncl_vinvalbuf(struct vnode *vp, int flag
 			goto out;
 		error = vinvalbuf(vp, flags, 0, slptimeo);
 	}
-	if (NFSHASPNFS(nmp))
+	if (NFSHASPNFS(nmp)) {
 		nfscl_layoutcommit(vp, td);
-	mtx_lock(&np->n_mtx);
+		/*
+		 * Invalidate the attribute cache, since writes to a DS
+		 * won't update the size attribute.
+		 */
+		mtx_lock(&np->n_mtx);
+		np->n_attrstamp = 0;
+	} else
+		mtx_lock(&np->n_mtx);
 	if (np->n_directio_asyncwr == 0)
 		np->n_flag &= ~NMODIFIED;
 	mtx_unlock(&np->n_mtx);
@@ -1555,6 +1562,13 @@ ncl_doio_directwrite(struct buf *bp)
 	if ((bp->b_flags & B_DIRECT) && bp->b_iocmd == BIO_WRITE) {
 		struct nfsnode *np = VTONFS(bp->b_vp);
 		mtx_lock(&np->n_mtx);
+		if (NFSHASPNFS(VFSTONFS(vnode_mount(bp->b_vp)))) {
+			/*
+			 * Invalidate the attribute cache, since writes to a DS
+			 * won't update the size attribute.
+			 */
+			np->n_attrstamp = 0;
+		}
 		np->n_directio_asyncwr--;
 		if (np->n_directio_asyncwr == 0) {
 			np->n_flag &= ~NMODIFIED;

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvnops.c	Fri Jun 21 21:59:58 2013	(r252071)
+++ head/sys/fs/nfsclient/nfs_clvnops.c	Fri Jun 21 22:26:18 2013	(r252072)
@@ -2951,9 +2951,16 @@ loop:
 		mtx_unlock(&np->n_mtx);
 	} else
 		BO_UNLOCK(bo);
-	if (NFSHASPNFS(nmp))
+	if (NFSHASPNFS(nmp)) {
 		nfscl_layoutcommit(vp, td);
-	mtx_lock(&np->n_mtx);
+		/*
+		 * Invalidate the attribute cache, since writes to a DS
+		 * won't update the size attribute.
+		 */
+		mtx_lock(&np->n_mtx);
+		np->n_attrstamp = 0;
+	} else
+		mtx_lock(&np->n_mtx);
 	if (np->n_flag & NWRITEERR) {
 		error = np->n_error;
 		np->n_flag &= ~NWRITEERR;


More information about the svn-src-head mailing list