aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/nvme/host/core.c12
-rw-r--r--drivers/nvme/host/multipath.c15
2 files changed, 13 insertions, 14 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f431c32774f3..6088ea13a6bf 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2835,7 +2835,7 @@ out:
2835} 2835}
2836 2836
2837static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, 2837static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
2838 struct nvme_id_ns *id, bool *new) 2838 struct nvme_id_ns *id)
2839{ 2839{
2840 struct nvme_ctrl *ctrl = ns->ctrl; 2840 struct nvme_ctrl *ctrl = ns->ctrl;
2841 bool is_shared = id->nmic & (1 << 0); 2841 bool is_shared = id->nmic & (1 << 0);
@@ -2851,8 +2851,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
2851 ret = PTR_ERR(head); 2851 ret = PTR_ERR(head);
2852 goto out_unlock; 2852 goto out_unlock;
2853 } 2853 }
2854
2855 *new = true;
2856 } else { 2854 } else {
2857 struct nvme_ns_ids ids; 2855 struct nvme_ns_ids ids;
2858 2856
@@ -2864,8 +2862,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
2864 ret = -EINVAL; 2862 ret = -EINVAL;
2865 goto out_unlock; 2863 goto out_unlock;
2866 } 2864 }
2867
2868 *new = false;
2869 } 2865 }
2870 2866
2871 list_add_tail(&ns->siblings, &head->list); 2867 list_add_tail(&ns->siblings, &head->list);
@@ -2936,7 +2932,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
2936 struct nvme_id_ns *id; 2932 struct nvme_id_ns *id;
2937 char disk_name[DISK_NAME_LEN]; 2933 char disk_name[DISK_NAME_LEN];
2938 int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT; 2934 int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT;
2939 bool new = true;
2940 2935
2941 ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); 2936 ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
2942 if (!ns) 2937 if (!ns)
@@ -2962,7 +2957,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
2962 if (id->ncap == 0) 2957 if (id->ncap == 0)
2963 goto out_free_id; 2958 goto out_free_id;
2964 2959
2965 if (nvme_init_ns_head(ns, nsid, id, &new)) 2960 if (nvme_init_ns_head(ns, nsid, id))
2966 goto out_free_id; 2961 goto out_free_id;
2967 nvme_setup_streams_ns(ctrl, ns); 2962 nvme_setup_streams_ns(ctrl, ns);
2968 2963
@@ -3028,8 +3023,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
3028 pr_warn("%s: failed to register lightnvm sysfs group for identification\n", 3023 pr_warn("%s: failed to register lightnvm sysfs group for identification\n",
3029 ns->disk->disk_name); 3024 ns->disk->disk_name);
3030 3025
3031 if (new) 3026 nvme_mpath_add_disk(ns->head);
3032 nvme_mpath_add_disk(ns->head);
3033 nvme_mpath_add_disk_links(ns); 3027 nvme_mpath_add_disk_links(ns);
3034 return; 3028 return;
3035 out_unlink_ns: 3029 out_unlink_ns:
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 3b211d9e58b8..b7e5c6db4d92 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -198,11 +198,16 @@ void nvme_mpath_add_disk(struct nvme_ns_head *head)
198{ 198{
199 if (!head->disk) 199 if (!head->disk)
200 return; 200 return;
201 device_add_disk(&head->subsys->dev, head->disk); 201
202 if (sysfs_create_group(&disk_to_dev(head->disk)->kobj, 202 mutex_lock(&head->subsys->lock);
203 &nvme_ns_id_attr_group)) 203 if (!(head->disk->flags & GENHD_FL_UP)) {
204 pr_warn("%s: failed to create sysfs group for identification\n", 204 device_add_disk(&head->subsys->dev, head->disk);
205 head->disk->disk_name); 205 if (sysfs_create_group(&disk_to_dev(head->disk)->kobj,
206 &nvme_ns_id_attr_group))
207 pr_warn("%s: failed to create sysfs group for identification\n",
208 head->disk->disk_name);
209 }
210 mutex_unlock(&head->subsys->lock);
206} 211}
207 212
208void nvme_mpath_add_disk_links(struct nvme_ns *ns) 213void nvme_mpath_add_disk_links(struct nvme_ns *ns)