[PATCH 07/14] nvmet: remove repeated call for ana log page
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Sun Jun 27 22:08:10 PDT 2021
Return status from nvmet_execute_get_log_page_ana() and complete the
request in nvmet_execute_get_log_page(). This reduces number of
repeated nvmet_req_complete() calls for log page 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 | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index cf02d70dedeb..4e58dfbfbbd5 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -265,7 +265,7 @@ static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid,
return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32);
}
-static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
+static u16 nvmet_execute_get_log_page_ana(struct nvmet_req *req)
{
struct nvme_ana_rsp_hdr hdr = { 0, };
struct nvme_ana_group_desc *desc;
@@ -275,11 +275,10 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
u16 ngrps = 0;
u16 status;
- status = NVME_SC_INTERNAL;
desc = kmalloc(sizeof(struct nvme_ana_group_desc) +
NVMET_MAX_NAMESPACES * sizeof(__le32), GFP_KERNEL);
if (!desc)
- goto out;
+ return NVME_SC_INTERNAL;
down_read(&nvmet_ana_sem);
for (grpid = 1; grpid <= NVMET_MAX_ANAGRPS; grpid++) {
@@ -305,9 +304,9 @@ static void nvmet_execute_get_log_page_ana(struct nvmet_req *req)
kfree(desc);
/* copy the header last once we know the number of groups */
- status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
-out:
- nvmet_req_complete(req, status);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, &hdr, sizeof(hdr));
+ return status;
}
static void nvmet_execute_get_log_page(struct nvmet_req *req)
@@ -339,7 +338,8 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
status = nvmet_execute_get_log_cmd_effects_ns(req);
break;
case NVME_LOG_ANA:
- return nvmet_execute_get_log_page_ana(req);
+ status = nvmet_execute_get_log_page_ana(req);
+ break;
default:
pr_err("unhandled lid %d on qid %d\n",
req->cmd->get_log_page.lid, req->sq->qid);
--
2.22.1
More information about the Linux-nvme
mailing list