Skip to content

Commit 54e4606

Browse files
committed
NFSD: Fix reads with a non-zero offset that don't end on a page boundary
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Chuck Lever <chuck.lever@oracle.com> commit ac8db82 This was found when virtual machines with nfs-mounted qcow2 disks failed to boot properly. Reported-by: Anders Blomdell <anders.blomdell@control.lth.se> Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2142132 Fixes: bfbfb61 ("nfsd_splice_actor(): handle compound pages") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> (cherry picked from commit ac8db82) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 9ecabb4 commit 54e4606

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/nfsd/vfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,11 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
847847
struct svc_rqst *rqstp = sd->u.data;
848848
struct page *page = buf->page; // may be a compound one
849849
unsigned offset = buf->offset;
850+
struct page *last_page;
850851

851-
page += offset / PAGE_SIZE;
852-
for (int i = sd->len; i > 0; i -= PAGE_SIZE)
853-
svc_rqst_replace_page(rqstp, page++);
852+
last_page = page + (offset + sd->len - 1) / PAGE_SIZE;
853+
for (page += offset / PAGE_SIZE; page <= last_page; page++)
854+
svc_rqst_replace_page(rqstp, page);
854855
if (rqstp->rq_res.page_len == 0) // first call
855856
rqstp->rq_res.page_base = offset % PAGE_SIZE;
856857
rqstp->rq_res.page_len += sd->len;

0 commit comments

Comments
 (0)