Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-13 Thread Ming Lei
On Thu, Apr 12, 2018 at 06:57:12AM -0700, Tejun Heo wrote: > On Thu, Apr 12, 2018 at 07:05:13AM +0800, Ming Lei wrote: > > > Not really because aborted_gstate right now doesn't have any memory > > > barrier around it, so nothing ensures blk_add_timer() actually appears > > > before. We can either

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-12 Thread Tejun Heo
On Thu, Apr 12, 2018 at 07:05:13AM +0800, Ming Lei wrote: > > Not really because aborted_gstate right now doesn't have any memory > > barrier around it, so nothing ensures blk_add_timer() actually appears > > before. We can either add the matching barriers in aborted_gstate > > update and when

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Ming Lei
On Wed, Apr 11, 2018 at 10:49:51PM +, Bart Van Assche wrote: > On Thu, 2018-04-12 at 04:55 +0800, Ming Lei wrote: > > +again: > > switch (ret) { > > case BLK_EH_HANDLED: > > __blk_mq_complete_request(req); > > break; > > case BLK_EH_RESET_TIMER: > >

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Bart Van Assche
On Thu, 2018-04-12 at 04:55 +0800, Ming Lei wrote: > +again: > switch (ret) { > case BLK_EH_HANDLED: > __blk_mq_complete_request(req); > break; > case BLK_EH_RESET_TIMER: > [ ... ] > + spin_lock_irqsave(req->q->queue_lock,

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Tejun Heo
Hello, On Thu, Apr 12, 2018 at 06:43:45AM +0800, Ming Lei wrote: > On Wed, Apr 11, 2018 at 02:30:07PM -0700, Tejun Heo wrote: > > Hello, Ming. > > > > On Thu, Apr 12, 2018 at 04:55:29AM +0800, Ming Lei wrote: > > ... > > > + spin_lock_irqsave(req->q->queue_lock, flags); > > > +

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Ming Lei
On Wed, Apr 11, 2018 at 02:30:07PM -0700, Tejun Heo wrote: > Hello, Ming. > > On Thu, Apr 12, 2018 at 04:55:29AM +0800, Ming Lei wrote: > ... > > + spin_lock_irqsave(req->q->queue_lock, flags); > > + if (blk_mq_rq_state(req) != MQ_RQ_COMPLETE_IN_RESET) { > > +

Re: [PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Tejun Heo
Hello, Ming. On Thu, Apr 12, 2018 at 04:55:29AM +0800, Ming Lei wrote: ... > + spin_lock_irqsave(req->q->queue_lock, flags); > + if (blk_mq_rq_state(req) != MQ_RQ_COMPLETE_IN_RESET) { > + blk_mq_rq_update_aborted_gstate(req, 0); > +

[PATCH] blk-mq: fix race between complete and BLK_EH_RESET_TIMER

2018-04-11 Thread Ming Lei
The normal request completion can be done before or during handling BLK_EH_RESET_TIMER, and this race may cause the request to never be completed since driver's .timeout() may always return BLK_EH_RESET_TIMER. This issue can't be fixed completely by driver, since the normal completion can be done