target: iblock: Use flexible array for per-CPU plugs
Subsystems (2)
PATCH 1/1 target: iblock: Use flexible array for per-CPU plugs
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 <[email protected]>
--- drivers/target/target_core_iblock.c | 11 +---------- drivers/target/target_core_iblock.h | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/target/target_core_iblock.c +1 -10
@@ -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); }
drivers/target/target_core_iblock.h +1 -1
@@ -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 */
Signature · 1 line
2.54.0