Skip to content

Commit 572efad

Browse files
dhowellskuba-moo
authored andcommitted
rds: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage
When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced. To make this work, the data is assembled in a bio_vec array and attached to a BVEC-type iterator. Signed-off-by: David Howells <[email protected]> cc: Santosh Shilimkar <[email protected]> cc: Jens Axboe <[email protected]> cc: Matthew Wilcox <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fa094cc commit 572efad

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

net/rds/tcp_send.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
7272
{
7373
struct rds_conn_path *cp = rm->m_inc.i_conn_path;
7474
struct rds_tcp_connection *tc = cp->cp_transport_data;
75+
struct msghdr msg = {};
76+
struct bio_vec bvec;
7577
int done = 0;
7678
int ret = 0;
77-
int more;
7879

7980
if (hdr_off == 0) {
8081
/*
@@ -111,15 +112,17 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
111112
goto out;
112113
}
113114

114-
more = rm->data.op_nents > 1 ? (MSG_MORE | MSG_SENDPAGE_NOTLAST) : 0;
115115
while (sg < rm->data.op_nents) {
116-
int flags = MSG_DONTWAIT | MSG_NOSIGNAL | more;
117-
118-
ret = tc->t_sock->ops->sendpage(tc->t_sock,
119-
sg_page(&rm->data.op_sg[sg]),
120-
rm->data.op_sg[sg].offset + off,
121-
rm->data.op_sg[sg].length - off,
122-
flags);
116+
msg.msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT | MSG_NOSIGNAL;
117+
if (sg + 1 < rm->data.op_nents)
118+
msg.msg_flags |= MSG_MORE;
119+
120+
bvec_set_page(&bvec, sg_page(&rm->data.op_sg[sg]),
121+
rm->data.op_sg[sg].length - off,
122+
rm->data.op_sg[sg].offset + off);
123+
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1,
124+
rm->data.op_sg[sg].length - off);
125+
ret = sock_sendmsg(tc->t_sock, &msg);
123126
rdsdebug("tcp sendpage %p:%u:%u ret %d\n", (void *)sg_page(&rm->data.op_sg[sg]),
124127
rm->data.op_sg[sg].offset + off, rm->data.op_sg[sg].length - off,
125128
ret);
@@ -132,8 +135,6 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm,
132135
off = 0;
133136
sg++;
134137
}
135-
if (sg == rm->data.op_nents - 1)
136-
more = 0;
137138
}
138139

139140
out:

0 commit comments

Comments
 (0)