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: 2a904d0085
("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>
This commit is contained in:
Родитель
9b0cb770f5
Коммит
00e885efcf
|
@ -378,12 +378,13 @@ static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,
|
||||||
#define __blk_mq_run_dispatch_ops(q, check_sleep, dispatch_ops) \
|
#define __blk_mq_run_dispatch_ops(q, check_sleep, dispatch_ops) \
|
||||||
do { \
|
do { \
|
||||||
if ((q)->tag_set->flags & BLK_MQ_F_BLOCKING) { \
|
if ((q)->tag_set->flags & BLK_MQ_F_BLOCKING) { \
|
||||||
|
struct blk_mq_tag_set *__tag_set = (q)->tag_set; \
|
||||||
int srcu_idx; \
|
int srcu_idx; \
|
||||||
\
|
\
|
||||||
might_sleep_if(check_sleep); \
|
might_sleep_if(check_sleep); \
|
||||||
srcu_idx = srcu_read_lock((q)->tag_set->srcu); \
|
srcu_idx = srcu_read_lock(__tag_set->srcu); \
|
||||||
(dispatch_ops); \
|
(dispatch_ops); \
|
||||||
srcu_read_unlock((q)->tag_set->srcu, srcu_idx); \
|
srcu_read_unlock(__tag_set->srcu, srcu_idx); \
|
||||||
} else { \
|
} else { \
|
||||||
rcu_read_lock(); \
|
rcu_read_lock(); \
|
||||||
(dispatch_ops); \
|
(dispatch_ops); \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче