blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops
authorChris Leech <cleech@redhat.com>
Fri, 10 Mar 2023 01:09:13 +0000 (09:09 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Mar 2023 01:20:55 +0000 (19:20 -0600)
commit00e885efcfbb8712d3e1bfc1ae30639c15ca1d3b
tree92eb3e277ed07c27d06e2d06b9b61523935cb87d
parent9b0cb770f5d7b1ff40bea7ca385438ee94570eec
blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops

The 'q' parameter of the macro __blk_mq_run_dispatch_ops may not be one
local variable, such as, it is rq->q, then request queue pointed by
this variable could be changed to another queue in case of
BLK_MQ_F_TAG_QUEUE_SHARED after 'dispatch_ops' returns, then
'bad unlock balance' is triggered.

Fixes the issue by adding one local variable for doing srcu lock/unlock.

Fixes: 2a904d00855f ("blk-mq: remove hctx_lock and hctx_unlock")
Cc: Marco Patalano <mpatalan@redhat.com>
Signed-off-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230310010913.1014789-1-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.h