Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e7f5d2a authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by Jens Axboe
Browse files

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: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 41528f80
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -185,7 +185,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
	id->ssvid = 0;
	id->ssvid = 0;


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


	memset(id->mn, ' ', sizeof(id->mn));
	memset(id->mn, ' ', sizeof(id->mn));
	strncpy((char *)id->mn, "Linux", sizeof(id->mn));
	strncpy((char *)id->mn, "Linux", sizeof(id->mn));
+2 −3
Original line number Original line Diff line number Diff line
@@ -767,9 +767,6 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
	memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
	memcpy(ctrl->subsysnqn, subsysnqn, NVMF_NQN_SIZE);
	memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);
	memcpy(ctrl->hostnqn, hostnqn, NVMF_NQN_SIZE);


	/* generate a random serial number as our controllers are ephemeral: */
	get_random_bytes(&ctrl->serial, sizeof(ctrl->serial));

	kref_init(&ctrl->ref);
	kref_init(&ctrl->ref);
	ctrl->subsys = subsys;
	ctrl->subsys = subsys;


@@ -928,6 +925,8 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
		return NULL;
		return NULL;


	subsys->ver = NVME_VS(1, 3, 0); /* NVMe 1.3.0 */
	subsys->ver = NVME_VS(1, 3, 0); /* NVMe 1.3.0 */
	/* generate a random serial number as our controllers are ephemeral: */
	get_random_bytes(&subsys->serial, sizeof(subsys->serial));


	switch (type) {
	switch (type) {
	case NVME_NQN_NVME:
	case NVME_NQN_NVME:
+1 −1
Original line number Original line Diff line number Diff line
@@ -112,7 +112,6 @@ struct nvmet_ctrl {


	struct mutex		lock;
	struct mutex		lock;
	u64			cap;
	u64			cap;
	u64			serial;
	u32			cc;
	u32			cc;
	u32			csts;
	u32			csts;


@@ -152,6 +151,7 @@ struct nvmet_subsys {
	u16			max_qid;
	u16			max_qid;


	u64			ver;
	u64			ver;
	u64			serial;
	char			*subsysnqn;
	char			*subsysnqn;


	struct config_group	group;
	struct config_group	group;