Skip to content

Commit 8a6291b

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
pNFS: Fix the pnfs block driver's calculation of layoutget size
Instead of relying on the value of the 'bytes_left' field, we should calculate the layout size based on the offset of the request that is being written out. Reported-by: Benjamin Coddington <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Fixes: 954998b ("NFS: Fix error handling for O_DIRECT write scheduling") Reviewed-by: Benjamin Coddington <[email protected]> Tested-by: Benjamin Coddington <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent f6e70c5 commit 8a6291b

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

fs/nfs/blocklayout/blocklayout.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,9 @@ bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
895895
}
896896

897897
if (pgio->pg_dreq == NULL)
898-
wb_size = pnfs_num_cont_bytes(pgio->pg_inode,
899-
req->wb_index);
898+
wb_size = pnfs_num_cont_bytes(pgio->pg_inode, req->wb_index);
900899
else
901-
wb_size = nfs_dreq_bytes_left(pgio->pg_dreq);
900+
wb_size = nfs_dreq_bytes_left(pgio->pg_dreq, req_offset(req));
902901

903902
pnfs_generic_pg_init_write(pgio, req, wb_size);
904903

fs/nfs/direct.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@ static void nfs_direct_req_release(struct nfs_direct_req *dreq)
205205
kref_put(&dreq->kref, nfs_direct_req_free);
206206
}
207207

208-
ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq)
208+
ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset)
209209
{
210-
return dreq->bytes_left;
210+
loff_t start = offset - dreq->io_start;
211+
return dreq->max_count - start;
211212
}
212213
EXPORT_SYMBOL_GPL(nfs_dreq_bytes_left);
213214

fs/nfs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ extern int nfs_sillyrename(struct inode *dir, struct dentry *dentry);
655655
/* direct.c */
656656
void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
657657
struct nfs_direct_req *dreq);
658-
extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);
658+
extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq, loff_t offset);
659659

660660
/* nfs4proc.c */
661661
extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,

fs/nfs/pnfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,8 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r
27332733
if (pgio->pg_dreq == NULL)
27342734
rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
27352735
else
2736-
rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
2736+
rd_size = nfs_dreq_bytes_left(pgio->pg_dreq,
2737+
req_offset(req));
27372738

27382739
pgio->pg_lseg =
27392740
pnfs_update_layout(pgio->pg_inode, nfs_req_openctx(req),

0 commit comments

Comments
 (0)