[PATCH 3/7] nvmet: centralize req completion for smart log

Chaitanya Kulkarni kch at nvidia.com
Thu Mar 23 00:51:59 PDT 2023


Remove nvmet_req_completion() call from
nvmet_execute_get_log_page_smart() and use the one that is in the caller
nvmet_execute_get_log_page().

Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
---
 drivers/nvme/target/admin-cmd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 44ad1c945938..c2f510c80bbf 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -130,18 +130,18 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
 	return NVME_SC_SUCCESS;
 }
 
-static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_smart(struct nvmet_req *req)
 {
 	struct nvme_smart_log *log;
 	u16 status = NVME_SC_INTERNAL;
 	unsigned long flags;
 
 	if (req->transfer_len != sizeof(*log))
-		goto out;
+		return status;
 
 	log = kzalloc(sizeof(*log), GFP_KERNEL);
 	if (!log)
-		goto out;
+		return status;
 
 	if (req->cmd->get_log_page.nsid == cpu_to_le32(NVME_NSID_ALL))
 		status = nvmet_get_smart_log_all(req, log);
@@ -158,8 +158,7 @@ static void nvmet_execute_get_log_page_smart(struct nvmet_req *req)
 	status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
 out_free_log:
 	kfree(log);
-out:
-	nvmet_req_complete(req, status);
+	return status;
 }
 
 static void nvmet_get_cmd_effects_nvm(struct nvme_effects_log *log)
@@ -329,7 +328,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		status = nvmet_execute_get_log_page_error(req);
 		break;
 	case NVME_LOG_SMART:
-		return nvmet_execute_get_log_page_smart(req);
+		status = nvmet_execute_get_log_page_smart(req);
+		break;
 	case NVME_LOG_FW_SLOT:
 		/*
 		 * We only support a single firmware slot which always is
-- 
2.29.0




More information about the Linux-nvme mailing list