* [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops
@ 2023-03-10 1:09 Ming Lei
2023-03-15 1:18 ` Ming Lei
2023-03-15 1:21 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2023-03-10 1:09 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Chris Leech, Marco Patalano, Ming Lei
From: Chris Leech <cleech@redhat.com>
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>
---
block/blk-mq.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq.h b/block/blk-mq.h
index ef59fee62780..a7482d2cc82e 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -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) \
do { \
if ((q)->tag_set->flags & BLK_MQ_F_BLOCKING) { \
+ struct blk_mq_tag_set *__tag_set = (q)->tag_set; \
int srcu_idx; \
\
might_sleep_if(check_sleep); \
- srcu_idx = srcu_read_lock((q)->tag_set->srcu); \
+ srcu_idx = srcu_read_lock(__tag_set->srcu); \
(dispatch_ops); \
- srcu_read_unlock((q)->tag_set->srcu, srcu_idx); \
+ srcu_read_unlock(__tag_set->srcu, srcu_idx); \
} else { \
rcu_read_lock(); \
(dispatch_ops); \
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops
2023-03-10 1:09 [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops Ming Lei
@ 2023-03-15 1:18 ` Ming Lei
2023-03-15 1:21 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2023-03-15 1:18 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-block, Chris Leech, Marco Patalano, ming.lei
On Fri, Mar 10, 2023 at 09:09:13AM +0800, Ming Lei wrote:
> From: Chris Leech <cleech@redhat.com>
>
> 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>
Hi Jens,
This patch fixes one hang issue on blk_mq_quiesce_queue(), so could you
make it to v6.3 if you are fine?
Thanks,
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops
2023-03-10 1:09 [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops Ming Lei
2023-03-15 1:18 ` Ming Lei
@ 2023-03-15 1:21 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-03-15 1:21 UTC (permalink / raw)
To: Ming Lei; +Cc: linux-block, Chris Leech, Marco Patalano
On Fri, 10 Mar 2023 09:09:13 +0800, Ming Lei wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops
commit: 00e885efcfbb8712d3e1bfc1ae30639c15ca1d3b
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-15 1:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 1:09 [PATCH] blk-mq: fix "bad unlock balance detected" on q->srcu in __blk_mq_run_dispatch_ops Ming Lei
2023-03-15 1:18 ` Ming Lei
2023-03-15 1:21 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox