Skip to content

Commit

Permalink
nvme: make nvme_report_ns_ids propagate error back
Browse files Browse the repository at this point in the history
Make the callers check the return status and propagate
back accordingly (casting to errno from a positive nvme status).
Also print the return status in nvme_report_ns_ids.

Reviewed-by: Hannes Reinecke <[email protected]>
Reviewed-by: James Smart <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
Signed-off-by: Sagi Grimberg <[email protected]>
  • Loading branch information
sagigrimberg committed Sep 12, 2019
1 parent 331813f commit 538af88
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,9 +1595,11 @@ static void nvme_config_write_zeroes(struct gendisk *disk, struct nvme_ns *ns)
blk_queue_max_write_zeroes_sectors(disk->queue, max_sectors);
}

static void nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
struct nvme_id_ns *id, struct nvme_ns_ids *ids)
{
int ret = 0;

memset(ids, 0, sizeof(*ids));

if (ctrl->vs >= NVME_VS(1, 1, 0))
Expand All @@ -1608,10 +1610,12 @@ static void nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
/* Don't treat error as fatal we potentially
* already have a NGUID or EUI-64
*/
if (nvme_identify_ns_descs(ctrl, nsid, ids))
ret = nvme_identify_ns_descs(ctrl, nsid, ids);
if (ret)
dev_warn(ctrl->device,
"%s: Identify Descriptors failed\n", __func__);
"Identify Descriptors failed (%d)\n", ret);
}
return ret;
}

static bool nvme_ns_ids_valid(struct nvme_ns_ids *ids)
Expand Down Expand Up @@ -1748,7 +1752,10 @@ static int nvme_revalidate_disk(struct gendisk *disk)
}

__nvme_revalidate_disk(disk, id);
nvme_report_ns_ids(ctrl, ns->head->ns_id, id, &ids);
ret = nvme_report_ns_ids(ctrl, ns->head->ns_id, id, &ids);
if (ret)
goto free_id;

if (!nvme_ns_ids_equal(&ns->head->ids, &ids)) {
dev_err(ctrl->device,
"identifiers changed for nsid %d\n", ns->head->ns_id);
Expand Down Expand Up @@ -3176,7 +3183,9 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
head->ns_id = nsid;
kref_init(&head->ref);

nvme_report_ns_ids(ctrl, nsid, id, &head->ids);
ret = nvme_report_ns_ids(ctrl, nsid, id, &head->ids);
if (ret)
goto out_cleanup_srcu;

ret = __nvme_check_ids(ctrl->subsys, head);
if (ret) {
Expand All @@ -3201,6 +3210,8 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
out_free_head:
kfree(head);
out:
if (ret > 0)
ret = blk_status_to_errno(nvme_error_status(ret));
return ERR_PTR(ret);
}

Expand All @@ -3224,7 +3235,10 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
} else {
struct nvme_ns_ids ids;

nvme_report_ns_ids(ctrl, nsid, id, &ids);
ret = nvme_report_ns_ids(ctrl, nsid, id, &ids);
if (ret)
goto out_unlock;

if (!nvme_ns_ids_equal(&head->ids, &ids)) {
dev_err(ctrl->device,
"IDs don't match for shared namespace %d\n",
Expand All @@ -3239,6 +3253,8 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,

out_unlock:
mutex_unlock(&ctrl->subsys->lock);
if (ret > 0)
ret = blk_status_to_errno(nvme_error_status(ret));
return ret;
}

Expand Down

0 comments on commit 538af88

Please sign in to comment.