nvme: add a helper to initialize connect_q
authorChaitanya Kulkarni <kch@nvidia.com>
Thu, 10 Feb 2022 19:12:36 +0000 (11:12 -0800)
committerChristoph Hellwig <hch@lst.de>
Mon, 28 Feb 2022 11:45:06 +0000 (13:45 +0200)
Add and use helper to remove duplicate code for fabrics connect_q
initialization and error handling for all the transports.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fc.c
drivers/nvme/host/nvme.h
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c
drivers/nvme/target/loop.c

index 96a5d7f..080f85f 100644 (file)
@@ -2916,11 +2916,9 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
 
        ctrl->ctrl.tagset = &ctrl->tag_set;
 
-       ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set);
-       if (IS_ERR(ctrl->ctrl.connect_q)) {
-               ret = PTR_ERR(ctrl->ctrl.connect_q);
+       ret = nvme_ctrl_init_connect_q(&(ctrl->ctrl));
+       if (ret)
                goto out_free_tag_set;
-       }
 
        ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
        if (ret)
index a162f6c..f8658f9 100644 (file)
@@ -894,6 +894,14 @@ static inline int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 }
 #endif
 
+static inline int nvme_ctrl_init_connect_q(struct nvme_ctrl *ctrl)
+{
+       ctrl->connect_q = blk_mq_init_queue(ctrl->tagset);
+       if (IS_ERR(ctrl->connect_q))
+               return PTR_ERR(ctrl->connect_q);
+       return 0;
+}
+
 static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
 {
        return dev_to_disk(dev)->private_data;
index 14ec2c8..c49b9c3 100644 (file)
@@ -978,11 +978,9 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
                        goto out_free_io_queues;
                }
 
-               ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set);
-               if (IS_ERR(ctrl->ctrl.connect_q)) {
-                       ret = PTR_ERR(ctrl->ctrl.connect_q);
+               ret = nvme_ctrl_init_connect_q(&(ctrl->ctrl));
+               if (ret)
                        goto out_free_tag_set;
-               }
        }
 
        ret = nvme_rdma_start_io_queues(ctrl);
index 4ceb286..6cbcc8b 100644 (file)
@@ -1825,11 +1825,9 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
                        goto out_free_io_queues;
                }
 
-               ctrl->connect_q = blk_mq_init_queue(ctrl->tagset);
-               if (IS_ERR(ctrl->connect_q)) {
-                       ret = PTR_ERR(ctrl->connect_q);
+               ret = nvme_ctrl_init_connect_q(ctrl);
+               if (ret)
                        goto out_free_tag_set;
-               }
        }
 
        ret = nvme_tcp_start_io_queues(ctrl);
index eb10942..23f9d6f 100644 (file)
@@ -543,11 +543,9 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)
        if (ret)
                goto out_destroy_queues;
 
-       ctrl->ctrl.connect_q = blk_mq_init_queue(&ctrl->tag_set);
-       if (IS_ERR(ctrl->ctrl.connect_q)) {
-               ret = PTR_ERR(ctrl->ctrl.connect_q);
+       ret = nvme_ctrl_init_connect_q(&(ctrl->ctrl));
+       if (ret)
                goto out_free_tagset;
-       }
 
        ret = nvme_loop_connect_io_queues(ctrl);
        if (ret)