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

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


Return status from nvmet_execute_identify_cns_cs_ctrl() 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 |  4 +++-
 drivers/nvme/target/nvmet.h     |  2 +-
 drivers/nvme/target/zns.c       | 12 +++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index ef6982beb6b0..1a8ca93b6bb9 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -709,7 +709,9 @@ 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_ctrl(req);
+				status =
+				nvmet_execute_identify_cns_cs_ctrl(req);
+				break;
 			default:
 				break;
 			}
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index f1c9cd445c74..b2eeb296cc37 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -545,7 +545,7 @@ void nvmet_ns_revalidate(struct nvmet_ns *ns);
 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);
+u16 nvmet_execute_identify_cns_cs_ctrl(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);
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 2e1f01ec0dd1..28a1de2e0fbf 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -71,7 +71,7 @@ bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
 	return true;
 }
 
-void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
+u16 nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 {
 	u8 zasl = req->sq->ctrl->subsys->zasl;
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -79,10 +79,8 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	u16 status;
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
-	if (!id) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id)
+		return NVME_SC_INTERNAL;
 
 	if (ctrl->ops->get_mdts)
 		id->zasl = min_t(u8, ctrl->ops->get_mdts(ctrl), zasl);
@@ -92,8 +90,8 @@ void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
 
 	kfree(id);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 u16 nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
-- 
2.22.1




More information about the Linux-nvme mailing list