Skip to content

Commit e2d77d2

Browse files
author
Christoph Hellwig
committed
nvme: check for duplicate identifiers earlier
Lift the check for duplicate identifiers into nvme_init_ns_head, which avoids pointless error unwinding in case they don't match, and also matches where we check identifier validity for the multipath case. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]>
1 parent e2724cb commit e2d77d2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/nvme/host/core.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,13 +3782,6 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
37823782
head->ids = *ids;
37833783
kref_init(&head->ref);
37843784

3785-
ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, &head->ids);
3786-
if (ret) {
3787-
dev_err(ctrl->device,
3788-
"duplicate IDs for nsid %d\n", nsid);
3789-
goto out_cleanup_srcu;
3790-
}
3791-
37923785
if (head->ids.csi) {
37933786
ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects);
37943787
if (ret)
@@ -3827,6 +3820,12 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
38273820
mutex_lock(&ctrl->subsys->lock);
38283821
head = nvme_find_ns_head(ctrl->subsys, nsid);
38293822
if (!head) {
3823+
ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, ids);
3824+
if (ret) {
3825+
dev_err(ctrl->device,
3826+
"duplicate IDs for nsid %d\n", nsid);
3827+
goto out_unlock;
3828+
}
38303829
head = nvme_alloc_ns_head(ctrl, nsid, ids);
38313830
if (IS_ERR(head)) {
38323831
ret = PTR_ERR(head);

0 commit comments

Comments
 (0)