[PATCH 13/14] nvmet: remove repeated call for id-cns-ns

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Sun Jun 27 22:08:16 PDT 2021


Return status from nvmet_execute_identify_cns_cs_ns() and complete the
request in nvmet_execute_identify(). This reduces number of repeated
nvmet_req_complete() calls for identify handlers.

Also, now we can get rid of the goto and out label needed for request
completion and directly return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/admin-cmd.c |  3 ++-
 drivers/nvme/target/nvmet.h     |  2 +-
 drivers/nvme/target/zns.c       | 15 ++++++---------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 02d28158e9f0..ef6982beb6b0 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -691,7 +691,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
 			switch (req->cmd->identify.csi) {
 			case NVME_CSI_ZNS:
-				return nvmet_execute_identify_cns_cs_ns(req);
+				status = nvmet_execute_identify_cns_cs_ns(req);
+				break;
 			default:
 				break;
 			}
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 2119abc2a9b9..f1c9cd445c74 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -546,7 +546,7 @@ u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts);
 
 bool nvmet_bdev_zns_enable(struct nvmet_ns *ns);
 void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req);
-void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
+u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_mgmt_send(struct nvmet_req *req);
 void nvmet_bdev_execute_zone_append(struct nvmet_req *req);
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 17f8b7a45f21..2e1f01ec0dd1 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -96,7 +96,7 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	nvmet_req_complete(req, status);
 }
 
-void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
+u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 {
 	struct nvme_id_ns_zns *id_zns;
 	u64 zsze;
@@ -104,15 +104,12 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 
 	if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
 		req->error_loc = offsetof(struct nvme_identify, nsid);
-		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
-		goto out;
+		return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
 	}
 
 	id_zns = kzalloc(sizeof(*id_zns), GFP_KERNEL);
-	if (!id_zns) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id_zns)
+		return NVME_SC_INTERNAL;
 
 	status = nvmet_req_find_ns(req);
 	if (status) {
@@ -136,8 +133,8 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
 done:
 	status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns));
 	kfree(id_zns);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u16 nvmet_bdev_validate_zone_mgmt_recv(struct nvmet_req *req)
-- 
2.22.1




More information about the Linux-nvme mailing list