mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	target-devel@vger.kernel.org (open list:SCSI TARGET SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] target: iblock: Use flexible array for per-CPU plugs
Date: Mon, 18 May 2026 17:50:50 -0700	[thread overview]
Message-ID: <20260519005050.627926-1-rosenp@gmail.com> (raw)

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


                 reply	other threads:[~2026-05-19  0:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260519005050.627926-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®