[PATCH 08/14] nvmet: add default case for nvmet_execute_identify

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


Just like on what we have done earlier in the series for the
nvmet_execute_get_log_page() repeat the same pattern for the
nvmet_execute_identify(), add a default case to print the error & move
the request completion call outside of the switch so it can be used by
all the switch cases.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 10 +++++++++-
 drivers/nvme/target/nvmet.h     |  8 --------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 4e58dfbfbbd5..28c24c08bd99 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -682,6 +682,8 @@ static bool nvmet_handle_identify_desclist(struct nvmet_req *req)
 
 static void nvmet_execute_identify(struct nvmet_req *req)
 {
+	u16 status;
+
 	if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
 		return;
 
@@ -732,9 +734,15 @@ static void nvmet_execute_identify(struct nvmet_req *req)
 		if (nvmet_handle_identify_desclist(req) == true)
 			return;
 		break;
+	default:
+		pr_debug("unhandled identify cns %d on qid %d\n",
+			 req->cmd->identify.cns, req->sq->qid);
+		req->error_loc = offsetof(struct nvme_identify, cns);
+		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+		break;
 	}
 
-	nvmet_req_cns_error_complete(req);
+	nvmet_req_complete(req, status);
 }
 
 /*
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index d719a1cd5dda..2119abc2a9b9 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -645,14 +645,6 @@ static inline bool nvmet_use_inline_bvec(struct nvmet_req *req)
 	       req->sg_cnt <= NVMET_MAX_INLINE_BIOVEC;
 }
 
-static inline void nvmet_req_cns_error_complete(struct nvmet_req *req)
-{
-	pr_debug("unhandled identify cns %d on qid %d\n",
-	       req->cmd->identify.cns, req->sq->qid);
-	req->error_loc = offsetof(struct nvme_identify, cns);
-	nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
-}
-
 static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
 {
 	if (bio != &req->b.inline_bio)
-- 
2.22.1




More information about the Linux-nvme mailing list