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

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: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Max Gurtovoy and committed by
Keith Busch
edd17206 7fce856f

+11 -11
+10 -8
drivers/nvme/target/auth.c
··· 380 380 ret = crypto_shash_update(shash, buf, 1); 381 381 if (ret) 382 382 goto out; 383 - ret = crypto_shash_update(shash, ctrl->subsysnqn, 384 - strlen(ctrl->subsysnqn)); 383 + ret = crypto_shash_update(shash, ctrl->subsys->subsysnqn, 384 + strlen(ctrl->subsys->subsysnqn)); 385 385 if (ret) 386 386 goto out; 387 387 ret = crypto_shash_final(shash, response); ··· 428 428 } 429 429 430 430 transformed_key = nvme_auth_transform_key(ctrl->ctrl_key, 431 - ctrl->subsysnqn); 431 + ctrl->subsys->subsysnqn); 432 432 if (IS_ERR(transformed_key)) { 433 433 ret = PTR_ERR(transformed_key); 434 434 goto out_free_tfm; ··· 483 483 ret = crypto_shash_update(shash, "Controller", 10); 484 484 if (ret) 485 485 goto out; 486 - ret = crypto_shash_update(shash, ctrl->subsysnqn, 487 - strlen(ctrl->subsysnqn)); 486 + ret = crypto_shash_update(shash, ctrl->subsys->subsysnqn, 487 + strlen(ctrl->subsys->subsysnqn)); 488 488 if (ret) 489 489 goto out; 490 490 ret = crypto_shash_update(shash, buf, 1); ··· 574 574 return; 575 575 } 576 576 ret = nvme_auth_generate_digest(sq->ctrl->shash_id, psk, psk_len, 577 - sq->ctrl->subsysnqn, 577 + sq->ctrl->subsys->subsysnqn, 578 578 sq->ctrl->hostnqn, &digest); 579 579 if (ret) { 580 580 pr_warn("%s: ctrl %d qid %d failed to generate digest, error %d\n", ··· 589 589 goto out_free_digest; 590 590 } 591 591 #ifdef CONFIG_NVME_TARGET_TCP_TLS 592 - tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, sq->ctrl->subsysnqn, 593 - sq->ctrl->shash_id, tls_psk, psk_len, digest); 592 + tls_key = nvme_tls_psk_refresh(NULL, sq->ctrl->hostnqn, 593 + sq->ctrl->subsys->subsysnqn, 594 + sq->ctrl->shash_id, tls_psk, psk_len, 595 + digest); 594 596 if (IS_ERR(tls_key)) { 595 597 pr_warn("%s: ctrl %d qid %d failed to refresh key, error %ld\n", 596 598 __func__, sq->ctrl->cntlid, sq->qid, PTR_ERR(tls_key));
-1
drivers/nvme/target/core.c
··· 1628 1628 INIT_WORK(&ctrl->fatal_err_work, nvmet_fatal_error_handler); 1629 1629 INIT_DELAYED_WORK(&ctrl->ka_work, nvmet_keep_alive_timer); 1630 1630 1631 - memcpy(ctrl->subsysnqn, args->subsysnqn, NVMF_NQN_SIZE); 1632 1631 memcpy(ctrl->hostnqn, args->hostnqn, NVMF_NQN_SIZE); 1633 1632 1634 1633 kref_init(&ctrl->ref);
-1
drivers/nvme/target/nvmet.h
··· 284 284 __le32 *changed_ns_list; 285 285 u32 nr_changed_ns; 286 286 287 - char subsysnqn[NVMF_NQN_FIELD_LEN]; 288 287 char hostnqn[NVMF_NQN_FIELD_LEN]; 289 288 290 289 struct device *p2p_client;
+1 -1
drivers/nvme/target/passthru.c
··· 150 150 * code path with duplicate ctrl subsysnqn. In order to prevent that we 151 151 * mask the passthru-ctrl subsysnqn with the target ctrl subsysnqn. 152 152 */ 153 - memcpy(id->subnqn, ctrl->subsysnqn, sizeof(id->subnqn)); 153 + memcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); 154 154 155 155 /* use fabric id-ctrl values */ 156 156 id->ioccsz = cpu_to_le32((sizeof(struct nvme_command) +