NFSv4.1/pnfs: Don't ask for a read layout for an empty file.
Subsystems (2)
PATCH v2 1/3 NFSv4.1/pnfs: Don't ask for a read layout for an empty file.
Signed-off-by Trond Myklebust <[email protected]>
--- fs/nfs/pnfs.c | 3 +++ 1 file changed, 3 insertions(+)
fs/nfs/pnfs.c +3 -0
@@ -1494,6 +1494,9 @@ pnfs_update_layout(struct inode *ino,if (!pnfs_enabled_sb (NFS_SERVER (ino))) goto out; +if (iomode ==IOMODE_READ &&i_size_read (ino) ==0 ) + goto out; +if (pnfs_within_mdsthreshold (ctx, ino, iomode)) goto out;
Signature · 1 line
2.4.3
PATCH v2 2/3 NFSv4.1/pnfs: Handle LAYOUTGET return values correctly
According to RFC5661 section 18.43.3, if the server cannot satisfy the loga_minlength argument to LAYOUTGET, there are 2 cases:
1) If loga_minlength == 0, it returns NFS4ERR_LAYOUTTRYLATER
2) If loga_minlength != 0, it returns NFS4ERR_BADLAYOUT
Signed-off-by Trond Myklebust <[email protected]>
--- fs/nfs/nfs4proc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +14 -1
@@ -7781,10 +7781,19 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)case 0 : goto out;/* +* NFS4ERR_BADLAYOUT means the MDS cannot return a layout of +* length lgp->args.minlength != 0 (see RFC5661 section 18.43.3). +*/ +case -NFS4ERR_BADLAYOUT : + goto out_overflow; +/* * NFS4ERR_LAYOUTTRYLATER is a conflict with another client -* (or clients) writing to the same RAID stripe +* (or clients) writing to the same RAID stripe except when +* the minlength argument is 0 (see RFC5661 section 18.43.3). */ case -NFS4ERR_LAYOUTTRYLATER : +if (lgp->args.minlength ==0 ) + goto out_overflow;/* * NFS4ERR_RECALLCONFLICT is when conflict with self (must recall * existing layout before getting a new one).
@@ -7840,6 +7849,10 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)rpc_restart_call_prepare (task); out:dprintk ("<-- %s\n" , __func__); +return ; +out_overflow: + task->tk_status = -EOVERFLOW ; + goto out; }static size_t max_response_pages (struct nfs_server *server)
Signature · 1 line
2.4.3
PATCH v2 3/3 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 <[email protected]>
--- fs/nfs/pnfs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/nfs/pnfs.c +9 -0
@@ -868,6 +868,7 @@ send_layoutget(struct pnfs_layout_hdr *lo,struct nfs_server *server =NFS_SERVER (ino);struct nfs4_layoutget *lgp;struct pnfs_layout_segment *lseg; +loff_t i_size;dprintk ("--> %s\n" , __func__);
@@ -875,9 +876,17 @@ send_layoutget(struct pnfs_layout_hdr *lo,if (lgp ==NULL )return NULL ; + i_size =i_size_read (ino); + lgp->args.minlength =PAGE_CACHE_SIZE ;if (lgp->args.minlength > range->length) lgp->args.minlength = range->length; +if (range->iomode ==IOMODE_READ ) { +if (range->offset >= i_size) + lgp->args.minlength =0 ; +else if (i_size - range->offset < lgp->args.minlength) + lgp->args.minlength = i_size - range->offset; + } lgp->args.maxcount =PNFS_LAYOUT_MAXSIZE ; lgp->args.range = *range; lgp->args.type = server->pnfs_curr_ld->id;
Signature · 1 line
2.4.3