Skip to content

Commit 5197c05

Browse files
htejunaxboe
authored andcommitted
blk-mq: protect completion path with RCU
Currently, blk-mq protects only the issue path with RCU. This patch puts the completion path under the same RCU protection. This will be used to synchronize issue/completion against timeout by later patches, which will also add the comments. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 04ced15 commit 5197c05

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

block/blk-mq.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,16 @@ static void hctx_lock(struct blk_mq_hw_ctx *hctx, int *srcu_idx)
584584
void blk_mq_complete_request(struct request *rq)
585585
{
586586
struct request_queue *q = rq->q;
587+
struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu);
588+
int srcu_idx;
587589

588590
if (unlikely(blk_should_fake_timeout(q)))
589591
return;
592+
593+
hctx_lock(hctx, &srcu_idx);
590594
if (!blk_mark_rq_complete(rq))
591595
__blk_mq_complete_request(rq);
596+
hctx_unlock(hctx, srcu_idx);
592597
}
593598
EXPORT_SYMBOL(blk_mq_complete_request);
594599

0 commit comments

Comments
 (0)