Author: kib
Date: Tue Nov 29 08:20:55 2016
New Revision: 309280
URL: https://svnweb.freebsd.org/changeset/base/309280
Log:
  MFC r308980:
  Use buffer pager for NFS.
  
  MFC note: really do not, by default.

Modified:
  stable/11/sys/fs/nfsclient/nfs_clbio.c
  stable/11/sys/fs/nfsclient/nfs_clvnops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clbio.c      Tue Nov 29 08:17:24 2016        
(r309279)
+++ stable/11/sys/fs/nfsclient/nfs_clbio.c      Tue Nov 29 08:20:55 2016        
(r309280)
@@ -78,6 +78,40 @@ static int nfs_directio_write(struct vno
 /*
  * Vnode op for VM getpages.
  */
+SYSCTL_DECL(_vfs_nfs);
+static int use_buf_pager = 0;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, use_buf_pager, CTLFLAG_RWTUN,
+    &use_buf_pager, 0,
+    "Use buffer pager instead of direct readrpc call");
+
+static daddr_t
+ncl_gbp_getblkno(struct vnode *vp, vm_ooffset_t off)
+{
+
+       return (off / vp->v_bufobj.bo_bsize);
+}
+
+static int
+ncl_gbp_getblksz(struct vnode *vp, daddr_t lbn)
+{
+       struct nfsnode *np;
+       u_quad_t nsize;
+       int biosize, bcount;
+
+       np = VTONFS(vp);
+       mtx_lock(&np->n_mtx);
+       nsize = np->n_size;
+       mtx_unlock(&np->n_mtx);
+
+       biosize = vp->v_bufobj.bo_bsize;
+       bcount = biosize;
+       if ((off_t)lbn * biosize >= nsize)
+               bcount = 0;
+       else if ((off_t)(lbn + 1) * biosize > nsize)
+               bcount = nsize - (off_t)lbn * biosize;
+       return (bcount);
+}
+
 int
 ncl_getpages(struct vop_getpages_args *ap)
 {
@@ -126,6 +160,10 @@ ncl_getpages(struct vop_getpages_args *a
        } else
                mtx_unlock(&nmp->nm_mtx);
 
+       if (use_buf_pager)
+               return (vfs_bio_getpages(vp, pages, npages, ap->a_rbehind,
+                   ap->a_rahead, ncl_gbp_getblkno, ncl_gbp_getblksz));
+
        /*
         * If the requested page is partially valid, just return it and
         * allow the pager to zero-out the blanks.  Partially valid pages

Modified: stable/11/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clvnops.c    Tue Nov 29 08:17:24 2016        
(r309279)
+++ stable/11/sys/fs/nfsclient/nfs_clvnops.c    Tue Nov 29 08:20:55 2016        
(r309280)
@@ -2569,13 +2569,20 @@ ncl_commit(struct vnode *vp, u_quad_t of
 static int
 nfs_strategy(struct vop_strategy_args *ap)
 {
-       struct buf *bp = ap->a_bp;
+       struct buf *bp;
+       struct vnode *vp;
        struct ucred *cr;
 
+       bp = ap->a_bp;
+       vp = ap->a_vp;
+       KASSERT(bp->b_vp == vp, ("missing b_getvp"));
        KASSERT(!(bp->b_flags & B_DONE),
            ("nfs_strategy: buffer %p unexpectedly marked B_DONE", bp));
        BUF_ASSERT_HELD(bp);
 
+       if (vp->v_type == VREG && bp->b_blkno == bp->b_lblkno)
+               bp->b_blkno = bp->b_lblkno * (vp->v_bufobj.bo_bsize /
+                   DEV_BSIZE);
        if (bp->b_iocmd == BIO_READ)
                cr = bp->b_rcred;
        else
@@ -2587,8 +2594,8 @@ nfs_strategy(struct vop_strategy_args *a
         * otherwise just do it ourselves.
         */
        if ((bp->b_flags & B_ASYNC) == 0 ||
-           ncl_asyncio(VFSTONFS(ap->a_vp->v_mount), bp, NOCRED, curthread))
-               (void) ncl_doio(ap->a_vp, bp, cr, curthread, 1);
+           ncl_asyncio(VFSTONFS(vp->v_mount), bp, NOCRED, curthread))
+               (void) ncl_doio(vp, bp, cr, curthread, 1);
        return (0);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to