]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet: remove redundant subsysnqn field from ctrl
authorMax Gurtovoy <mgurtovoy@nvidia.com>
Wed, 24 Sep 2025 20:34:02 +0000 (23:34 +0300)
committerKeith Busch <kbusch@kernel.org>
Mon, 1 Dec 2025 21:45:53 +0000 (13:45 -0800)
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>
drivers/nvme/target/auth.c
drivers/nvme/target/core.c
drivers/nvme/target/nvmet.h
drivers/nvme/target/passthru.c

index b340380f38922abafc65f4a53fa7115f40f16bbc..250d2d650ee9a6af123ca64b2d989b925229c145 100644 (file)
@@ -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));
index 9de429a3f0d893d73c2dc7f4b37e0429a59217a6..da94d1c7699eba8fe9be634a78828671183c2872 100644 (file)
@@ -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);
index 51df72f5e89b72a271ea54124a946fdce94fbc89..209f04adcde618d2d117a736225fd5afcd59b440 100644 (file)
@@ -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;
index 0c361b1e356656e719bf2ab3ba007a02b6953406..96648ec2fadb55aca6760530849f202e035ba39a 100644 (file)
@@ -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) +