Skip to content

Commit 1e38f8e

Browse files
Johannes Thumshirngregkh
authored andcommitted
nvmet: Move serial number from controller to subsystem
commit 2e7f5d2 upstream. The NVMe specification defines the serial number as: "Serial Number (SN): Contains the serial number for the NVM subsystem that is assigned by the vendor as an ASCII string. Refer to section 7.10 for unique identifier requirements. Refer to section 1.5 for ASCII string requirements" So move it from the controller to the subsystem, where it belongs. Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 077c9e2 commit 1e38f8e

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/nvme/target/admin-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
183183
id->ssvid = 0;
184184

185185
memset(id->sn, ' ', sizeof(id->sn));
186-
snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->serial);
186+
snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->subsys->serial);
187187

188188
memset(id->mn, ' ', sizeof(id->mn));
189189
strncpy((char *)id->mn, "Linux", sizeof(id->mn));

drivers/nvme/target/core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,6 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
743743
memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
744744
memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
745745

746-
/* generate a random serial number as our controllers are ephemeral: */
747-
get_random_bytes(&ctrl->serial, sizeof(ctrl->serial));
748-
749746
kref_init(&ctrl->ref);
750747
ctrl->subsys = subsys;
751748

@@ -904,6 +901,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
904901
return NULL;
905902

906903
subsys->ver = NVME_VS(1, 2, 1); /* NVMe 1.2.1 */
904+
/* generate a random serial number as our controllers are ephemeral: */
905+
get_random_bytes(&subsys->serial, sizeof(subsys->serial));
907906

908907
switch (type) {
909908
case NVME_NQN_NVME:

drivers/nvme/target/nvmet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ struct nvmet_ctrl {
110110

111111
struct mutex lock;
112112
u64 cap;
113-
u64 serial;
114113
u32 cc;
115114
u32 csts;
116115

@@ -151,6 +150,7 @@ struct nvmet_subsys {
151150
u16 max_qid;
152151

153152
u64 ver;
153+
u64 serial;
154154
char *subsysnqn;
155155

156156
struct config_group group;

0 commit comments

Comments
 (0)