Commit edd17206 authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Keith Busch
Browse files

nvmet: remove redundant subsysnqn field from ctrl



The subsysnqn field in the nvmet controller structure is redundant,
since the subsystem NQN can always be accessed via the controller's
subsystem reference. Remove this field to save memory and avoid
unnecessary duplication.

Signed-off-by: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 7fce856f
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -380,8 +380,8 @@ int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
	ret = crypto_shash_update(shash, buf, 1);
	if (ret)
		goto out;
	ret = crypto_shash_update(shash, ctrl->subsysnqn,
				  strlen(ctrl->subsysnqn));
	ret = crypto_shash_update(shash, ctrl->subsys->subsysnqn,
				  strlen(ctrl->subsys->subsysnqn));
	if (ret)
		goto out;
	ret = crypto_shash_final(shash, response);
@@ -428,7 +428,7 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
	}

	transformed_key = nvme_auth_transform_key(ctrl->ctrl_key,
						ctrl->subsysnqn);
						ctrl->subsys->subsysnqn);
	if (IS_ERR(transformed_key)) {
		ret = PTR_ERR(transformed_key);
		goto out_free_tfm;
@@ -483,8 +483,8 @@ int nvmet_auth_ctrl_hash(struct nvmet_req *req, u8 *response,
	ret = crypto_shash_update(shash, "Controller", 10);
	if (ret)
		goto out;
	ret = crypto_shash_update(shash, ctrl->subsysnqn,
			    strlen(ctrl->subsysnqn));
	ret = crypto_shash_update(shash, ctrl->subsys->subsysnqn,
			    strlen(ctrl->subsys->subsysnqn));
	if (ret)
		goto out;
	ret = crypto_shash_update(shash, buf, 1);
@@ -574,7 +574,7 @@ void nvmet_auth_insert_psk(struct nvmet_sq *sq)
		return;
	}
	ret = nvme_auth_generate_digest(sq->ctrl->shash_id, psk, psk_len,
					sq->ctrl->subsysnqn,
					sq->ctrl->subsys->subsysnqn,
					sq->ctrl->hostnqn, &digest);
	if (ret) {
		pr_warn("%s: ctrl %d qid %d failed to generate digest, error %d\n",
@@ -589,8 +589,10 @@ void nvmet_auth_insert_psk(struct nvmet_sq *sq)
		goto out_free_digest;
	}
#ifdef CONFIG_NVME_TARGET_TCP_TLS
	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsysnqn,
				       sq->ctrl->shash_id, tls_psk, psk_len, digest);
	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn,
				       sq->ctrl->subsys->subsysnqn,
				       sq->ctrl->shash_id, tls_psk, psk_len,
				       digest);
	if (IS_ERR(tls_key)) {
		pr_warn("%s: ctrl %d qid %d failed to refresh key, error %ld\n",
			__func__, sq->ctrl->cntlid, sq->qid, PTR_ERR(tls_key));
+0 −1
Original line number Diff line number Diff line
@@ -1628,7 +1628,6 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args)
	INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler);
	INIT_DELAYED_WORK(&ctrl->ka_work, nvmet_keep_alive_timer);

	memcpy(ctrl->subsysnqn, args->subsysnqn, NVMF_NQN_SIZE);
	memcpy(ctrl->hostnqn, args->hostnqn, NVMF_NQN_SIZE);

	kref_init(&ctrl->ref);
+0 −1
Original line number Diff line number Diff line
@@ -284,7 +284,6 @@ struct nvmet_ctrl {
	__le32			*changed_ns_list;
	u32			nr_changed_ns;

	char			subsysnqn[NVMF_NQN_FIELD_LEN];
	char			hostnqn[NVMF_NQN_FIELD_LEN];

	struct device		*p2p_client;
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
	 * code path with duplicate ctrl subsysnqn. In order to prevent that we
	 * mask the passthru-ctrl subsysnqn with the target ctrl subsysnqn.
	 */
	memcpy(id->subnqn, ctrl->subsysnqn, sizeof(id->subnqn));
	memcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));

	/* use fabric id-ctrl values */
	id->ioccsz = cpu_to_le32((sizeof(struct nvme_command) +