Skip to content

Commit baabf59

Browse files
committed
SUNRPC: Convert svc_udp_sendto() to use the per-socket bio_vec array
Commit da1661b ("SUNRPC: Teach server to use xprt_sock_sendmsg for socket sends") modified svc_udp_sendto() to use xprt_sock_sendmsg() because we originally believed xprt_sock_sendmsg() would be needed for TLS support. That does not actually appear to be the case. In addition, the linkage between the client and server send code has been a bit of a maintenance headache because of the distinct ways that the client and server handle memory allocation. Going forward, eventually the XDR layer will deal with its buffers in the form of bio_vec arrays, so convert this function accordingly. Signed-off-by: Chuck Lever <[email protected]>
1 parent e18e157 commit baabf59

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

net/sunrpc/svcsock.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,10 @@ static int svc_udp_sendto(struct svc_rqst *rqstp)
693693
.msg_name = &rqstp->rq_addr,
694694
.msg_namelen = rqstp->rq_addrlen,
695695
.msg_control = cmh,
696+
.msg_flags = MSG_SPLICE_PAGES,
696697
.msg_controllen = sizeof(buffer),
697698
};
698-
unsigned int sent;
699+
unsigned int count;
699700
int err;
700701

701702
svc_udp_release_ctxt(xprt, rqstp->rq_xprt_ctxt);
@@ -708,22 +709,23 @@ static int svc_udp_sendto(struct svc_rqst *rqstp)
708709
if (svc_xprt_is_dead(xprt))
709710
goto out_notconn;
710711

711-
err = xdr_alloc_bvec(xdr, GFP_KERNEL);
712-
if (err < 0)
713-
goto out_unlock;
712+
count = xdr_buf_to_bvec(rqstp->rq_bvec,
713+
ARRAY_SIZE(rqstp->rq_bvec), xdr);
714714

715-
err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent);
715+
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, rqstp->rq_bvec,
716+
count, 0);
717+
err = sock_sendmsg(svsk->sk_sock, &msg);
716718
if (err == -ECONNREFUSED) {
717719
/* ICMP error on earlier request. */
718-
err = xprt_sock_sendmsg(svsk->sk_sock, &msg, xdr, 0, 0, &sent);
720+
iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, rqstp->rq_bvec,
721+
count, 0);
722+
err = sock_sendmsg(svsk->sk_sock, &msg);
719723
}
720-
xdr_free_bvec(xdr);
724+
721725
trace_svcsock_udp_send(xprt, err);
722-
out_unlock:
726+
723727
mutex_unlock(&xprt->xpt_mutex);
724-
if (err < 0)
725-
return err;
726-
return sent;
728+
return err;
727729

728730
out_notconn:
729731
mutex_unlock(&xprt->xpt_mutex);

0 commit comments

Comments
 (0)