Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl
@ 2025-09-24 20:34 Max Gurtovoy
  2025-09-24 22:14 ` Keith Busch
  2025-10-03  7:25 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Max Gurtovoy @ 2025-09-24 20:34 UTC (permalink / raw)
  To: hch, linux-nvme, kbusch, sagi, kch; +Cc: israelr, Max Gurtovoy

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: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/nvme/target/auth.c     | 14 +++++++-------
 drivers/nvme/target/core.c     |  1 -
 drivers/nvme/target/nvmet.h    |  1 -
 drivers/nvme/target/passthru.c |  2 +-
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/nvme/target/auth.c b/drivers/nvme/target/auth.c
index b340380f3892..022e94847800 100644
--- a/drivers/nvme/target/auth.c
+++ b/drivers/nvme/target/auth.c
@@ -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,7 +589,7 @@ 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,
+	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",
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 61625d692c90..099a05409ac5 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1654,7 +1654,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);
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 2d29df0f66eb..e5a4571199aa 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -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;
diff --git a/drivers/nvme/target/passthru.c b/drivers/nvme/target/passthru.c
index 0c361b1e3566..96648ec2fadb 100644
--- a/drivers/nvme/target/passthru.c
+++ b/drivers/nvme/target/passthru.c
@@ -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) +
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl
  2025-09-24 20:34 [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl Max Gurtovoy
@ 2025-09-24 22:14 ` Keith Busch
  2025-10-03  7:25 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Keith Busch @ 2025-09-24 22:14 UTC (permalink / raw)
  To: Max Gurtovoy; +Cc: hch, linux-nvme, sagi, kch, israelr

On Wed, Sep 24, 2025 at 11:34:02PM +0300, Max Gurtovoy wrote:
> 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.

Looks good, applied to nvme-6.18.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl
  2025-09-24 20:34 [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl Max Gurtovoy
  2025-09-24 22:14 ` Keith Busch
@ 2025-10-03  7:25 ` Christoph Hellwig
  2025-10-08 11:37   ` Max Gurtovoy
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-10-03  7:25 UTC (permalink / raw)
  To: Max Gurtovoy; +Cc: hch, linux-nvme, kbusch, sagi, kch, israelr

On Wed, Sep 24, 2025 at 11:34:02PM +0300, Max Gurtovoy wrote:
>  #ifdef CONFIG_NVME_TARGET_TCP_TLS
> -	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsysnqn,
> +	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsys->subsysnqn,

Please fix the overly long line here (and in the next line) while touching
this.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl
  2025-10-03  7:25 ` Christoph Hellwig
@ 2025-10-08 11:37   ` Max Gurtovoy
  0 siblings, 0 replies; 4+ messages in thread
From: Max Gurtovoy @ 2025-10-08 11:37 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-nvme, kbusch, sagi, kch, israelr


On 03/10/2025 10:25, Christoph Hellwig wrote:
> On Wed, Sep 24, 2025 at 11:34:02PM +0300, Max Gurtovoy wrote:
>>   #ifdef CONFIG_NVME_TARGET_TCP_TLS
>> -	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsysnqn,
>> +	tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsys->subsysnqn,
> Please fix the overly long line here (and in the next line) while touching
> this.

this was already applied to nvme-6.19.

I can send a dedicated patch for the long lines if needed.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-08 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 20:34 [PATCH 1/1] nvmet: remove redundant subsysnqn field from ctrl Max Gurtovoy
2025-09-24 22:14 ` Keith Busch
2025-10-03  7:25 ` Christoph Hellwig
2025-10-08 11:37   ` Max Gurtovoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox