From: "J. Bruce Fields" <bfields@fieldses.org>
To: Benny Halevy <bhalevy@panasas.com>
Cc: linux-nfs@vger.kernel.org, pnfs@linux-nfs.org,
Alexandros Batsakis <batsakis@netapp.com>,
Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
Subject: Re: [PATCH RFC 01/10] nfsd41: sunrpc: svc_tcp_recv_record()
Date: Mon, 24 Aug 2009 18:52:50 -0400 [thread overview]
Message-ID: <20090824225249.GD8532@fieldses.org> (raw)
In-Reply-To: <1250728459-28477-1-git-send-email-bhalevy@panasas.com>
On Thu, Aug 20, 2009 at 03:34:19AM +0300, Benny Halevy wrote:
> From: Alexandros Batsakis <batsakis@netapp.com>
>
> Factor functionality out of svc_tcp_recvfrom() to simplify routine
Thanks, applied.
--b.
>
> Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
> Signed-off-by: Ricardo Labiaga <Ricardo.Labiaga@netapp.com>
> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> ---
> net/sunrpc/svcsock.c | 79 ++++++++++++++++++++++++++++++++-----------------
> 1 files changed, 51 insertions(+), 28 deletions(-)
>
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 23128ee..5a5bc8b 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -826,21 +826,15 @@ failed:
> }
>
> /*
> - * Receive data from a TCP socket.
> + * Receive data.
> + * If we haven't gotten the record length yet, get the next four bytes.
> + * Otherwise try to gobble up as much as possible up to the complete
> + * record length.
> */
> -static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> +static int svc_tcp_recv_record(struct svc_sock *svsk, struct svc_rqst *rqstp)
> {
> - struct svc_sock *svsk =
> - container_of(rqstp->rq_xprt, struct svc_sock, sk_xprt);
> struct svc_serv *serv = svsk->sk_xprt.xpt_server;
> - int len;
> - struct kvec *vec;
> - int pnum, vlen;
> -
> - dprintk("svc: tcp_recv %p data %d conn %d close %d\n",
> - svsk, test_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags),
> - test_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags),
> - test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags));
> + int len;
>
> if (test_and_clear_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags))
> /* sndbuf needs to have room for one request
> @@ -861,10 +855,6 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
>
> clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
>
> - /* Receive data. If we haven't got the record length yet, get
> - * the next four bytes. Otherwise try to gobble up as much as
> - * possible up to the complete record length.
> - */
> if (svsk->sk_tcplen < sizeof(rpc_fraghdr)) {
> int want = sizeof(rpc_fraghdr) - svsk->sk_tcplen;
> struct kvec iov;
> @@ -879,7 +869,7 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> dprintk("svc: short recvfrom while reading record "
> "length (%d of %d)\n", len, want);
> svc_xprt_received(&svsk->sk_xprt);
> - return -EAGAIN; /* record header not complete */
> + goto err_again; /* record header not complete */
> }
>
> svsk->sk_reclen = ntohl(svsk->sk_reclen);
> @@ -894,6 +884,7 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> "per record not supported\n");
> goto err_delete;
> }
> +
> svsk->sk_reclen &= RPC_FRAGMENT_SIZE_MASK;
> dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen);
> if (svsk->sk_reclen > serv->sv_max_mesg) {
> @@ -914,11 +905,45 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> dprintk("svc: incomplete TCP record (%d of %d)\n",
> len, svsk->sk_reclen);
> svc_xprt_received(&svsk->sk_xprt);
> - return -EAGAIN; /* record not complete */
> + goto err_again; /* record not complete */
> }
> len = svsk->sk_reclen;
> set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
>
> + return len;
> + error:
> + if (len == -EAGAIN) {
> + dprintk("RPC: TCP recv_record got EAGAIN\n");
> + svc_xprt_received(&svsk->sk_xprt);
> + }
> + return len;
> + err_delete:
> + set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
> + err_again:
> + return -EAGAIN;
> +}
> +
> +/*
> + * Receive data from a TCP socket.
> + */
> +static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> +{
> + struct svc_sock *svsk =
> + container_of(rqstp->rq_xprt, struct svc_sock, sk_xprt);
> + struct svc_serv *serv = svsk->sk_xprt.xpt_server;
> + int len;
> + struct kvec *vec;
> + int pnum, vlen;
> +
> + dprintk("svc: tcp_recv %p data %d conn %d close %d\n",
> + svsk, test_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags),
> + test_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags),
> + test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags));
> +
> + len = svc_tcp_recv_record(svsk, rqstp);
> + if (len < 0)
> + goto error;
> +
> vec = rqstp->rq_vec;
> vec[0] = rqstp->rq_arg.head[0];
> vlen = PAGE_SIZE;
> @@ -934,7 +959,7 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
> /* Now receive data */
> len = svc_recvfrom(rqstp, vec, pnum, len);
> if (len < 0)
> - goto error;
> + goto err_again;
>
> dprintk("svc: TCP complete record (%d bytes)\n", len);
> rqstp->rq_arg.len = len;
> @@ -960,21 +985,19 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
>
> return len;
>
> - err_delete:
> - set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
> - return -EAGAIN;
> -
> - error:
> +err_again:
> if (len == -EAGAIN) {
> dprintk("RPC: TCP recvfrom got EAGAIN\n");
> svc_xprt_received(&svsk->sk_xprt);
> - } else {
> + return len;
> + }
> +error:
> + if (len != -EAGAIN) {
> printk(KERN_NOTICE "%s: recvfrom returned errno %d\n",
> svsk->sk_xprt.xpt_server->sv_name, -len);
> - goto err_delete;
> + set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
> }
> -
> - return len;
> + return -EAGAIN;
> }
>
> /*
> --
> 1.6.4
>
next prev parent reply other threads:[~2009-08-24 22:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 0:32 [PATCH RFC 0/10] nfsd41 backchannel patches for 2.6.32 Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 01/10] nfsd41: sunrpc: svc_tcp_recv_record() Benny Halevy
2009-08-24 22:52 ` J. Bruce Fields [this message]
2009-08-20 0:34 ` [PATCH RFC 02/10] nfsd41: sunrpc: Added rpc server-side backchannel handling Benny Halevy
2009-08-24 23:34 ` J. Bruce Fields
2009-08-24 23:42 ` Trond Myklebust
[not found] ` <1251157347.6325.364.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-08-24 23:50 ` Batsakis, Alexandros
2009-08-24 23:51 ` J. Bruce Fields
2009-08-25 0:05 ` [PATCH RFC 02/10] nfsd41: sunrpc: Added rpc server-sidebackchannel handling Labiaga, Ricardo
2009-08-25 8:40 ` [PATCH RFC 02/10] nfsd41: sunrpc: Added rpc server-side backchannel handling Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 03/10] nfsd41: sunrpc: move struct rpc_buffer def into a common header file Benny Halevy
2009-08-24 23:35 ` J. Bruce Fields
2009-08-25 8:43 ` Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 04/10] nfsd41: Backchannel: callback infrastructure Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 05/10] nfsd41: Backchannel: Add sequence arguments to callback RPC arguments Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 06/10] nfsd41: Backchannel: Server backchannel RPC wait queue Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 07/10] nfsd41: Backchannel: Setup sequence information Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 08/10] nfsd41: Backchannel: cb_sequence callback Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 09/10] nfsd41: Backchannel: Implement cb_recall over NFSv4.1 Benny Halevy
2009-08-20 0:34 ` [PATCH RFC 10/10] nfsd41: Refactor create_client() Benny Halevy
2009-08-20 21:37 ` [PATCH RFC 0/10] nfsd41 backchannel patches for 2.6.32 J. Bruce Fields
2009-08-21 8:43 ` Benny Halevy
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=20090824225249.GD8532@fieldses.org \
--to=bfields@fieldses.org \
--cc=Ricardo.Labiaga@netapp.com \
--cc=batsakis@netapp.com \
--cc=bhalevy@panasas.com \
--cc=linux-nfs@vger.kernel.org \
--cc=pnfs@linux-nfs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.