Skip to content

Commit 473106d

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: fix queue freeze vs limits lock order
Match the locking order used by the core block code by only freezing the queue after taking the limits lock. Unlike most queue updates this does not use the queue_limits_commit_update_frozen helper as the nvme driver want the queue frozen for more than just the limits update. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Nilay Shroff <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c99f66e commit 473106d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/nvme/host/core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,9 +2128,10 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,
21282128
struct queue_limits lim;
21292129
int ret;
21302130

2131-
blk_mq_freeze_queue(ns->disk->queue);
21322131
lim = queue_limits_start_update(ns->disk->queue);
21332132
nvme_set_ctrl_limits(ns->ctrl, &lim);
2133+
2134+
blk_mq_freeze_queue(ns->disk->queue);
21342135
ret = queue_limits_commit_update(ns->disk->queue, &lim);
21352136
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
21362137
blk_mq_unfreeze_queue(ns->disk->queue);
@@ -2177,12 +2178,12 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21772178
goto out;
21782179
}
21792180

2181+
lim = queue_limits_start_update(ns->disk->queue);
2182+
21802183
blk_mq_freeze_queue(ns->disk->queue);
21812184
ns->head->lba_shift = id->lbaf[lbaf].ds;
21822185
ns->head->nuse = le64_to_cpu(id->nuse);
21832186
capacity = nvme_lba_to_sect(ns->head, le64_to_cpu(id->nsze));
2184-
2185-
lim = queue_limits_start_update(ns->disk->queue);
21862187
nvme_set_ctrl_limits(ns->ctrl, &lim);
21872188
nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info);
21882189
nvme_set_chunk_sectors(ns, id, &lim);
@@ -2285,6 +2286,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22852286
struct queue_limits *ns_lim = &ns->disk->queue->limits;
22862287
struct queue_limits lim;
22872288

2289+
lim = queue_limits_start_update(ns->head->disk->queue);
22882290
blk_mq_freeze_queue(ns->head->disk->queue);
22892291
/*
22902292
* queue_limits mixes values that are the hardware limitations
@@ -2301,7 +2303,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
23012303
* the splitting limits in to make sure we still obey possibly
23022304
* lower limitations of other controllers.
23032305
*/
2304-
lim = queue_limits_start_update(ns->head->disk->queue);
23052306
lim.logical_block_size = ns_lim->logical_block_size;
23062307
lim.physical_block_size = ns_lim->physical_block_size;
23072308
lim.io_min = ns_lim->io_min;

0 commit comments

Comments
 (0)