From: Rosen Penev <rosenp@gmail.com>
To: linux-nvme@lists.infradead.org
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <kch@nvidia.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] nvme: target: allocate ana_state with port
Date: Sun, 7 Jun 2026 22:12:23 -0700 [thread overview]
Message-ID: <20260608051223.6884-1-rosenp@gmail.com> (raw)
Use a flexible array member to remove one allocation. Simplifies code
slightly.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/nvme/target/configfs.c | 9 +--------
drivers/nvme/target/nvmet.h | 2 +-
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index b88f897f06e2..2b69ffcfc8df 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -2007,7 +2007,6 @@ static void nvmet_port_release(struct config_item *item)
list_del(&port->global_entry);
key_put(port->keyring);
- kfree(port->ana_state);
kfree(port);
}
@@ -2047,16 +2046,10 @@ static struct config_group *nvmet_ports_make(struct config_group *group,
if (kstrtou16(name, 0, &portid))
return ERR_PTR(-EINVAL);
- port = kzalloc_obj(*port);
+ port = kzalloc_flex(*port, ana_state, NVMET_MAX_ANAGRPS + 1);
if (!port)
return ERR_PTR(-ENOMEM);
- port->ana_state = kzalloc_objs(*port->ana_state, NVMET_MAX_ANAGRPS + 1);
- if (!port->ana_state) {
- kfree(port);
- return ERR_PTR(-ENOMEM);
- }
-
if (IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS) && nvme_keyring_id()) {
port->keyring = key_lookup(nvme_keyring_id());
if (IS_ERR(port->keyring)) {
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 3305a88684ec..aaba745e3c21 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -208,7 +208,6 @@ struct nvmet_port {
struct list_head global_entry;
struct config_group ana_groups_group;
struct nvmet_ana_group ana_default_group;
- enum nvme_ana_state *ana_state;
struct key *keyring;
void *priv;
bool enabled;
@@ -217,6 +216,7 @@ struct nvmet_port {
int mdts;
const struct nvmet_fabrics_ops *tr_ops;
bool pi_enable;
+ enum nvme_ana_state ana_state[];
};
static inline struct nvmet_port *to_nvmet_port(struct config_item *item)
--
2.54.0
next reply other threads:[~2026-06-08 5:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 5:12 Rosen Penev [this message]
2026-06-09 18:44 ` [PATCH] nvme: target: allocate ana_state with port Keith Busch
2026-06-10 5:12 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260608051223.6884-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=hch@lst.de \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox