Commit 0472e476 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Convert socket page send code to use iov_iter()

Simplify the page send code using iov_iter and bvecs.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent e791f8e9
...@@ -1723,6 +1723,7 @@ void xprt_release(struct rpc_task *task) ...@@ -1723,6 +1723,7 @@ void xprt_release(struct rpc_task *task)
xprt->ops->buf_free(task); xprt->ops->buf_free(task);
xprt_inject_disconnect(xprt); xprt_inject_disconnect(xprt);
xdr_free_bvec(&req->rq_rcv_buf); xdr_free_bvec(&req->rq_rcv_buf);
xdr_free_bvec(&req->rq_snd_buf);
if (req->rq_cred != NULL) if (req->rq_cred != NULL)
put_rpccred(req->rq_cred); put_rpccred(req->rq_cred);
task->tk_rqstp = NULL; task->tk_rqstp = NULL;
......
...@@ -759,42 +759,18 @@ static int xs_send_kvec(struct socket *sock, struct msghdr *msg, struct kvec *ve ...@@ -759,42 +759,18 @@ static int xs_send_kvec(struct socket *sock, struct msghdr *msg, struct kvec *ve
return xs_sendmsg(sock, msg, seek); 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 msghdr *msg, struct xdr_buf *xdr, size_t base)
{ {
ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
int offset, size_t size, int flags);
struct page **ppage;
unsigned int remainder;
int err; int err;
remainder = xdr->page_len - base; err = xdr_alloc_bvec(xdr, GFP_KERNEL);
base += xdr->page_base; if (err < 0)
ppage = xdr->pages + (base >> PAGE_SHIFT); return err;
base &= ~PAGE_MASK;
do_sendpage = sock->ops->sendpage;
if (!zerocopy)
do_sendpage = sock_no_sendpage;
for(;;) {
unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
int flags = XS_SENDMSG_FLAGS;
remainder -= len; iov_iter_bvec(&msg->msg_iter, WRITE, xdr->bvec,
if (more) xdr_buf_pagecount(xdr),
flags |= MSG_MORE; xdr->page_len + xdr->page_base);
if (remainder != 0) return xs_sendmsg(sock, msg, base + xdr->page_base);
flags |= MSG_SENDPAGE_NOTLAST | MSG_MORE;
err = do_sendpage(sock, *ppage, base, len, flags);
if (remainder == 0 || err != len)
break;
*sent_p += err;
ppage++;
base = 0;
}
if (err > 0) {
*sent_p += err;
err = 0;
}
return err;
} }
/** /**
...@@ -817,7 +793,6 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, ...@@ -817,7 +793,6 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
}; };
unsigned int remainder = xdr->len - base; unsigned int remainder = xdr->len - base;
int err = 0; int err = 0;
int sent = 0;
if (unlikely(!sock)) if (unlikely(!sock))
return -ENOTSOCK; return -ENOTSOCK;
...@@ -843,10 +818,12 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, ...@@ -843,10 +818,12 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
if (base < xdr->page_len) { if (base < xdr->page_len) {
unsigned int len = xdr->page_len - base; unsigned int len = xdr->page_len - base;
remainder -= len; remainder -= len;
err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy, &sent); if (remainder == 0)
*sent_p += sent; msg.msg_flags &= ~MSG_MORE;
if (remainder == 0 || sent != len) err = xs_send_pagedata(sock, &msg, xdr, base);
if (remainder == 0 || err != len)
goto out; goto out;
*sent_p += err;
base = 0; base = 0;
} else } else
base -= xdr->page_len; base -= xdr->page_len;
......
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