Skip to content

Commit 4098b88

Browse files
committed
dm: fix queue start/stop imbalance under suspend/load/resume races
JIRA: https://issues.redhat.com/browse/RHEL-119009 Upstream Status: kernel/git/torvalds/linux.git commit 7f597c2 Author: Zheng Qixing <[email protected]> Date: Tue Aug 26 15:42:03 2025 +0800 dm: fix queue start/stop imbalance under suspend/load/resume races When suspend and load run concurrently, before q->mq_ops is set in blk_mq_init_allocated_queue(), __dm_suspend() skip dm_stop_queue(). As a result, the queue's quiesce depth is not incremented. Later, once table load has finished and __dm_resume() runs, which triggers q->quiesce_depth ==0 warning in blk_mq_unquiesce_queue(): Call Trace: <TASK> dm_start_queue+0x16/0x20 [dm_mod] __dm_resume+0xac/0xb0 [dm_mod] dm_resume+0x12d/0x150 [dm_mod] do_resume+0x2c2/0x420 [dm_mod] dev_suspend+0x30/0x130 [dm_mod] ctl_ioctl+0x402/0x570 [dm_mod] dm_ctl_ioctl+0x23/0x30 [dm_mod] Fix this by explicitly tracking whether the request queue was stopped in __dm_suspend() via a new DMF_QUEUE_STOPPED flag. Only call dm_start_queue() in __dm_resume() if the queue was actually stopped. Fixes: e70feb8 ("blk-mq: support concurrent queue quiesce/unquiesce") Cc: [email protected] Signed-off-by: Zheng Qixing <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Benjamin Marzinski <[email protected]>
1 parent 33c8d68 commit 4098b88

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/md/dm-core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct mapped_device {
162162
#define DMF_SUSPENDED_INTERNALLY 7
163163
#define DMF_POST_SUSPENDING 8
164164
#define DMF_EMULATE_ZONE_APPEND 9
165+
#define DMF_QUEUE_STOPPED 10
165166

166167
static inline sector_t dm_get_size(struct mapped_device *md)
167168
{

drivers/md/dm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,8 +2960,10 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
29602960
* Stop md->queue before flushing md->wq in case request-based
29612961
* dm defers requests to md->wq from md->queue.
29622962
*/
2963-
if (dm_request_based(md))
2963+
if (dm_request_based(md)) {
29642964
dm_stop_queue(md->queue);
2965+
set_bit(DMF_QUEUE_STOPPED, &md->flags);
2966+
}
29652967

29662968
flush_workqueue(md->wq);
29672969

@@ -2983,7 +2985,7 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
29832985
if (r < 0) {
29842986
dm_queue_flush(md);
29852987

2986-
if (dm_request_based(md))
2988+
if (test_and_clear_bit(DMF_QUEUE_STOPPED, &md->flags))
29872989
dm_start_queue(md->queue);
29882990

29892991
unlock_fs(md);
@@ -3067,7 +3069,7 @@ static int __dm_resume(struct mapped_device *md, struct dm_table *map)
30673069
* so that mapping of targets can work correctly.
30683070
* Request-based dm is queueing the deferred I/Os in its request_queue.
30693071
*/
3070-
if (dm_request_based(md))
3072+
if (test_and_clear_bit(DMF_QUEUE_STOPPED, &md->flags))
30713073
dm_start_queue(md->queue);
30723074

30733075
unlock_fs(md);

0 commit comments

Comments
 (0)