[PATCH V10 1/8] nvmet: trim args for nvmet_copy_ns_identifier()
Chaitanya Kulkarni
chaitanya.kulkarni at wdc.com
Tue Mar 9 04:58:16 GMT 2021
The function nvmet_copy_ns_identifier() takes type length and pointer
to the actual id. These parameters can be derived from other parameters
such id can be derived from req->ns->XXXid and len can be derived
from type since it has 1:1 mapping.
Remove the len and id arguments and derived those from type and
req->ns->XXXid respectively.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
drivers/nvme/target/admin-cmd.c | 36 ++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index fe6b8aa90b53..e6caa35db4d5 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -589,24 +589,36 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
nvmet_req_complete(req, status);
}
-static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, u8 len,
- void *id, off_t *off)
+static u16 nvmet_copy_ns_identifier(struct nvmet_req *req, u8 type, off_t *off)
{
- struct nvme_ns_id_desc desc = {
- .nidt = type,
- .nidl = len,
- };
+ struct nvme_ns_id_desc desc = { };
+ void *id;
u16 status;
+ switch (type) {
+ case NVME_NIDT_UUID:
+ desc.nidl = NVME_NIDT_UUID_LEN;
+ desc.nidt = NVME_NIDT_UUID;
+ id = &req->ns->uuid;
+ break;
+ case NVME_NIDT_NGUID:
+ desc.nidl = NVME_NIDT_NGUID_LEN;
+ desc.nidt = NVME_NIDT_NGUID;
+ id = &req->ns->nguid;
+ break;
+ default:
+ return NVME_SC_INTERNAL;
+ }
+
status = nvmet_copy_to_sgl(req, *off, &desc, sizeof(desc));
if (status)
return status;
*off += sizeof(desc);
- status = nvmet_copy_to_sgl(req, *off, id, len);
+ status = nvmet_copy_to_sgl(req, *off, id, desc.nidl);
if (status)
return status;
- *off += len;
+ *off += desc.nidl;
return 0;
}
@@ -621,16 +633,12 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req)
goto out;
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);
+ status = nvmet_copy_ns_identifier(req, NVME_NIDT_UUID, &off);
if (status)
goto out;
}
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);
+ status = nvmet_copy_ns_identifier(req, NVME_NIDT_NGUID, &off);
if (status)
goto out;
}
--
2.22.1
More information about the Linux-nvme
mailing list