[PATCH 11/14] nvmet: remove repeated call for nslist

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


Return status from nvmet_execute_identidy_nslist() 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 | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index e625a33d0861..749d7e695fa2 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -567,7 +567,7 @@ static u16 nvmet_execute_identify_ns(struct nvmet_req *req)
 	return status;
 }
 
-static void nvmet_execute_identify_nslist(struct nvmet_req *req)
+static u16 nvmet_execute_identify_nslist(struct nvmet_req *req)
 {
 	static const int buf_size = NVME_IDENTIFY_DATA_SIZE;
 	struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -575,14 +575,12 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	unsigned long idx;
 	u32 min_nsid = le32_to_cpu(req->cmd->identify.nsid);
 	__le32 *list;
-	u16 status = 0;
+	u16 status;
 	int i = 0;
 
 	list = kzalloc(buf_size, GFP_KERNEL);
-	if (!list) {
-		status = NVME_SC_INTERNAL;
-		goto out;
-	}
+	if (!list)
+		return NVME_SC_INTERNAL;
 
 	xa_for_each(&ctrl->subsys->namespaces, idx, ns) {
 		if (ns->nsid <= min_nsid)
@@ -595,8 +593,8 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, list, buf_size);
 
 	kfree(list);
-out:
-	nvmet_req_complete(req, status);
+
+	return status;
 }
 
 static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
@@ -723,7 +721,8 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 	case NVME_ID_CNS_NS_ACTIVE_LIST:
 		switch (req->cmd->identify.csi) {
 		case NVME_CSI_NVM:
-			return nvmet_execute_identify_nslist(req);
+			status = nvmet_execute_identify_nslist(req);
+			break;
 		default:
 			break;
 		}
-- 
2.22.1




More information about the Linux-nvme mailing list