blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
PATCH 1/1 blk-mq: bitmap tag: fix potential unwakeable sleep in bt_get()
There is a race between __bt_get_word() and bt_clear_tag(). Since access to the tags bitmap is not serialized __bt_get_word() might miss a tag which is about to or being returned by bt_clear_tag(). As result, the process requesting the tag might end up schedulled out forever.
To avoid this corner case call io_schedule_timeout() instead of io_schedule(). The timeout should be long enough to not falsely wake up waiters often, so take the requests queue's "rq_timeout" for that.
--- block/blk-mq-tag.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
block/blk-mq-tag.c +1 -1
@@ -256,7 +256,7 @@ static int bt_get(struct blk_mq_alloc_data *data,blk_mq_put_ctx (data->ctx); -io_schedule (); +WARN_ON (!io_schedule_timeout (hctx->queue->rq_timeout)); data->ctx =blk_mq_get_ctx (data->q); data->hctx = data->q->mq_ops->map_queue(data->q,
Signature · 1 line
1.7.7.6
Jens Axboe
maintainerQuoted 10 lines · Alexander Gordeev
There is a race between
__bt_get_word()andbt_clear_tag(). Since access to the tags bitmap is not serialized__bt_get_word()might miss a tag which is about to or being returned bybt_clear_tag(). As result, the process requesting the tag might end up schedulled out forever.To avoid this corner case call
io_schedule_timeout()instead ofio_schedule(). The timeout should be long enough to not falsely wake up waiters often, so take the requests queue's "rq_timeout" for that.
What is this patch against?
Signature · 1 line
Jens Axboe
Quoted 1 line · Jens Axboe
What is this patch against?
v3.16-rc5
Quoted 3 lines
Signature · 1 line
Jens Axboe
Signature · 3 lines
Regards, Alexander Gordeev [email protected]
Jens Axboe
maintainerQuoted 4 lines · Alexander Gordeev
Quoted 1 line · Jens Axboe
What is this patch against?
v3.16-rc5
My bad, was looking at the wrong sources. What is the race? If the clear and wakeup come in after the prepare_to_wait() but before the io_schedule(), the io_schedule() will be a no-op and it wont actually sleep. Your commit message doesn't mention any particular details.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jens Axboe
Quoted 4 lines · Alexander Gordeev
Quoted 1 line · Jens Axboe
What is this patch against?
v3.16-rc5
My bad, was looking at the wrong sources. What is the race? If the clear and wakeup come in after the
prepare_to_wait()but before theio_schedule(), theio_schedule()will be a no-op and it wont actually sleep. Your commit message doesn't mention any particular details.
Let me examine the code.. It was few weeks ago and I can not remember what was that. And the changelog does not help :)
Quoted 4 lines
Signature · 2 lines
-- Jens Axboe
Signature · 3 lines
Regards, Alexander Gordeev [email protected]
Quoted 8 lines · Alexander Gordeev
Quoted 5 lines
My bad, was looking at the wrong sources. What is the race? If the clear and wakeup come in after the
prepare_to_wait()but before theio_schedule(), theio_schedule()will be a no-op and it wont actually sleep. Your commit message doesn't mention any particular details.Let me examine the code.. It was few weeks ago and I can not remember what was that. And the changelog does not help :)
Jens,
I can not recall what was my concern. Sorry for the noise.
Thanks!
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
Jens Axboe
Signature · 3 lines
Regards, Alexander Gordeev [email protected]