aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-08-31 05:05:47 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-08-31 05:05:47 -0400
commit2d89a1d3c9ff8ceb115f001e66cff9788338ca47 (patch)
treec9e05f049190c054640b7c49695deef9c5d3cf5a
parent21b874c873b5019db8bb4b4f6aa929c4bac0a398 (diff)
NFSv4.1/pNFS: Don't request a minimal read layout beyond the end of file
If we have a read layout, then sanity check the minimal layout length so that it does not extend beyond the end of file. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/pnfs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c4f918eca3d2..ba1246433794 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -868,6 +868,7 @@ send_layoutget(struct pnfs_layout_hdr *lo,
868 struct nfs_server *server = NFS_SERVER(ino); 868 struct nfs_server *server = NFS_SERVER(ino);
869 struct nfs4_layoutget *lgp; 869 struct nfs4_layoutget *lgp;
870 struct pnfs_layout_segment *lseg; 870 struct pnfs_layout_segment *lseg;
871 loff_t i_size;
871 872
872 dprintk("--> %s\n", __func__); 873 dprintk("--> %s\n", __func__);
873 874
@@ -875,9 +876,17 @@ send_layoutget(struct pnfs_layout_hdr *lo,
875 if (lgp == NULL) 876 if (lgp == NULL)
876 return NULL; 877 return NULL;
877 878
879 i_size = i_size_read(ino);
880
878 lgp->args.minlength = PAGE_CACHE_SIZE; 881 lgp->args.minlength = PAGE_CACHE_SIZE;
879 if (lgp->args.minlength > range->length) 882 if (lgp->args.minlength > range->length)
880 lgp->args.minlength = range->length; 883 lgp->args.minlength = range->length;
884 if (range->iomode == IOMODE_READ) {
885 if (range->offset >= i_size)
886 lgp->args.minlength = 0;
887 else if (i_size - range->offset < lgp->args.minlength)
888 lgp->args.minlength = i_size - range->offset;
889 }
881 lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; 890 lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE;
882 lgp->args.range = *range; 891 lgp->args.range = *range;
883 lgp->args.type = server->pnfs_curr_ld->id; 892 lgp->args.type = server->pnfs_curr_ld->id;