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

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


Return status from nvmet_execute_identidy_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 | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 4f88276e0c48..e625a33d0861 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -486,22 +486,20 @@ static u16 nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	return status;
 }
 
-static void nvmet_execute_identify_ns(struct nvmet_req *req)
+static u16 nvmet_execute_identify_ns(struct nvmet_req *req)
 {
 	struct nvme_id_ns *id;
 	u16 status;
 
 	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_NS | NVME_SC_DNR;
 	}
 
 	id = kzalloc(sizeof(*id), GFP_KERNEL);
-	if (!id) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!id)
+		return NVME_SC_INTERNAL;
+
 
 	/* return an all zeroed buffer if we can't find an active namespace */
 	status = nvmet_req_find_ns(req);
@@ -565,8 +563,8 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 		status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
 
 	kfree(id);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static void nvmet_execute_identify_nslist(struct nvmet_req *req)
@@ -689,7 +687,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 	case NVME_ID_CNS_NS:
 		switch (req->cmd->identify.csi) {
 		case NVME_CSI_NVM:
-			return nvmet_execute_identify_ns(req);
+			status = nvmet_execute_identify_ns(req);
+			break;
 		default:
 			break;
 		}
-- 
2.22.1




More information about the Linux-nvme mailing list