Commit e791f8e9 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Convert xs_send_kvec() to use iov_iter_kvec()

Prepare to the socket transmission code to use iov_iter.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 5f52a9d4
...@@ -742,21 +742,21 @@ xs_stream_start_connect(struct sock_xprt *transport) ...@@ -742,21 +742,21 @@ xs_stream_start_connect(struct sock_xprt *transport)
#define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL) #define XS_SENDMSG_FLAGS (MSG_DONTWAIT | MSG_NOSIGNAL)
static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen, struct kvec *vec, unsigned int base, int more) static int xs_sendmsg(struct socket *sock, struct msghdr *msg, size_t seek)
{ {
struct msghdr msg = { if (seek)
.msg_name = addr, iov_iter_advance(&msg->msg_iter, seek);
.msg_namelen = addrlen, return sock_sendmsg(sock, msg);
.msg_flags = XS_SENDMSG_FLAGS | (more ? MSG_MORE : 0), }
};
struct kvec iov = {
.iov_base = vec->iov_base + base,
.iov_len = vec->iov_len - base,
};
if (iov.iov_len != 0) static int xs_send_kvec(struct socket *sock, struct msghdr *msg, struct kvec *vec, size_t seek)
return kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len); {
return kernel_sendmsg(sock, &msg, NULL, 0, 0); if (!vec) {
iov_iter_kvec(&msg->msg_iter, WRITE, NULL, 0, 0);
return sock_sendmsg(sock, msg);
}
iov_iter_kvec(&msg->msg_iter, WRITE, vec, 1, vec->iov_len);
return xs_sendmsg(sock, msg, seek);
} }
static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy, int *sent_p) static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy, int *sent_p)
...@@ -810,6 +810,11 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i ...@@ -810,6 +810,11 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
*/ */
static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy, int *sent_p) static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy, int *sent_p)
{ {
struct msghdr msg = {
.msg_name = addr,
.msg_namelen = addrlen,
.msg_flags = XS_SENDMSG_FLAGS | MSG_MORE,
};
unsigned int remainder = xdr->len - base; unsigned int remainder = xdr->len - base;
int err = 0; int err = 0;
int sent = 0; int sent = 0;
...@@ -825,7 +830,9 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, ...@@ -825,7 +830,9 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
if (base < xdr->head[0].iov_len || addr != NULL) { if (base < xdr->head[0].iov_len || addr != NULL) {
unsigned int len = xdr->head[0].iov_len - base; unsigned int len = xdr->head[0].iov_len - base;
remainder -= len; remainder -= len;
err = xs_send_kvec(sock, addr, addrlen, &xdr->head[0], base, remainder != 0); if (remainder == 0)
msg.msg_flags &= ~MSG_MORE;
err = xs_send_kvec(sock, &msg, &xdr->head[0], base);
if (remainder == 0 || err != len) if (remainder == 0 || err != len)
goto out; goto out;
*sent_p += err; *sent_p += err;
...@@ -846,7 +853,8 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, ...@@ -846,7 +853,8 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
if (base >= xdr->tail[0].iov_len) if (base >= xdr->tail[0].iov_len)
return 0; return 0;
err = xs_send_kvec(sock, NULL, 0, &xdr->tail[0], base, 0); msg.msg_flags &= ~MSG_MORE;
err = xs_send_kvec(sock, &msg, &xdr->tail[0], base);
out: out:
if (err > 0) { if (err > 0) {
*sent_p += err; *sent_p += err;
......
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