[PATCH 3/3] Return errors in bc_send
Andy Adamson
andros at umich.edu
Fri May 25 12:38:41 EDT 2007
Release the request and task upon allocation errors.
Don't just return zero, return the send_request return value.
---
net/sunrpc/bc_svc.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/sunrpc/bc_svc.c b/net/sunrpc/bc_svc.c
index c713f05..a9be1b4 100644
--- a/net/sunrpc/bc_svc.c
+++ b/net/sunrpc/bc_svc.c
@@ -131,7 +131,7 @@ void bc_release_xprt(struct rpc_task *task)
int bc_send(struct rpc_rqst *req)
{
struct rpc_task *bc_task;
- int err;
+ int err = -ENOMEM;
struct xdr_buf *xbufp = &req->rq_snd_buf;
struct rpc_xprt *xprt = req->rq_xprt;
@@ -139,13 +139,15 @@ int bc_send(struct rpc_rqst *req)
* Create an rpc_task to send the data
*/
bc_task = bc_alloc_task(req);
+ if (!bc_task)
+ goto out_free_req;
/*
* Reserve the xprt and then try to send the request across
*/
err = bc_reserve_xprt(bc_task);
if (err)
- goto out;
+ goto out_free_task;
/*
* Set up the xdr_buf length
@@ -156,12 +158,14 @@ int bc_send(struct rpc_rqst *req)
bc_release_xprt(bc_task);
+out_free_req:
xprt_free_bc_request(req);
- return 0;
-out:
+ return err;
+
+out_free_task:
bc_task->tk_rqstp = NULL;
bc_release_task(bc_task);
- return err;
+ goto out_free_req;
}
/*
--
On 5/24/07, Iyer, Rahul <Rahul.Iyer at netapp.com> wrote:
>
>
> My bad. I see it now.
> Regards
> Rahul
>
> > -----Original Message-----
> > From: Benny Halevy [mailto:bhalevy at panasas.com]
> > Sent: Thursday, May 24, 2007 9:07 AM
> > To: undisclosed-recipients
> > Subject: [pnfs] [PATCH 2/2] bc_send: handle error from bc_alloc_task
> >
> > >From 3ad9cc52abc6146a4e0714b797feb3473d829e56 Mon Sep 17
> > 00:00:00 2001
> > From: Benny Halevy <bhalevy at panasas.com>
> > Date: Thu, 24 May 2007 19:07:13 +0300
> > Subject: [PATCH 2/2] bc_send: handle error from bc_alloc_task
> >
> > Signed-off-by: Benny Halevy <bhalevy at panasas.com>
> > ---
> > net/sunrpc/bc_svc.c | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/net/sunrpc/bc_svc.c b/net/sunrpc/bc_svc.c
> > index fbea284..a8519d5 100644
> > --- a/net/sunrpc/bc_svc.c
> > +++ b/net/sunrpc/bc_svc.c
> > @@ -139,6 +139,10 @@ int bc_send(struct rpc_rqst *req)
> > * Create an rpc_task to send the data
> > */
> > bc_task = bc_alloc_task(req);
> > + if (!bc_task) {
> > + err = -ENOMEM;
> > + goto out_no_free;
> > + }
> >
> > /*
> > * Reserve the xprt and then try to send the request across
> > @@ -158,6 +162,7 @@ int bc_send(struct rpc_rqst *req)
> > out:
> > bc_task->tk_rqstp = NULL;
> > bc_release_task(bc_task);
> > +out_no_free:
> > xprt_free_bc_request(req);
> > return err;
> > }
> > --
> > 1.5.1
> >
> > _______________________________________________
> > pNFS mailing list
> > pNFS at linux-nfs.org
> > http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
> >
> _______________________________________________
> pNFS mailing list
> pNFS at linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
>
>
------=_Part_128865_29770799.1180111924724
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
This patch did not apply to the 4.1-sessions branch. There is no xprt_free_bc_request(req); after the out: label.<br>
<br>
here is the function in the 4.1-sessions branch.<br>
<br>
/*<br>
* Send the callback reply<br>
*/<br>
int bc_send(struct rpc_rqst *req)<br>
{<br>
struct rpc_task *bc_task;<br>
int err;<br>
struct xdr_buf *xbufp = &req->rq_snd_buf;<br>
struct rpc_xprt *xprt = req->rq_xprt;<br>
<br>
/*<br>
* Create an rpc_task to send the data<br>
*/<br>
bc_task = bc_alloc_task(req);<br>
<br>
/*<br>
* Reserve the xprt and then try to send the request across<br>
*/<br>
err = bc_reserve_xprt(bc_task);<br>
if (err)<br>
goto out;<br>
<br>
/*<br>
* Set up the xdr_buf length<br>
*/<br>
xbufp->len =
xbufp->head[0].iov_len + xbufp->page_len +
xbufp->tail[0].iov_len;<br>
<br>
err = xprt->ops->send_request(bc_task);<br>
<br>
bc_release_xprt(bc_task);<br>
<br>
xprt_free_bc_request(req);<br>
return 0;<br>
out:<br>
bc_task->tk_rqstp = NULL;<br>
bc_release_task(bc_task);<br>
return err;<br>
}<br>
<br>
Why do you return zero and not the err from xprt->ops->send_request?<br>
<br>
Here is what I suggest:<br>
<br>
<br>
More information about the pNFS
mailing list