Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvmet: Move serial number from controller to subsystem

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>

authored by

Johannes Thumshirn and committed by
Jens Axboe
2e7f5d2a 41528f80

+4 -5
+1 -1
drivers/nvme/target/admin-cmd.c
··· 185 185 id->ssvid = 0; 186 186 187 187 memset(id->sn, ' ', sizeof(id->sn)); 188 - snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->serial); 188 + snprintf(id->sn, sizeof(id->sn), "%llx", ctrl->subsys->serial); 189 189 190 190 memset(id->mn, ' ', sizeof(id->mn)); 191 191 strncpy((char *)id->mn, "Linux", sizeof(id->mn));
+2 -3
drivers/nvme/target/core.c
··· 767 767 memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE); 768 768 memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE); 769 769 770 - /* generate a random serial number as our controllers are ephemeral: */ 771 - get_random_bytes(&ctrl->serial, sizeof(ctrl->serial)); 772 - 773 770 kref_init(&ctrl->ref); 774 771 ctrl->subsys = subsys; 775 772 ··· 925 928 return NULL; 926 929 927 930 subsys->ver = NVME_VS(1, 3, 0); /* NVMe 1.3.0 */ 931 + /* generate a random serial number as our controllers are ephemeral: */ 932 + get_random_bytes(&subsys->serial, sizeof(subsys->serial)); 928 933 929 934 switch (type) { 930 935 case NVME_NQN_NVME:
+1 -1
drivers/nvme/target/nvmet.h
··· 112 112 113 113 struct mutex lock; 114 114 u64 cap; 115 - u64 serial; 116 115 u32 cc; 117 116 u32 csts; 118 117 ··· 151 152 u16 max_qid; 152 153 153 154 u64 ver; 155 + u64 serial; 154 156 char *subsysnqn; 155 157 156 158 struct config_group group;