[PATCH 04/10] nvmet: remove nsid param from nvmet_find_namespace()
From: Chaitanya Kulkarni <hidden>
Date: 2021-02-01 05:42:21
Subsystem:
nvm express target driver, the rest · Maintainers:
Christoph Hellwig, Sagi Grimberg, Chaitanya Kulkarni, Linus Torvalds
The nvmet_find_namespace() takes nsid parameter which is from NVMe commands structures such as get_log_page, identify, rw and common. All these commands have same offset for the nsid field. Derive nsid from req (req->cmd->common.nsid) and remove the extra parameter from the nvmet_find_namespace(). Signed-off-by: Chaitanya Kulkarni <redacted> --- drivers/nvme/target/admin-cmd.c | 10 +++++----- drivers/nvme/target/core.c | 6 ++++-- drivers/nvme/target/nvmet.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index fbb5fe18f2d4..ec64218db03c 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c@@ -77,7 +77,7 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req, u64 host_reads, host_writes, data_units_read, data_units_written; u16 status; - status = nvmet_find_namespace(req, req->cmd->get_log_page.nsid); + status = nvmet_find_namespace(req); if (status) { pr_err("Could not find namespace id : %d\n", le32_to_cpu(req->cmd->get_log_page.nsid));
@@ -475,7 +475,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req) goto out; } - status = nvmet_find_namespace(req, req->cmd->identify.nsid); + status = nvmet_find_namespace(req); if (status) { /* * According to spec : If the specified namespace is
@@ -611,7 +611,7 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req) u16 status; off_t off = 0; - status = nvmet_find_namespace(req, req->cmd->identify.nsid); + status = nvmet_find_namespace(req); if (status) goto out;
@@ -695,7 +695,7 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req) struct nvmet_subsys *subsys = req->sq->ctrl->subsys; u16 status; - status = nvmet_find_namespace(req, req->cmd->rw.nsid); + status = nvmet_find_namespace(req); if (unlikely(status)) return status;
@@ -798,7 +798,7 @@ static u16 nvmet_get_feat_write_protect(struct nvmet_req *req) struct nvmet_subsys *subsys = req->sq->ctrl->subsys; u16 result; - result = nvmet_find_namespace(req, req->cmd->common.nsid); + result = nvmet_find_namespace(req); if (result) return result;
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 6ebcbc637265..9c6683f8e790 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c@@ -417,8 +417,10 @@ void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl) cancel_delayed_work_sync(&ctrl->ka_work); } -u16 nvmet_find_namespace(struct nvmet_req *req, __le32 id) +u16 nvmet_find_namespace(struct nvmet_req *req) { + __le32 id = le32_to_cpu(req->cmd->common.nsid); + req->ns = xa_load(&req->sq->ctrl->subsys->namespaces, le32_to_cpu(id)); if (unlikely(!req->ns)) { req->error_loc = offsetof(struct nvme_common_command, nsid);
@@ -863,7 +865,7 @@ static u16 nvmet_parse_io_cmd(struct nvmet_req *req) if (nvmet_req_passthru_ctrl(req)) return nvmet_parse_passthru_io_cmd(req); - ret = nvmet_find_namespace(req, cmd->rw.nsid); + ret = nvmet_find_namespace(req); if (unlikely(ret)) return ret; ret = nvmet_check_ana_state(req->port, req->ns);
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 80811fccb431..6864fd916bb5 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h@@ -443,7 +443,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn, void nvmet_subsys_put(struct nvmet_subsys *subsys); void nvmet_subsys_del_ctrls(struct nvmet_subsys *subsys); -u16 nvmet_find_namespace(struct nvmet_req *req, __le32 id); +u16 nvmet_find_namespace(struct nvmet_req *req); void nvmet_put_namespace(struct nvmet_ns *ns); int nvmet_ns_enable(struct nvmet_ns *ns); void nvmet_ns_disable(struct nvmet_ns *ns);
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme