nvme-loop: initialize sqsize later
authorChristoph Hellwig <hch@lst.de>
Tue, 20 Sep 2022 15:26:18 +0000 (17:26 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 27 Sep 2022 12:44:17 +0000 (14:44 +0200)
Defer initializing the sqsize field from the options until it has been
capped by MAXCMD.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
drivers/nvme/target/loop.c

index 9750a7f..ed6d36e 100644 (file)
@@ -601,7 +601,6 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
 
        ret = -ENOMEM;
 
-       ctrl->ctrl.sqsize = opts->queue_size - 1;
        ctrl->ctrl.kato = opts->kato;
        ctrl->port = nvme_loop_find_port(&ctrl->ctrl);
 
@@ -621,6 +620,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
                        opts->queue_size, ctrl->ctrl.maxcmd);
                opts->queue_size = ctrl->ctrl.maxcmd;
        }
+       ctrl->ctrl.sqsize = opts->queue_size - 1;
 
        if (opts->nr_io_queues) {
                ret = nvme_loop_create_io_queues(ctrl);