提交 b5ce8101 编写于 作者: S Sagi Grimberg 提交者: Yang Yingliang

nvme: make nvme_report_ns_ids propagate error back

mainline inclusion
from mainline-v5.4-rc1
commit 538af88e
category: bugfix
bugzilla: NA
CVE: NA
Link: https://gitee.com/openeuler/kernel/issues/I4JFBE?from=project-issue

-------------------------------------------------

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: NHannes Reinecke <hare@suse.com>
Reviewed-by: NJames Smart <james.smart@broadcom.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: NSagi Grimberg <sagi@grimberg.me>

conflicts:
drivers/nvme/host/core.c
[adjust context]
Signed-off-by: Nchengjike <chengjike.cheng@huawei.com>
Reviewed-by: NAo Sun <sunao.sun@huawei.com>
Reviewed-by: NZhenwei Yang <yangzhenwei@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 fb716db7
...@@ -1589,9 +1589,11 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns) ...@@ -1589,9 +1589,11 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
blk_queue_max_write_zeroes_sectors(queue, UINT_MAX); blk_queue_max_write_zeroes_sectors(queue, UINT_MAX);
} }
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) struct nvme_id_ns *id, struct nvme_ns_ids *ids)
{ {
int ret = 0;
memset(ids, 0, sizeof(*ids)); memset(ids, 0, sizeof(*ids));
if (ctrl->vs >= NVME_VS(1, 1, 0)) if (ctrl->vs >= NVME_VS(1, 1, 0))
...@@ -1602,10 +1604,12 @@ static void nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid, ...@@ -1602,10 +1604,12 @@ static void nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid,
/* Don't treat error as fatal we potentially /* Don't treat error as fatal we potentially
* already have a NGUID or EUI-64 * 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, 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) static bool nvme_ns_ids_valid(struct nvme_ns_ids *ids)
...@@ -1711,7 +1715,10 @@ static int nvme_revalidate_disk(struct gendisk *disk) ...@@ -1711,7 +1715,10 @@ static int nvme_revalidate_disk(struct gendisk *disk)
goto free_id; goto free_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)) { if (!nvme_ns_ids_equal(&ns->head->ids, &ids)) {
dev_err(ctrl->device, dev_err(ctrl->device,
"identifiers changed for nsid %d\n", ns->head->ns_id); "identifiers changed for nsid %d\n", ns->head->ns_id);
...@@ -3144,7 +3151,9 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, ...@@ -3144,7 +3151,9 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
head->ns_id = nsid; head->ns_id = nsid;
kref_init(&head->ref); 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); ret = __nvme_check_ids(ctrl->subsys, head);
if (ret) { if (ret) {
...@@ -3169,6 +3178,8 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, ...@@ -3169,6 +3178,8 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
out_free_head: out_free_head:
kfree(head); kfree(head);
out: out:
if (ret > 0)
ret = blk_status_to_errno(nvme_error_status(ret));
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -3192,7 +3203,12 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, ...@@ -3192,7 +3203,12 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
} else { } else {
struct nvme_ns_ids ids; struct nvme_ns_ids ids;
nvme_report_ns_ids(ctrl, nsid, id, &ids); ret = nvme_report_ns_ids(ctrl, nsid, id, &ids);
if (ret) {
nvme_put_ns_head(head);
goto out_unlock;
}
if (!nvme_ns_ids_equal(&head->ids, &ids)) { if (!nvme_ns_ids_equal(&head->ids, &ids)) {
dev_err(ctrl->device, dev_err(ctrl->device,
"IDs don't match for shared namespace %d\n", "IDs don't match for shared namespace %d\n",
...@@ -3208,6 +3224,8 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, ...@@ -3208,6 +3224,8 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
out_unlock: out_unlock:
mutex_unlock(&ctrl->subsys->lock); mutex_unlock(&ctrl->subsys->lock);
if (ret > 0)
ret = blk_status_to_errno(nvme_error_status(ret));
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册