From: Tom Tucker <tom@opengridcomputing.com>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 8/17] svcrdma: Return error from rdma_read_xdr so caller knows to free context
Date: Mon, 05 May 2008 21:05:37 -0500 [thread overview]
Message-ID: <C4452721.4958A%tom@opengridcomputing.com> (raw)
In-Reply-To: <20080505225207.GJ12814@fieldses.org>
On 5/5/08 5:52 PM, "J. Bruce Fields" <bfields@fieldses.org> wrote:
> On Fri, May 02, 2008 at 11:28:40AM -0500, Tom Tucker wrote:
>> The rdma_read_xdr function did discriminate between no read-list and
> ^^^
> did not?
>
Ack.
>> an error posting the read-list. This results a leak of a page in the
>> context when an asyncrhonous error occurs on the transport.
>>
>> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
>>
>> ---
>> net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 17 +++++++++++++----
>> 1 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> index f3a108a..0ac375a 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
>> @@ -260,11 +260,16 @@ static int rdma_read_max_sge(struct svcxprt_rdma *xprt,
>> int sge_count)
>> * On our side, we need to read into a pagelist. The first page immediately
>> * follows the RPC header.
>> *
>> - * This function returns 1 to indicate success. The data is not yet in
>> + * This function returns:
>> + * 0 - No error and no read-list found.
>> + *
>> + * 1 - Successful read-list processing. The data is not yet in
>> * the pagelist and therefore the RPC request must be deferred. The
>> * I/O completion will enqueue the transport again and
>> * svc_rdma_recvfrom will complete the request.
>> *
>> + * <0 - Error processing/posting read-list.
>> + *
>> * NOTE: The ctxt must not be touched after the last WR has been posted
>> * because the I/O completion processing may occur on another
>> * processor and free / modify the context. Ne touche pas!
>> @@ -398,7 +403,7 @@ next_sge:
>> svc_rdma_put_context(head, 1);
>> head = ctxt;
>> }
>> - return 0;
>> + return err;
>> }
>>
>> return 1;
>> @@ -536,8 +541,12 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
>> * it. Not that in this case, we don't return the RQ credit
>> * until after the read completes.
>> */
>> - if (rdma_read_xdr(rdma_xprt, rmsgp, rqstp, ctxt)) {
>> - svc_xprt_received(xprt);
>> + ret = rdma_read_xdr(rdma_xprt, rmsgp, rqstp, ctxt);
>> + if (ret) {
>> + if (ret > 0)
>> + svc_xprt_received(xprt);
>> + else
>> + svc_rdma_put_context(ctxt, 1);
>> return 0;
>> }
>>
>
> Possibly slightly more straightforward?:
>
> /* Read read-list data. */
> ret = rdma_read_xdr(rdma_xprt, rmsgp, rqstp, ctxt);
> if (ret < 0) {
> svc_rdma_put_context(ctxt, 1);
> return 0;
> }
> if (ret > 0) {
> /*
> * We need to wait; defer the request. Note that in
> * this case, we don't return the RQ credit until after
> * the read completes.
> */
> svc_xprt_received(xprt);
> return 0;
> }
> ...
>
Yep. I rewrote that code three different ways and never liked it. I think
you've got it right first try... :-)
> --b.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-05-06 2:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1209745721600-git-send-email-tom@opengridcomputing.com>
2008-05-02 22:37 ` [PATCH 0/17] svcrdma: RDMA transport driver close path cleanup J. Bruce Fields
2008-05-02 23:05 ` Tom Tucker
[not found] ` <12097457211326-git-send-email-tom@opengridcomputing.com>
[not found] ` <1209745721248-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457213375-git-send-email-tom@opengridcomputing.com>
2008-05-05 19:31 ` [PATCH 1/17] svcrdma: Simplify receive buffer posting J. Bruce Fields
[not found] ` <12097457212336-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457212951-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457211122-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223433-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223971-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223635-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223351-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:06 ` [PATCH 2/17] svcrdma: Fix race with dto_tasklet in svc_rdma_send J. Bruce Fields
2008-05-06 2:26 ` Tom Tucker
2008-05-06 21:18 ` J. Bruce Fields
2008-05-07 0:45 ` Tom Tucker
[not found] ` <12097457221640-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:08 ` [PATCH 3/17] svcrdma: Fix return value " J. Bruce Fields
2008-05-06 2:03 ` Tom Tucker
2008-05-06 21:08 ` J. Bruce Fields
[not found] ` <120974572253-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223519-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457223927-git-send-email-tom@opengridcomputing.com>
[not found] ` <12097457232986-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:41 ` [PATCH 7/17] svcrdma: Fix error handling during listening endpoint creation J. Bruce Fields
2008-05-06 14:48 ` Tom Tucker
2008-05-06 21:22 ` J. Bruce Fields
2008-05-07 0:48 ` Tom Tucker
2008-05-07 1:30 ` J. Bruce Fields
[not found] ` <12097457231736-git-send-email-tom@opengridcomputing.com>
2008-05-05 22:52 ` [PATCH 8/17] svcrdma: Return error from rdma_read_xdr so caller knows to free context J. Bruce Fields
2008-05-06 2:05 ` Tom Tucker [this message]
2008-05-06 21:32 ` [PATCH 11/17] svcrdma: Use standard Linux lists for context cache J. Bruce Fields
2008-05-07 0:49 ` Tom Tucker
2008-05-06 21:46 ` [PATCH 0/17] svcrdma: RDMA transport driver close path cleanup J. Bruce Fields
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=C4452721.4958A%tom@opengridcomputing.com \
--to=tom@opengridcomputing.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 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.