nvme: display correct subsystem NQN
authorHannes Reinecke <hare@suse.de>
Wed, 22 Sep 2021 06:35:25 +0000 (08:35 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 20 Oct 2021 17:16:02 +0000 (19:16 +0200)
With discovery controllers supporting unique subsystem NQNs the
actual subsystem NQN might be different from that one passed in
via the connect args. So add a helper to display the resulting
subsystem NQN.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.h
drivers/nvme/host/fc.c
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c

index fd856ee..3825b59 100644 (file)
@@ -222,7 +222,7 @@ int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl)
 static void nvme_do_delete_ctrl(struct nvme_ctrl *ctrl)
 {
        dev_info(ctrl->device,
-                "Removing ctrl: NQN \"%s\"\n", ctrl->opts->subsysnqn);
+                "Removing ctrl: NQN \"%s\"\n", nvmf_ctrl_subsysnqn(ctrl));
 
        flush_work(&ctrl->reset_work);
        nvme_stop_ctrl(ctrl);
index b61b666..c3203ff 100644 (file)
@@ -179,6 +179,13 @@ nvmf_ctlr_matches_baseopts(struct nvme_ctrl *ctrl,
        return true;
 }
 
+static inline char *nvmf_ctrl_subsysnqn(struct nvme_ctrl *ctrl)
+{
+       if (!ctrl->subsys)
+               return ctrl->opts->subsysnqn;
+       return ctrl->subsys->subnqn;
+}
+
 int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val);
 int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val);
 int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val);
index 34f7a7c..be98928 100644 (file)
@@ -3596,7 +3596,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 
        dev_info(ctrl->ctrl.device,
                "NVME-FC{%d}: new ctrl: NQN \"%s\"\n",
-               ctrl->cnum, ctrl->ctrl.opts->subsysnqn);
+               ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl));
 
        return &ctrl->ctrl;
 
index 027ee57..5ba386f 100644 (file)
@@ -2393,7 +2393,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
                goto out_uninit_ctrl;
 
        dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISpcs\n",
-               ctrl->ctrl.opts->subsysnqn, &ctrl->addr);
+               nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr);
 
        mutex_lock(&nvme_rdma_ctrl_mutex);
        list_add_tail(&ctrl->list, &nvme_rdma_ctrl_list);
index 9ce3458..07156ea 100644 (file)
@@ -2582,7 +2582,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,
                goto out_uninit_ctrl;
 
        dev_info(ctrl->ctrl.device, "new ctrl: NQN \"%s\", addr %pISp\n",
-               ctrl->ctrl.opts->subsysnqn, &ctrl->addr);
+               nvmf_ctrl_subsysnqn(&ctrl->ctrl), &ctrl->addr);
 
        mutex_lock(&nvme_tcp_ctrl_mutex);
        list_add_tail(&ctrl->list, &nvme_tcp_ctrl_list);