Commit ac8db824 authored by Chuck Lever's avatar Chuck Lever
Browse files

NFSD: Fix reads with a non-zero offset that don't end on a page boundary



This was found when virtual machines with nfs-mounted qcow2 disks
failed to boot properly.

Reported-by: default avatarAnders Blomdell <anders.blomdell@control.lth.se>
Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2142132


Fixes: bfbfb618 ("nfsd_splice_actor(): handle compound pages")
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 5a01c805
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -871,10 +871,11 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
	struct svc_rqst *rqstp = sd->u.data;
	struct page *page = buf->page;	// may be a compound one
	unsigned offset = buf->offset;
	struct page *last_page;

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