summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-04-22 09:59:08 +0200
committerJens Axboe <axboe@kernel.dk>2020-05-09 16:18:36 -0600
commit6623c5b3dfa5513190d729a8516db7a5163ec7de (patch)
tree7aa5608e6eeccf02afb0f27ad6105dac12146815
parent3add1d93d9919b6de94aa47900d4904adffbc976 (diff)
downloadlinux-6623c5b3dfa5513190d729a8516db7a5163ec7de.tar.bz2
nvme: clean up error handling in nvme_init_ns_head
Use a common label for putting the nshead if needed and only convert nvme status codes for the one case where it actually is needed. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--drivers/nvme/host/core.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 0231f61f37d0..35e279261c7d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3501,8 +3501,11 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
int ret = 0;
ret = nvme_report_ns_ids(ctrl, nsid, id, &ids);
- if (ret)
- goto out;
+ if (ret) {
+ if (ret < 0)
+ return ret;
+ return blk_status_to_errno(nvme_error_status(ret));
+ }
mutex_lock(&ctrl->subsys->lock);
head = nvme_find_ns_head(ctrl->subsys, nsid);
@@ -3514,32 +3517,29 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
}
head->shared = is_shared;
} else {
+ ret = -EINVAL;
if (!is_shared || !head->shared) {
dev_err(ctrl->device,
- "Duplicate unshared namespace %d\n",
- nsid);
- ret = -EINVAL;
- nvme_put_ns_head(head);
- goto out_unlock;
+ "Duplicate unshared namespace %d\n", nsid);
+ goto out_put_ns_head;
}
if (!nvme_ns_ids_equal(&head->ids, &ids)) {
dev_err(ctrl->device,
"IDs don't match for shared namespace %d\n",
nsid);
- ret = -EINVAL;
- nvme_put_ns_head(head);
- goto out_unlock;
+ goto out_put_ns_head;
}
}
list_add_tail(&ns->siblings, &head->list);
ns->head = head;
+ mutex_unlock(&ctrl->subsys->lock);
+ return 0;
+out_put_ns_head:
+ nvme_put_ns_head(head);
out_unlock:
mutex_unlock(&ctrl->subsys->lock);
-out:
- if (ret > 0)
- ret = blk_status_to_errno(nvme_error_status(ret));
return ret;
}