nvme: Fix block device naming collision
PATCH 1/1 nvme: Fix block device naming collision
The issue exists when multipath is enabled and the namespace is shared, but all the other controller checks at nvme_is_unique_nsid() are false. The reason for this issue is that nvme_is_unique_nsid() returns false when is called from nvme_mpath_alloc_disk() due to an uninitialized value of head->shared. The patch fixes it by setting head->shared before nvme_mpath_alloc_disk() is called.
--- drivers/nvme/host/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/nvme/host/core.c +3 -3
@@ -3786,7 +3786,7 @@ static int nvme_add_ns_cdev(struct nvme_ns *ns) }static struct nvme_ns_head *nvme_alloc_ns_head (struct nvme_ctrl *ctrl, -unsigned nsid,struct nvme_ns_ids *ids) +unsigned nsid,struct nvme_ns_ids *ids,bool is_shared) {struct nvme_ns_head *head;size_t size =sizeof (*head);
@@ -3810,6 +3810,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, head->subsys = ctrl->subsys; head->ns_id = nsid; head->ids = *ids; + head->shared = is_shared;kref_init (&head->ref);if (head->ids.csi) {
@@ -3891,12 +3892,11 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, nsid); goto out_unlock; } - head =nvme_alloc_ns_head (ctrl, nsid, ids); + head =nvme_alloc_ns_head (ctrl, nsid, ids, is_shared);if (IS_ERR (head)) { ret =PTR_ERR (head); goto out_unlock; } - head->shared = is_shared; }else { ret = -EINVAL ;if (!is_shared || !head->shared) {
Signature · 1 line
2.27.0
Quoted 10 lines · Israel Rukshin
The issue exists when multipath is enabled and the namespace is shared, but all the other controller checks at
nvme_is_unique_nsid()are false. The reason for this issue is thatnvme_is_unique_nsid()returns false when is called fromnvme_mpath_alloc_disk()due to an uninitialized value ofhead->shared. The patch fixes it by settinghead->sharedbeforenvme_mpath_alloc_disk()is called.Fixes 5974ea7ce0f9 ("nvme: allow duplicate NSIDs for private namespaces")Signed-off-by Israel Rukshin <[email protected]>Reviewed-by Max Gurtovoy <[email protected]>
Looks good.
Thanks,
applied to nvme-5.19.
Incidentally my refactoring of the probing also fixes this (and will have a small merge conflict).