nvmet: fill discovery controller sn, fr and mn correctly
authorSagi Grimberg <sagi@grimberg.me>
Thu, 24 Oct 2019 16:55:58 +0000 (09:55 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 4 Nov 2019 17:56:42 +0000 (10:56 -0700)
Discovery controllers need this information as well.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/target/discovery.c

index 7a868c3e8e9567db9194c6dfd7827caf0594edc7..0c2274b21e158643f1f54fc4bf68ed02685d8d70 100644 (file)
@@ -241,6 +241,7 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
 {
        struct nvmet_ctrl *ctrl = req->sq->ctrl;
        struct nvme_id_ctrl *id;
+       const char model[] = "Linux";
        u16 status = 0;
 
        if (!nvmet_check_data_len(req, NVME_IDENTIFY_DATA_SIZE))
@@ -258,8 +259,13 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
                goto out;
        }
 
+       memset(id->sn, ' ', sizeof(id->sn));
+       bin2hex(id->sn, &ctrl->subsys->serial,
+               min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2));
        memset(id->fr, ' ', sizeof(id->fr));
-       strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr));
+       memcpy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1, ' ');
+       memcpy_and_pad(id->fr, sizeof(id->fr),
+                      UTS_RELEASE, strlen(UTS_RELEASE), ' ');
 
        /* no limit on data transfer sizes for now */
        id->mdts = 0;