NFS41: send real read size in layoutget
authorPeng Tao <bergwolf@gmail.com>
Tue, 25 Sep 2012 06:55:57 +0000 (14:55 +0800)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 8 Oct 2012 23:32:34 +0000 (19:32 -0400)
For buffer read, use offst-to-isize.

For direct read, use dreq->bytes_left.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/pnfs.c

index 9a2bcce45282202e1673a850da5c93fbd14514c9..fe624c91bd006ef11f839f61cab54f833286edfa 100644 (file)
@@ -1220,16 +1220,24 @@ out_forget_reply:
 void
 pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
 {
+       u64 rd_size = req->wb_bytes;
+
        BUG_ON(pgio->pg_lseg != NULL);
 
        if (req->wb_offset != req->wb_pgbase) {
                nfs_pageio_reset_read_mds(pgio);
                return;
        }
+
+       if (pgio->pg_dreq == NULL)
+               rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
+       else
+               rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
+
        pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
                                           req->wb_context,
                                           req_offset(req),
-                                          req->wb_bytes,
+                                          rd_size,
                                           IOMODE_READ,
                                           GFP_KERNEL);
        /* If no lseg, fall back to read through mds */