From owner-svn-src-head@freebsd.org Wed Apr 5 17:26:22 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0806AD3072A; Wed, 5 Apr 2017 17:26:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF1F228C; Wed, 5 Apr 2017 17:26:21 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v35HQKCf077077; Wed, 5 Apr 2017 17:26:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v35HQKGf077076; Wed, 5 Apr 2017 17:26:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201704051726.v35HQKGf077076@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Apr 2017 17:26:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316532 - head/sys/fs/nfsclient X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2017 17:26:22 -0000 Author: kib Date: Wed Apr 5 17:26:20 2017 New Revision: 316532 URL: https://svnweb.freebsd.org/changeset/base/316532 Log: Make nfs pageout coherent with the dirty state of the buffers. Write out the dirty pages using VOP_WRITE() instead of directly calling ncl_writerpc(). The state of the buffers now reflects the write, fixing some hard to diagnose consistency and write order issues. The change also allowed to remove remapping of paged out pages into kernel space and related allocation of the phys buffer. Reviewed by: markj, rmacklem Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D10241 Modified: head/sys/fs/nfsclient/nfs_clbio.c Modified: head/sys/fs/nfsclient/nfs_clbio.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clbio.c Wed Apr 5 17:20:31 2017 (r316531) +++ head/sys/fs/nfsclient/nfs_clbio.c Wed Apr 5 17:26:20 2017 (r316532) @@ -266,9 +266,7 @@ ncl_putpages(struct vop_putpages_args *a { struct uio uio; struct iovec iov; - vm_offset_t kva; - struct buf *bp; - int iomode, must_commit, i, error, npages, count; + int i, error, npages, count; off_t offset; int *rtvals; struct vnode *vp; @@ -322,44 +320,26 @@ ncl_putpages(struct vop_putpages_args *a } mtx_unlock(&np->n_mtx); - /* - * We use only the kva address for the buffer, but this is extremely - * convenient and fast. - */ - bp = getpbuf(&ncl_pbuf_freecnt); - - kva = (vm_offset_t) bp->b_data; - pmap_qenter(kva, pages, npages); PCPU_INC(cnt.v_vnodeout); PCPU_ADD(cnt.v_vnodepgsout, count); - iov.iov_base = (caddr_t) kva; + iov.iov_base = unmapped_buf; iov.iov_len = count; uio.uio_iov = &iov; uio.uio_iovcnt = 1; uio.uio_offset = offset; uio.uio_resid = count; - uio.uio_segflg = UIO_SYSSPACE; + uio.uio_segflg = UIO_NOCOPY; uio.uio_rw = UIO_WRITE; uio.uio_td = td; - if ((ap->a_sync & VM_PAGER_PUT_SYNC) == 0) - iomode = NFSWRITE_UNSTABLE; - else - iomode = NFSWRITE_FILESYNC; - - error = ncl_writerpc(vp, &uio, cred, &iomode, &must_commit, 0); + error = VOP_WRITE(vp, &uio, vnode_pager_putpages_ioflags(ap->a_sync), + cred); crfree(cred); - pmap_qremove(kva, npages); - relpbuf(bp, &ncl_pbuf_freecnt); - - if (error == 0 || !nfs_keep_dirty_on_error) { + if (error == 0 || !nfs_keep_dirty_on_error) vnode_pager_undirty_pages(pages, rtvals, count - uio.uio_resid); - if (must_commit) - ncl_clearcommit(vp->v_mount); - } - return rtvals[0]; + return (rtvals[0]); } /* @@ -1385,7 +1365,8 @@ ncl_vinvalbuf(struct vnode *vp, int flag /* * Now, flush as required. */ - if ((flags & V_SAVE) && (vp->v_bufobj.bo_object != NULL)) { + if ((flags & (V_SAVE | V_VMIO)) == V_SAVE && + vp->v_bufobj.bo_object != NULL) { VM_OBJECT_WLOCK(vp->v_bufobj.bo_object); vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC); VM_OBJECT_WUNLOCK(vp->v_bufobj.bo_object);