nvmet: return uniform error for invalid ns

For nvmet_find_namespace() error case we have inconsistent error code
mapping in the function nvmet_get_smart_log_nsid() and
nvmet_set_feat_write_protect().

There is no point in retrying for the invalid namesapce from the host
side. Set the error code to the NVME_SC_INVALID_NS | NVME_SC_DNR which
matches what we have in nvmet_execute_identify_desclist().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Chaitanya Kulkarni 2021-02-09 21:47:53 -08:00 committed by Christoph Hellwig
parent 40244ad36b
commit aa0aff604a

View File

@ -82,7 +82,7 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
pr_err("Could not find namespace id : %d\n", pr_err("Could not find namespace id : %d\n",
le32_to_cpu(req->cmd->get_log_page.nsid)); le32_to_cpu(req->cmd->get_log_page.nsid));
req->error_loc = offsetof(struct nvme_rw_command, nsid); req->error_loc = offsetof(struct nvme_rw_command, nsid);
return NVME_SC_INVALID_NS; return NVME_SC_INVALID_NS | NVME_SC_DNR;
} }
/* we don't have the right data for file backed ns */ /* we don't have the right data for file backed ns */
@ -697,7 +697,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid); req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid);
if (unlikely(!req->ns)) { if (unlikely(!req->ns)) {
req->error_loc = offsetof(struct nvme_common_command, nsid); req->error_loc = offsetof(struct nvme_common_command, nsid);
return status; return status = NVME_SC_INVALID_NS | NVME_SC_DNR;
} }
mutex_lock(&subsys->lock); mutex_lock(&subsys->lock);