[PATCH 12/14] nvmet: remove repeated call for desclist
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Sun Jun 27 22:08:15 PDT 2021
Return status from nvmet_execute_identidy_desclist() 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 | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 749d7e695fa2..02d28158e9f0 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -619,58 +619,54 @@ static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
return 0;
}
-static void nvmet_execute_identify_desclist(struct nvmet_req *req)
+static u16 nvmet_execute_identify_desclist(struct nvmet_req *req)
{
off_t off = 0;
u16 status;
status = nvmet_req_find_ns(req);
if (status)
- goto out;
+ return status;
if (memchr_inv(&req->ns->uuid, 0, sizeof(req->ns->uuid))) {
status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID,
NVME_NIDT_UUID_LEN,
&req->ns->uuid, &off);
if (status)
- goto out;
+ return status;
}
if (memchr_inv(req->ns->nguid, 0, sizeof(req->ns->nguid))) {
status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID,
NVME_NIDT_NGUID_LEN,
&req->ns->nguid, &off);
if (status)
- goto out;
+ return status;
}
status = nvmet_copy_ns_identifier(req, NVME_NIDT_CSI,
NVME_NIDT_CSI_LEN,
&req->ns->csi, &off);
if (status)
- goto out;
+ return status;
if (sg_zero_buffer(req->sg, req->sg_cnt, NVME_IDENTIFY_DATA_SIZE - off,
off) != NVME_IDENTIFY_DATA_SIZE - off)
- status = NVME_SC_INTERNAL | NVME_SC_DNR;
+ return NVME_SC_INTERNAL | NVME_SC_DNR;
-out:
- nvmet_req_complete(req, status);
+ return status;
}
-static bool nvmet_handle_identify_desclist(struct nvmet_req *req)
+static u16 nvmet_handle_identify_desclist(struct nvmet_req *req)
{
switch (req->cmd->identify.csi) {
case NVME_CSI_NVM:
- nvmet_execute_identify_desclist(req);
- return true;
+ return nvmet_execute_identify_desclist(req);
case NVME_CSI_ZNS:
- if (IS_ENABLED(CONFIG_BLK_DEV_ZONED)) {
- nvmet_execute_identify_desclist(req);
- return true;
- }
- return false;
+ if (IS_ENABLED(CONFIG_BLK_DEV_ZONED))
+ return nvmet_execute_identify_desclist(req);
+ return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
default:
- return false;
+ return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
}
}
@@ -728,8 +724,7 @@ static void nvmet_execute_identify(struct nvmet_req *req)
}
break;
case NVME_ID_CNS_NS_DESC_LIST:
- if (nvmet_handle_identify_desclist(req) == true)
- return;
+ status = nvmet_handle_identify_desclist(req);
break;
default:
pr_debug("unhandled identify cns %d on qid %d\n",
--
2.22.1
More information about the Linux-nvme
mailing list