Re: [PATCH 5/5] blk-mq: Rework blk-mq timeout handling again
From: Bart Van Assche <hidden>
Date: 2018-07-27 16:51:05
On Fri, 2018-07-27 at 10:46 -0600, Keith Busch wrote:
On Fri, Jul 27, 2018 at 09:20:42AM -0700, Bart Van Assche wrote:quoted
+ ret = req->q->mq_ops->timeout(req, reser=
ved);
quoted
+ /* + * BLK_EH_DONT_RESET_TIMER means that th=
e block driver either
quoted
+ * completed the request or still owns the request and w=
ill
quoted
+ * continue processing the timeout asynchronously. In th=
e
quoted
+ * latter case, if blk_mq_complete_request()=
was called while
quoted
+ * the timeout handler was in progress, ignore that call=
.
quoted
+ */ + if (ret == BLK_EH_DONT_RESET_TIMER) + return;=20 This is how completions get lost.
The new approach for handling completions that occur while the .timeout()
callback in progress is as follows:
* blk_mq_complete_request() executes the following code:
if (blk_mq_change_rq_state(rq, MQ_RQ_TIMED�
F8-OUT, MQ_RQ_COMPLETE))
return;
* blk_mq_rq_timed_out() executes the following code:
if (blk_mq_rq_state(req) == MQ_RQ_COMPLETE=
) {
__blk_mq_complete_request(req);
return;
}
As one can see __blk_mq_complete_request() gets called if=
this race occurs.
Bart.