From: Chuck Lever <chuck.lever@oracle.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH RFC 3/8] SUNRPC: TCP transport support for automated padding of xdr_buf::pages
Date: Wed, 29 Jan 2020 11:09:40 -0500 [thread overview]
Message-ID: <20200129160939.3024.63670.stgit@bazille.1015granger.net> (raw)
In-Reply-To: <20200129155516.3024.56575.stgit@bazille.1015granger.net>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
net/sunrpc/svcsock.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 2934dd711715..966ea431f845 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -187,14 +187,12 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
size_t base = xdr->page_base;
unsigned int pglen = xdr->page_len;
unsigned int flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
- int slen;
+ int slen = xdr_buf_msglen(xdr);
int len = 0;
- slen = xdr->len;
-
/* send head */
if (slen == xdr->head[0].iov_len)
- flags = 0;
+ flags = MSG_EOR;
len = kernel_sendpage(sock, headpage, headoffset,
xdr->head[0].iov_len, flags);
if (len != xdr->head[0].iov_len)
@@ -207,7 +205,7 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
size = PAGE_SIZE - base < pglen ? PAGE_SIZE - base : pglen;
while (pglen > 0) {
if (slen == size)
- flags = 0;
+ flags = MSG_EOR;
result = kernel_sendpage(sock, *ppage, base, size, flags);
if (result > 0)
len += result;
@@ -219,11 +217,21 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
base = 0;
ppage++;
}
+ if (xdr->page_pad) {
+ if (!xdr->tail[0].iov_len)
+ flags = MSG_EOR;
+ result = kernel_sendpage(sock, ZERO_PAGE(0), 0,
+ xdr->page_pad, flags);
+ if (result > 0)
+ len += result;
+ if (result != xdr->page_pad)
+ goto out;
+ }
/* send tail */
if (xdr->tail[0].iov_len) {
result = kernel_sendpage(sock, tailpage, tailoffset,
- xdr->tail[0].iov_len, 0);
+ xdr->tail[0].iov_len, MSG_EOR);
if (result > 0)
len += result;
}
@@ -272,9 +280,9 @@ static int svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
rqstp->rq_respages[0], tailoff);
out:
- dprintk("svc: socket %p sendto([%p %zu... ], %d) = %d (addr %s)\n",
+ dprintk("svc: socket %p sendto([%p %zu... ], %zu) = %d (addr %s)\n",
svsk, xdr->head[0].iov_base, xdr->head[0].iov_len,
- xdr->len, len, svc_print_addr(rqstp, buf, sizeof(buf)));
+ xdr_buf_msglen(xdr), len, svc_print_addr(rqstp, buf, sizeof(buf)));
return len;
}
@@ -1134,24 +1142,25 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
static int svc_tcp_sendto(struct svc_rqst *rqstp)
{
struct xdr_buf *xbufp = &rqstp->rq_res;
+ u32 reclen = xdr_buf_msglen(xbufp);
+ __be32 marker;
int sent;
- __be32 reclen;
/* Set up the first element of the reply kvec.
* Any other kvecs that may be in use have been taken
* care of by the server implementation itself.
*/
- reclen = htonl(0x80000000|((xbufp->len ) - 4));
- memcpy(xbufp->head[0].iov_base, &reclen, 4);
+ marker = cpu_to_be32(0x80000000 | (reclen - sizeof(marker)));
+ memcpy(xbufp->head[0].iov_base, &marker, sizeof(marker));
sent = svc_sendto(rqstp, &rqstp->rq_res);
- if (sent != xbufp->len) {
+ if (sent != reclen) {
printk(KERN_NOTICE
- "rpc-srv/tcp: %s: %s %d when sending %d bytes "
+ "rpc-srv/tcp: %s: %s %d when sending %u bytes "
"- shutting down socket\n",
rqstp->rq_xprt->xpt_server->sv_name,
- (sent<0)?"got error":"sent only",
- sent, xbufp->len);
+ (sent<0)?"got error":"sent",
+ sent, reclen);
set_bit(XPT_CLOSE, &rqstp->rq_xprt->xpt_flags);
svc_xprt_enqueue(rqstp->rq_xprt);
sent = -EAGAIN;
next prev parent reply other threads:[~2020-01-29 16:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-29 16:09 [PATCH RFC 0/8] For discussion of bug 198053 Chuck Lever
2020-01-29 16:09 ` [PATCH RFC 1/8] nfsd: Fix NFSv4 READ on RDMA when using readv Chuck Lever
2020-01-29 16:09 ` [PATCH RFC 2/8] SUNRPC: Add XDR infrastructure for automatically padding xdr_buf::pages Chuck Lever
2020-01-29 16:09 ` Chuck Lever [this message]
2020-01-29 16:09 ` [PATCH RFC 4/8] svcrdma: RDMA transport support for automated padding of xdr_buf::pages Chuck Lever
2020-01-29 16:09 ` [PATCH RFC 5/8] NFSD: NFSv2 " Chuck Lever
2020-01-29 16:09 ` [PATCH RFC 6/8] NFSD: NFSv3 " Chuck Lever
2020-01-29 16:10 ` [PATCH RFC 7/8] sunrpc: Add new contractual constraint on xdr_buf API Chuck Lever
2020-01-29 16:10 ` [PATCH RFC 8/8] SUNRPC: GSS support for automated padding of xdr_buf::pages Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200129160939.3024.63670.stgit@bazille.1015granger.net \
--to=chuck.lever@oracle.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).