Skip to content

Commit e17473f

Browse files
author
Ming Lei
committed
nvme: fix queue freeze vs limits lock order
JIRA: https://issues.redhat.com/browse/RHEL-71345 Upstream Status: for-6.4/block commit 473106d Author: Christoph Hellwig <hch@lst.de> Date: Fri Jan 10 06:47:15 2025 +0100 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 <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20250110054726.1499538-8-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 6d00d0c commit e17473f

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
@@ -2111,9 +2111,10 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,
21112111
struct queue_limits lim;
21122112
int ret;
21132113

2114-
blk_mq_freeze_queue(ns->disk->queue);
21152114
lim = queue_limits_start_update(ns->disk->queue);
21162115
nvme_set_ctrl_limits(ns->ctrl, &lim);
2116+
2117+
blk_mq_freeze_queue(ns->disk->queue);
21172118
ret = queue_limits_commit_update(ns->disk->queue, &lim);
21182119
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
21192120
blk_mq_unfreeze_queue(ns->disk->queue);
@@ -2160,12 +2161,12 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21602161
goto out;
21612162
}
21622163

2164+
lim = queue_limits_start_update(ns->disk->queue);
2165+
21632166
blk_mq_freeze_queue(ns->disk->queue);
21642167
ns->head->lba_shift = id->lbaf[lbaf].ds;
21652168
ns->head->nuse = le64_to_cpu(id->nuse);
21662169
capacity = nvme_lba_to_sect(ns->head, le64_to_cpu(id->nsze));
2167-
2168-
lim = queue_limits_start_update(ns->disk->queue);
21692170
nvme_set_ctrl_limits(ns->ctrl, &lim);
21702171
nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info);
21712172
nvme_set_chunk_sectors(ns, id, &lim);
@@ -2265,6 +2266,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22652266
struct queue_limits *ns_lim = &ns->disk->queue->limits;
22662267
struct queue_limits lim;
22672268

2269+
lim = queue_limits_start_update(ns->head->disk->queue);
22682270
blk_mq_freeze_queue(ns->head->disk->queue);
22692271
/*
22702272
* queue_limits mixes values that are the hardware limitations
@@ -2281,7 +2283,6 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22812283
* the splitting limits in to make sure we still obey possibly
22822284
* lower limitations of other controllers.
22832285
*/
2284-
lim = queue_limits_start_update(ns->head->disk->queue);
22852286
lim.logical_block_size = ns_lim->logical_block_size;
22862287
lim.physical_block_size = ns_lim->physical_block_size;
22872288
lim.io_min = ns_lim->io_min;

0 commit comments

Comments
 (0)