[PATCH 01/14] nvmet: add common req complete for log page

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


For set/get features command handlers we don't complete the request in
each feature handler instead we complete the request in the original
callback i.e. in nvmet_execute_set_feature() and
nvmet_execute_get_feature(). This reduces the number of repeated
nvmet_req_complete() calls needed for each feature to complete the
request.

A similar pattern can be used for the log page handler callback and its
helpers.

In this prep patch we add a default caes for unhandled log pages and
complete the request in the nvmet_execute_get_log_page(). Next patches
will use this call for request completion so we can remove the local
call from each log page handler.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 0cb98f2bbc8c..03bfd8676456 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -314,6 +314,8 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
 
 static void nvmet_execute_get_log_page(struct nvmet_req *req)
 {
+	u16 status;
+
 	if (!nvmet_check_transfer_len(req, nvmet_get_log_page_len(req->cmd)))
 		return;
 
@@ -335,11 +337,13 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
 		return nvmet_execute_get_log_cmd_effects_ns(req);
 	case NVME_LOG_ANA:
 		return nvmet_execute_get_log_page_ana(req);
+	default:
+		pr_err("unhandled lid %d on qid %d\n",
+		       req->cmd->get_log_page.lid, req->sq->qid);
+		req->error_loc = offsetof(struct nvme_get_log_page_command, lid);
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 	}
-	pr_debug("unhandled lid %d on qid %d\n",
-	       req->cmd->get_log_page.lid, req->sq->qid);
-	req->error_loc = offsetof(struct nvme_get_log_page_command, lid);
-	nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
+	nvmet_req_complete(req, status);
 }
 
 static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
-- 
2.22.1




More information about the Linux-nvme mailing list