* [PATCH] target: iblock: Use flexible array for per-CPU plugs
@ 2026-05-19 0:50 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-05-19 0:50 UTC (permalink / raw)
To: linux-scsi; +Cc: Martin K. Petersen, open list:SCSI TARGET SUBSYSTEM, open list
Store the per-CPU iblock plug array in the iblock_dev allocation
instead of allocating it separately.
This keeps the plug storage tied to the iblock device lifetime and
simplifies the allocation and RCU cleanup paths.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/target/target_core_iblock.c | 11 +----------
drivers/target/target_core_iblock.h | 2 +-
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 1087d1d17c36..985197f0df26 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -59,24 +59,16 @@ static struct se_device *iblock_alloc_device(struct se_hba *hba, const char *nam
{
struct iblock_dev *ib_dev = NULL;
- ib_dev = kzalloc_obj(struct iblock_dev);
+ ib_dev = kzalloc_flex(*ib_dev, ibd_plug, nr_cpu_ids);
if (!ib_dev) {
pr_err("Unable to allocate struct iblock_dev\n");
return NULL;
}
ib_dev->ibd_exclusive = true;
- ib_dev->ibd_plug = kzalloc_objs(*ib_dev->ibd_plug, nr_cpu_ids);
- if (!ib_dev->ibd_plug)
- goto free_dev;
-
pr_debug( "IBLOCK: Allocated ib_dev for %s\n", name);
return &ib_dev->dev;
-
-free_dev:
- kfree(ib_dev);
- return NULL;
}
static bool iblock_configure_unmap(struct se_device *dev)
@@ -189,7 +181,6 @@ static void iblock_dev_call_rcu(struct rcu_head *p)
struct se_device *dev = container_of(p, struct se_device, rcu_head);
struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
- kfree(ib_dev->ibd_plug);
kfree(ib_dev);
}
diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h
index e2f28a69a11c..849c948368bc 100644
--- a/drivers/target/target_core_iblock.h
+++ b/drivers/target/target_core_iblock.h
@@ -35,7 +35,7 @@ struct iblock_dev {
struct file *ibd_bdev_file;
bool ibd_readonly;
bool ibd_exclusive;
- struct iblock_dev_plug *ibd_plug;
+ struct iblock_dev_plug ibd_plug[];
} ____cacheline_aligned;
#endif /* TARGET_CORE_IBLOCK_H */
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-19 0:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-19 0:50 [PATCH] target: iblock: Use flexible array for per-CPU plugs Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®