Commit bad4c6eb authored by Chuck Lever's avatar Chuck Lever

SUNRPC: Fix NFS READs that start at non-page-aligned offsets

Anj Duvnjak reports that the Kodi.tv NFS client is not able to read
video files from a v5.10.11 Linux NFS server.

The new sendpage-based TCP sendto logic was not attentive to non-
zero page_base values. nfsd_splice_read() sets that field when a
READ payload starts in the middle of a page.

The Linux NFS client rarely emits an NFS READ that is not page-
aligned. All of my testing so far has been with Linux clients, so I
missed this one.
Reported-by: default avatarA. Duvnjak <avian@extremenerds.net>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=211471
Fixes: 4a85a6a3 ("SUNRPC: Handle TCP socket sends with kernel_sendpage() again")
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Tested-by: default avatarA. Duvnjak <avian@extremenerds.net>
parent 1048ba83
...@@ -1113,14 +1113,15 @@ static int svc_tcp_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -1113,14 +1113,15 @@ static int svc_tcp_sendmsg(struct socket *sock, struct msghdr *msg,
unsigned int offset, len, remaining; unsigned int offset, len, remaining;
struct bio_vec *bvec; struct bio_vec *bvec;
bvec = xdr->bvec; bvec = xdr->bvec + (xdr->page_base >> PAGE_SHIFT);
offset = xdr->page_base; offset = offset_in_page(xdr->page_base);
remaining = xdr->page_len; remaining = xdr->page_len;
flags = MSG_MORE | MSG_SENDPAGE_NOTLAST; flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
while (remaining > 0) { while (remaining > 0) {
if (remaining <= PAGE_SIZE && tail->iov_len == 0) if (remaining <= PAGE_SIZE && tail->iov_len == 0)
flags = 0; flags = 0;
len = min(remaining, bvec->bv_len);
len = min(remaining, bvec->bv_len - offset);
ret = kernel_sendpage(sock, bvec->bv_page, ret = kernel_sendpage(sock, bvec->bv_page,
bvec->bv_offset + offset, bvec->bv_offset + offset,
len, flags); len, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment