Author: rmacklem
Date: Mon Jun 18 22:17:28 2012
New Revision: 237244
URL: http://svn.freebsd.org/changeset/base/237244

Log:
  Fix the NFSv4 client for the case where mmap'd files are
  written, but not msync'd by a process. A VOP_PUTPAGES()
  called when VOP_RECLAIM() happens will usually fail, since
  the NFSv4 Open has already been closed by VOP_INACTIVE().
  Add a vm_object_page_clean() call to the NFSv4 client's
  VOP_INACTIVE(), so that the write happens before the NFSv4
  Open is closed. kib@ suggested using vgone() instead and
  I will explore this, but this patch fixes things in the
  meantime. For some reason, the VOP_PUTPAGES() is still
  attaempted in VOP_RECLAIM(), but having this fail doesn't
  cause any problems except a "stateid0 in write" being logged.
  
  Reviewed by:  kib
  MFC after:    1 week

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

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c  Mon Jun 18 21:08:48 2012        
(r237243)
+++ head/sys/fs/nfsclient/nfs_clnode.c  Mon Jun 18 22:17:28 2012        
(r237244)
@@ -210,18 +210,28 @@ ncl_inactive(struct vop_inactive_args *a
        struct nfsnode *np;
        struct sillyrename *sp;
        struct vnode *vp = ap->a_vp;
+       boolean_t retv;
 
        np = VTONFS(vp);
 
        if (NFS_ISV4(vp) && vp->v_type == VREG) {
                /*
                 * 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.
+                * Close operations are delayed until now. Any dirty
+                * buffers/pages must be flushed before the close, so that the
+                * stateid is available for the writes.
                 */
-               (void) ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0);
-               (void) nfsrpc_close(vp, 1, ap->a_td);
+               if (vp->v_object != NULL) {
+                       VM_OBJECT_LOCK(vp->v_object);
+                       retv = vm_object_page_clean(vp->v_object, 0, 0,
+                           OBJPC_SYNC);
+                       VM_OBJECT_UNLOCK(vp->v_object);
+               } else
+                       retv = TRUE;
+               if (retv == TRUE) {
+                       (void)ncl_flush(vp, MNT_WAIT, NULL, ap->a_td, 1, 0);
+                       (void)nfsrpc_close(vp, 1, ap->a_td);
+               }
        }
 
        mtx_lock(&np->n_mtx);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to