nvmet: remove redundant subsysnqn field from ctrl
Subsystems (3)
PATCH 1/1 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.
--- 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(-)
drivers/nvme/target/auth.c +7 -7
@@ -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",
drivers/nvme/target/core.c +0 -1
@@ -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);
drivers/nvme/target/nvmet.h +0 -1
@@ -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;
drivers/nvme/target/passthru.c +1 -1
@@ -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) +
Signature · 1 line
2.18.1
Keith Busch
maintainerQuoted 4 lines · 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.
Looks good, applied to nvme-6.18.
Christoph Hellwig
maintainerdrivers/nvme/target/auth.c void nvmet_auth_insert_psk(struct nvmet_sq *sq) · line 592
Quoted 3 lines · Max Gurtovoy
#ifdef
CONFIG_NVME_TARGET_TCP_TLSdrivers/nvme/target/auth.c +1
-1- 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.
Quoted 6 lines · Christoph Hellwig
drivers/nvme/target/auth.c void nvmet_auth_insert_psk(struct nvmet_sq *sq) · line 592
Quoted 3 lines · Max Gurtovoy
#ifdef CONFIG_NVME_TARGET_TCP_TLSdrivers/nvme/target/auth.c +1
-1- 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.