Skip to contentSkip to conversation

sunrpc: set the bv_offset of first bvec in svc_tcp_sendmsg

PATCH In review Jeff Layton 2 participants 3 messages Aug 14, 2023

Subsystems (4)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH v2 1/1 sunrpc: set the bv_offset of first bvec in svc_tcp_sendmsg

svc_tcp_sendmsg used to factor in the xdr->page_base when sending pages, but 5df5dd03a8f7 dropped that part of the handling. Fix it by setting the bv_offset of the first bvec.

Fixes 5df5dd03a8f7 ("sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage")

---
Changes in v2:
- limit the change to just svc_tcp_sendmsg

---
 net/sunrpc/svcsock.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/svcsock.c +3 -0
index e43f26382411..2eb8df44f894 100644
@@ -1244,6 +1244,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr,
 	if (ret != head->iov_len)
 		goto out;
 
+	if (xdr_buf_pagecount(xdr))
+		xdr->bvec[0].bv_offset = offset_in_page(xdr->page_base);
+
 	msg.msg_flags = MSG_SPLICE_PAGES;
 	iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, xdr->bvec,
 		      xdr_buf_pagecount(xdr), xdr->page_len);

---
base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230814-sendpage-b04874eed249

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
#1 lore raw
Quoted 6 lines · Jeff Layton

svc_tcp_sendmsg used to factor in the xdr->page_base when sending pages, but 5df5dd03a8f7 dropped that part of the handling. Fix it by setting the bv_offset of the first bvec.

Fixes 5df5dd03a8f7 ("sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage")

LGTM. However, nfsd-fixes does not have 5df5dd03a8f7 because the previous nfsd-next was merged into v6.5 before David's MSG_SPLICE_PAGES work was merged.

Unless someone has a better suggestion, I'll rebase nfsd-fixes to v6.5-r6 and apply this fix to send to Linus.

Quoted 30 lines

---
Changes in v2:
- limit the change to just svc_tcp_sendmsg

---
 net/sunrpc/svcsock.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/svcsock.c +3 -1
index e43f26382411..2eb8df44f894 100644
@@ -1244,6 +1244,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr,
 	if (ret != head->iov_len)
 		goto out;
 
+	if (xdr_buf_pagecount(xdr))
+		xdr->bvec[0].bv_offset = offset_in_page(xdr->page_base);
+
 	msg.msg_flags = MSG_SPLICE_PAGES;
 	iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, xdr->bvec,
 		      xdr_buf_pagecount(xdr), xdr->page_len);
 
---

base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230814-sendpage-b04874eed249

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Chuck Lever
author maintainer
#2 lore raw
Quoted 8 lines · Chuck Lever
Quoted 6 lines · Jeff Layton

svc_tcp_sendmsg used to factor in the xdr->page_base when sending pages, but 5df5dd03a8f7 dropped that part of the handling. Fix it by setting the bv_offset of the first bvec.

Fixes 5df5dd03a8f7 ("sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage")
Quoted 7 lines

LGTM. However, nfsd-fixes does not have 5df5dd03a8f7 because the previous nfsd-next was merged into v6.5 before David's MSG_SPLICE_PAGES work was merged.

Unless someone has a better suggestion, I'll rebase nfsd-fixes to v6.5-r6 and apply this fix to send to Linus.

ACK. That's probably safer than trying to pull in the big rework at the last minute.

Quoted 32 lines
Quoted 31 lines

---
Changes in v2:
- limit the change to just svc_tcp_sendmsg

---
 net/sunrpc/svcsock.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/svcsock.c +3 -1
index e43f26382411..2eb8df44f894 100644
@@ -1244,6 +1244,9 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr,
 	if (ret != head->iov_len)
 		goto out;
 
+	if (xdr_buf_pagecount(xdr))
+		xdr->bvec[0].bv_offset = offset_in_page(xdr->page_base);
+
 	msg.msg_flags = MSG_SPLICE_PAGES;
 	iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, xdr->bvec,
 		      xdr_buf_pagecount(xdr), xdr->page_len);
 
---

base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
change-id: 20230814-sendpage-b04874eed249

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
Signature · 1 line
Jeff Layton <[email protected]>