Author: rmacklem
Date: Mon Jun 25 01:48:18 2012
New Revision: 237543
URL: http://svn.freebsd.org/changeset/base/237543

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

Modified:
  stable/9/sys/fs/nfsclient/nfs_clnode.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/dev/e1000/   (props changed)
  stable/9/sys/dev/isp/   (props changed)
  stable/9/sys/dev/ixgbe/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/modules/   (props changed)

Modified: stable/9/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clnode.c      Sun Jun 24 23:12:24 2012        
(r237542)
+++ stable/9/sys/fs/nfsclient/nfs_clnode.c      Mon Jun 25 01:48:18 2012        
(r237543)
@@ -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-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to