Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
@ 2012-05-18 20:16 Jeff Layton
  2012-05-18 20:33 ` Jeff Layton
  2012-05-19 16:23 ` Myklebust, Trond
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff Layton @ 2012-05-18 20:16 UTC (permalink / raw)
  To: trond.myklebust; +Cc: andros, linux-nfs

xprt_alloc_slot will call rpc_delay() to make the task wait a bit before
retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot.

The problem there is that rpc_delay does this:

    rpc_sleep_on(&delay_queue, task, __rpc_atrun);

...and __rpc_atrun will reset the task->tk_status back to 0 when the
task wakes back up. This makes call_reserveresult abort the task with
-EIO.

The RH QA group discovered this problem when testing with low-memory
clients and this patch fixed it:

    https://bugzilla.redhat.com/show_bug.cgi?id=822189

Fix this by adding a new rpc_delay_action() variant that makes allows
us to pass in a rpc_action to reset the status back to -EAGAIN instead.

Cc: Andy Adamson <andros@netapp.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 include/linux/sunrpc/sched.h |    1 +
 net/sunrpc/sched.c           |    9 +++++++--
 net/sunrpc/xprt.c            |    7 ++++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index dc0c3cc..6cafdbb 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -241,6 +241,7 @@ struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *,
 					void *);
 void		rpc_wake_up_status(struct rpc_wait_queue *, int);
 int		rpc_queue_empty(struct rpc_wait_queue *);
+void		rpc_delay_action(struct rpc_task *, unsigned long, rpc_action);
 void		rpc_delay(struct rpc_task *, unsigned long);
 void *		rpc_malloc(struct rpc_task *, size_t);
 void		rpc_free(void *);
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 994cfea..f2ff98d 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -613,13 +613,18 @@ static void __rpc_atrun(struct rpc_task *task)
 	task->tk_status = 0;
 }
 
+void rpc_delay_action(struct rpc_task *task, unsigned long delay, rpc_action action)
+{
+	task->tk_timeout = delay;
+	rpc_sleep_on(&delay_queue, task, action);
+}
+
 /*
  * Run a task at a later time
  */
 void rpc_delay(struct rpc_task *task, unsigned long delay)
 {
-	task->tk_timeout = delay;
-	rpc_sleep_on(&delay_queue, task, __rpc_atrun);
+	rpc_delay_action(task, delay, __rpc_atrun);
 }
 EXPORT_SYMBOL_GPL(rpc_delay);
 
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index b239e75..a5dc816 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -969,6 +969,11 @@ static bool xprt_dynamic_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
 	return false;
 }
 
+static void xprt_alloc_delay_reset_status(struct rpc_task *task)
+{
+	task->tk_status = -EAGAIN;
+}
+
 static void xprt_alloc_slot(struct rpc_task *task)
 {
 	struct rpc_xprt	*xprt = task->tk_xprt;
@@ -984,7 +989,7 @@ static void xprt_alloc_slot(struct rpc_task *task)
 		goto out_init_req;
 	switch (PTR_ERR(req)) {
 	case -ENOMEM:
-		rpc_delay(task, HZ >> 2);
+		rpc_delay_action(task, HZ >> 2, xprt_alloc_delay_reset_status);
 		dprintk("RPC:       dynamic allocation of request slot "
 				"failed! Retrying\n");
 		break;
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
  2012-05-18 20:16 [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot Jeff Layton
@ 2012-05-18 20:33 ` Jeff Layton
  2012-05-19 19:33   ` Myklebust, Trond
  2012-05-19 16:23 ` Myklebust, Trond
  1 sibling, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2012-05-18 20:33 UTC (permalink / raw)
  To: trond.myklebust; +Cc: andros, linux-nfs

On Fri, 18 May 2012 16:16:28 -0400
Jeff Layton <jlayton@redhat.com> wrote:

> xprt_alloc_slot will call rpc_delay() to make the task wait a bit before
> retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot.
> 
> The problem there is that rpc_delay does this:
> 
>     rpc_sleep_on(&delay_queue, task, __rpc_atrun);
> 
> ...and __rpc_atrun will reset the task->tk_status back to 0 when the
> task wakes back up. This makes call_reserveresult abort the task with
> -EIO.
> 
> The RH QA group discovered this problem when testing with low-memory
> clients and this patch fixed it:
> 
>     https://bugzilla.redhat.com/show_bug.cgi?id=822189
> 
> Fix this by adding a new rpc_delay_action() variant that makes allows
> us to pass in a rpc_action to reset the status back to -EAGAIN instead.
> 
> Cc: Andy Adamson <andros@netapp.com>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  include/linux/sunrpc/sched.h |    1 +
>  net/sunrpc/sched.c           |    9 +++++++--
>  net/sunrpc/xprt.c            |    7 ++++++-
>  3 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
> index dc0c3cc..6cafdbb 100644
> --- a/include/linux/sunrpc/sched.h
> +++ b/include/linux/sunrpc/sched.h
> @@ -241,6 +241,7 @@ struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *,
>  					void *);
>  void		rpc_wake_up_status(struct rpc_wait_queue *, int);
>  int		rpc_queue_empty(struct rpc_wait_queue *);
> +void		rpc_delay_action(struct rpc_task *, unsigned long, rpc_action);
>  void		rpc_delay(struct rpc_task *, unsigned long);
>  void *		rpc_malloc(struct rpc_task *, size_t);
>  void		rpc_free(void *);
> diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
> index 994cfea..f2ff98d 100644
> --- a/net/sunrpc/sched.c
> +++ b/net/sunrpc/sched.c
> @@ -613,13 +613,18 @@ static void __rpc_atrun(struct rpc_task *task)
>  	task->tk_status = 0;
>  }
>  
> +void rpc_delay_action(struct rpc_task *task, unsigned long delay, rpc_action action)
> +{
> +	task->tk_timeout = delay;
> +	rpc_sleep_on(&delay_queue, task, action);
> +}
> +
>  /*
>   * Run a task at a later time
>   */
>  void rpc_delay(struct rpc_task *task, unsigned long delay)
>  {
> -	task->tk_timeout = delay;
> -	rpc_sleep_on(&delay_queue, task, __rpc_atrun);
> +	rpc_delay_action(task, delay, __rpc_atrun);
>  }
>  EXPORT_SYMBOL_GPL(rpc_delay);
>  
> diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> index b239e75..a5dc816 100644
> --- a/net/sunrpc/xprt.c
> +++ b/net/sunrpc/xprt.c
> @@ -969,6 +969,11 @@ static bool xprt_dynamic_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
>  	return false;
>  }
>  
> +static void xprt_alloc_delay_reset_status(struct rpc_task *task)
> +{
> +	task->tk_status = -EAGAIN;
> +}
> +
>  static void xprt_alloc_slot(struct rpc_task *task)
>  {
>  	struct rpc_xprt	*xprt = task->tk_xprt;
> @@ -984,7 +989,7 @@ static void xprt_alloc_slot(struct rpc_task *task)
>  		goto out_init_req;
>  	switch (PTR_ERR(req)) {
>  	case -ENOMEM:
> -		rpc_delay(task, HZ >> 2);
> +		rpc_delay_action(task, HZ >> 2, xprt_alloc_delay_reset_status);
>  		dprintk("RPC:       dynamic allocation of request slot "
>  				"failed! Retrying\n");
>  		break;


Now that I look at this more closely though...I wonder if we're going
to end up with similar problems in the EAGAIN case. Because we have
tk_timeout==0 at this point, I think we'll always end up having the
tk_status set to -ETIMEDOUT in the event that xprt_dynamic_alloc_slot
returns EAGAIN (due to __rpc_queue_timer_fn).

Perhaps we need a similar fix there? Or maybe we should just push the
error handling for xprt_alloc_slot into call_reserveresult and bypass
the whole problem that way?

Thoughts?
-- 
Jeff Layton <jlayton@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
  2012-05-18 20:16 [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot Jeff Layton
  2012-05-18 20:33 ` Jeff Layton
@ 2012-05-19 16:23 ` Myklebust, Trond
  1 sibling, 0 replies; 5+ messages in thread
From: Myklebust, Trond @ 2012-05-19 16:23 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Adamson, Andy, linux-nfs@vger.kernel.org

T24gRnJpLCAyMDEyLTA1LTE4IGF0IDE2OjE2IC0wNDAwLCBKZWZmIExheXRvbiB3cm90ZToNCj4g
eHBydF9hbGxvY19zbG90IHdpbGwgY2FsbCBycGNfZGVsYXkoKSB0byBtYWtlIHRoZSB0YXNrIHdh
aXQgYSBiaXQgYmVmb3JlDQo+IHJldHJ5aW5nIHdoZW4gaXQgZ2V0cyBiYWNrIGFuIC1FTk9NRU0g
ZXJyb3IgZnJvbSB4cHJ0X2R5bmFtaWNfYWxsb2Nfc2xvdC4NCj4gDQo+IFRoZSBwcm9ibGVtIHRo
ZXJlIGlzIHRoYXQgcnBjX2RlbGF5IGRvZXMgdGhpczoNCj4gDQo+ICAgICBycGNfc2xlZXBfb24o
JmRlbGF5X3F1ZXVlLCB0YXNrLCBfX3JwY19hdHJ1bik7DQo+IA0KPiAuLi5hbmQgX19ycGNfYXRy
dW4gd2lsbCByZXNldCB0aGUgdGFzay0+dGtfc3RhdHVzIGJhY2sgdG8gMCB3aGVuIHRoZQ0KPiB0
YXNrIHdha2VzIGJhY2sgdXAuIFRoaXMgbWFrZXMgY2FsbF9yZXNlcnZlcmVzdWx0IGFib3J0IHRo
ZSB0YXNrIHdpdGgNCj4gLUVJTy4NCj4gDQo+IFRoZSBSSCBRQSBncm91cCBkaXNjb3ZlcmVkIHRo
aXMgcHJvYmxlbSB3aGVuIHRlc3Rpbmcgd2l0aCBsb3ctbWVtb3J5DQo+IGNsaWVudHMgYW5kIHRo
aXMgcGF0Y2ggZml4ZWQgaXQ6DQo+IA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c2st
PnRrX3N0YXR1cyA9IDA7DQotLSANCjEuNy43LjYNCg0KDQotLSANClRyb25kIE15a2xlYnVzdA0K
TGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0KVHJvbmQuTXlrbGVidXN0QG5l
dGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQoNCg==

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
  2012-05-18 20:33 ` Jeff Layton
@ 2012-05-19 19:33   ` Myklebust, Trond
  2012-05-20 10:58     ` Jeff Layton
  0 siblings, 1 reply; 5+ messages in thread
From: Myklebust, Trond @ 2012-05-19 19:33 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Adamson, Andy, linux-nfs@vger.kernel.org

T24gRnJpLCAyMDEyLTA1LTE4IGF0IDE2OjMzIC0wNDAwLCBKZWZmIExheXRvbiB3cm90ZToNCj4g
T24gRnJpLCAxOCBNYXkgMjAxMiAxNjoxNjoyOCAtMDQwMA0KPiBKZWZmIExheXRvbiA8amxheXRv
bkByZWRoYXQuY29tPiB3cm90ZToNCj4gDQo+ID4geHBydF9hbGxvY19zbG90IHdpbGwgY2FsbCBy
cGNfZGVsYXkoKSB0byBtYWtlIHRoZSB0YXNrIHdhaXQgYSBiaXQgYmVmb3JlDQo+ID4gcmV0cnlp
bmcgd2hlbiBpdCBnZXRzIGJhY2sgYW4gLUVOT01FTSBlcnJvciBmcm9tIHhwcnRfZHluYW1pY19h
bGxvY19zbG90Lg0KPiA+IA0KPiA+IFRoZSBwcm9ibGVtIHRoZXJlIGlzIHRoYXQgcnBjX2RlbGF5
IGRvZXMgdGhpczoNCj4gPiANCj4gPiAgICAgcnBjX3NsZWVwX29uKCZkZWxheV9xdWV1ZSwgdGFz
aywgX19ycGNfYXRydW4pOw0KPiA+IA0KPiA+IC4uLmFuZCBfX3JwY19hdHJ1biB3aWxsIHJlc2V0
IHRoZSB0YXNr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4gV2UnbGwgc29sdmUgdGhpcyBp
bg0KY2FsbF9yZXNlcnZlcmVzdWx0Lg0KDQotLSANClRyb25kIE15a2xlYnVzdA0KTGludXggTkZT
IGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0KVHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20N
Cnd3dy5uZXRhcHAuY29tDQoNCg==

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot
  2012-05-19 19:33   ` Myklebust, Trond
@ 2012-05-20 10:58     ` Jeff Layton
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2012-05-20 10:58 UTC (permalink / raw)
  To: Myklebust, Trond; +Cc: Adamson, Andy, linux-nfs@vger.kernel.org

On Sat, 19 May 2012 19:33:19 +0000
"Myklebust, Trond" <Trond.Myklebust@netapp.com> wrote:

> On Fri, 2012-05-18 at 16:33 -0400, Jeff Layton wrote:
> > On Fri, 18 May 2012 16:16:28 -0400
> > Jeff Layton <jlayton@redhat.com> wrote:
> > 
> > > xprt_alloc_slot will call rpc_delay() to make the task wait a bit before
> > > retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot.
> > > 
> > > The problem there is that rpc_delay does this:
> > > 
> > >     rpc_sleep_on(&delay_queue, task, __rpc_atrun);
> > > 
> > > ...and __rpc_atrun will reset the task->tk_status back to 0 when the
> > > task wakes back up. This makes call_reserveresult abort the task with
> > > -EIO.
> > > 
> > > The RH QA group discovered this problem when testing with low-memory
> > > clients and this patch fixed it:
> > > 
> > >     https://bugzilla.redhat.com/show_bug.cgi?id=822189
> > > 
> > > Fix this by adding a new rpc_delay_action() variant that makes allows
> > > us to pass in a rpc_action to reset the status back to -EAGAIN instead.
> > > 
> > > Cc: Andy Adamson <andros@netapp.com>
> > > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > > ---
> > >  include/linux/sunrpc/sched.h |    1 +
> > >  net/sunrpc/sched.c           |    9 +++++++--
> > >  net/sunrpc/xprt.c            |    7 ++++++-
> > >  3 files changed, 14 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
> > > index dc0c3cc..6cafdbb 100644
> > > --- a/include/linux/sunrpc/sched.h
> > > +++ b/include/linux/sunrpc/sched.h
> > > @@ -241,6 +241,7 @@ struct rpc_task *rpc_wake_up_first(struct rpc_wait_queue *,
> > >  					void *);
> > >  void		rpc_wake_up_status(struct rpc_wait_queue *, int);
> > >  int		rpc_queue_empty(struct rpc_wait_queue *);
> > > +void		rpc_delay_action(struct rpc_task *, unsigned long, rpc_action);
> > >  void		rpc_delay(struct rpc_task *, unsigned long);
> > >  void *		rpc_malloc(struct rpc_task *, size_t);
> > >  void		rpc_free(void *);
> > > diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
> > > index 994cfea..f2ff98d 100644
> > > --- a/net/sunrpc/sched.c
> > > +++ b/net/sunrpc/sched.c
> > > @@ -613,13 +613,18 @@ static void __rpc_atrun(struct rpc_task *task)
> > >  	task->tk_status = 0;
> > >  }
> > >  
> > > +void rpc_delay_action(struct rpc_task *task, unsigned long delay, rpc_action action)
> > > +{
> > > +	task->tk_timeout = delay;
> > > +	rpc_sleep_on(&delay_queue, task, action);
> > > +}
> > > +
> > >  /*
> > >   * Run a task at a later time
> > >   */
> > >  void rpc_delay(struct rpc_task *task, unsigned long delay)
> > >  {
> > > -	task->tk_timeout = delay;
> > > -	rpc_sleep_on(&delay_queue, task, __rpc_atrun);
> > > +	rpc_delay_action(task, delay, __rpc_atrun);
> > >  }
> > >  EXPORT_SYMBOL_GPL(rpc_delay);
> > >  
> > > diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
> > > index b239e75..a5dc816 100644
> > > --- a/net/sunrpc/xprt.c
> > > +++ b/net/sunrpc/xprt.c
> > > @@ -969,6 +969,11 @@ static bool xprt_dynamic_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
> > >  	return false;
> > >  }
> > >  
> > > +static void xprt_alloc_delay_reset_status(struct rpc_task *task)
> > > +{
> > > +	task->tk_status = -EAGAIN;
> > > +}
> > > +
> > >  static void xprt_alloc_slot(struct rpc_task *task)
> > >  {
> > >  	struct rpc_xprt	*xprt = task->tk_xprt;
> > > @@ -984,7 +989,7 @@ static void xprt_alloc_slot(struct rpc_task *task)
> > >  		goto out_init_req;
> > >  	switch (PTR_ERR(req)) {
> > >  	case -ENOMEM:
> > > -		rpc_delay(task, HZ >> 2);
> > > +		rpc_delay_action(task, HZ >> 2, xprt_alloc_delay_reset_status);
> > >  		dprintk("RPC:       dynamic allocation of request slot "
> > >  				"failed! Retrying\n");
> > >  		break;
> > 
> > 
> > Now that I look at this more closely though...I wonder if we're going
> > to end up with similar problems in the EAGAIN case. Because we have
> > tk_timeout==0 at this point, I think we'll always end up having the
> > tk_status set to -ETIMEDOUT in the event that xprt_dynamic_alloc_slot
> > returns EAGAIN (due to __rpc_queue_timer_fn).
> 
> Am I missing something?
> 
> xprt_alloc_slot calls rpc_sleep_on with task->tk_timeout == 0, which
> means __rpc_add_timer quits without adding the task to the
> queue->timer_list. How would __rpc_queue_timer_fn find it?
> 

No, you're correct.

> > Perhaps we need a similar fix there? Or maybe we should just push the
> > error handling for xprt_alloc_slot into call_reserveresult and bypass
> > the whole problem that way?
> > 
> > Thoughts?
> 
> See the patch I sent out before I saw this email. We'll solve this in
> call_reserveresult.
> 

Yes, I think that's a cleaner approach now that I look at it. That
patch should solve the problem.

Should we also move the rpc_sleep_on in the -EAGAIN case to
call_reserveresult while we're at it? It seems a little confusing to
handle the delay in those cases within different functions.

Thanks,
-- 
Jeff Layton <jlayton@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-20 10:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-18 20:16 [PATCH] sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_alloc_slot Jeff Layton
2012-05-18 20:33 ` Jeff Layton
2012-05-19 19:33   ` Myklebust, Trond
2012-05-20 10:58     ` Jeff Layton
2012-05-19 16:23 ` Myklebust, Trond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox