Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 May 2009 19:41:29 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r192928 - head/sys/fs/nfsclient
Message-ID:  <200905271941.n4RJfT1H009782@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Wed May 27 19:41:29 2009
New Revision: 192928
URL: http://svn.freebsd.org/changeset/base/192928

Log:
  Fix handling of NFSv4 Close operations in ncl_inactive(). Only
  do them for NFSv4 and flush writes to the server before doing
  the Close(s), as required. Also, use the a_td argument instead of
  curthread.
  
  Approved by:	kib (mentor)

Modified:
  head/sys/fs/nfsclient/nfs_clnode.c

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c	Wed May 27 19:31:50 2009	(r192927)
+++ head/sys/fs/nfsclient/nfs_clnode.c	Wed May 27 19:41:29 2009	(r192928)
@@ -185,17 +185,23 @@ ncl_inactive(struct vop_inactive_args *a
 {
 	struct nfsnode *np;
 	struct sillyrename *sp;
-	struct thread *td = curthread;	/* XXX */
 
 	np = VTONFS(ap->a_vp);
 	if (prtactive && vrefcnt(ap->a_vp) != 0)
 		vprint("ncl_inactive: pushing active", ap->a_vp);
 
-	/*
-	 * Since mmap()'d files to I/O after VOP_CLOSE(), the NFSv4 Close
-	 * operations are delayed until now.
-	 */
-	(void) nfsrpc_close(ap->a_vp, 1, td);
+	if (NFS_ISV4(ap->a_vp)) {
+		/*
+		 * Since mmap()'d files do I/O after VOP_CLOSE(), the NFSv4
+		 * Close operations are delayed until now. Any dirty buffers
+		 * must be flushed before the close, so that the stateid is
+		 * available for the writes.
+		 */
+		if (nfscl_mustflush(ap->a_vp))
+			(void) ncl_flush(ap->a_vp, MNT_WAIT, NULL, ap->a_td,
+			    1);
+		(void) nfsrpc_close(ap->a_vp, 1, ap->a_td);
+	}
 
 	if (ap->a_vp->v_type != VDIR) {
 		sp = np->n_sillyrename;
@@ -203,7 +209,7 @@ ncl_inactive(struct vop_inactive_args *a
 	} else
 		sp = NULL;
 	if (sp) {
-		(void)ncl_vinvalbuf(ap->a_vp, 0, td, 1);
+		(void)ncl_vinvalbuf(ap->a_vp, 0, ap->a_td, 1);
 		/*
 		 * Remove the silly file that was rename'd earlier
 		 */



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