All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Stefan Haberland <sth@linux.ibm.com>,
	Jan Hoeppner <hoeppner@linux.ibm.com>,
	linux-block@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 03/10] block: cleanup hd_struct freeing
Date: Wed,  8 Apr 2020 21:44:32 +0200	[thread overview]
Message-ID: <20200408194439.1580699-4-hch@lst.de> (raw)
In-Reply-To: <20200408194439.1580699-1-hch@lst.de>

Move hd_ref_init out of line as there it isn't anywhere near a fast path,
and rename the rcu ref freeing callbacks to be more descriptive.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk.h             | 10 +---------
 block/partitions/core.c | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/block/blk.h b/block/blk.h
index 0cbf64108922..b1a0b8cd87f0 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -389,7 +389,6 @@ char *disk_name(struct gendisk *hd, int partno, char *buf);
 #define ADDPART_FLAG_NONE	0
 #define ADDPART_FLAG_RAID	1
 #define ADDPART_FLAG_WHOLEDISK	2
-void __delete_partition(struct percpu_ref *ref);
 void delete_partition(struct gendisk *disk, struct hd_struct *part);
 int bdev_add_partition(struct block_device *bdev, int partno,
 		sector_t start, sector_t length);
@@ -397,14 +396,7 @@ int bdev_del_partition(struct block_device *bdev, int partno);
 int bdev_resize_partition(struct block_device *bdev, int partno,
 		sector_t start, sector_t length);
 int disk_expand_part_tbl(struct gendisk *disk, int target);
-
-static inline int hd_ref_init(struct hd_struct *part)
-{
-	if (percpu_ref_init(&part->ref, __delete_partition, 0,
-				GFP_KERNEL))
-		return -ENOMEM;
-	return 0;
-}
+int hd_ref_init(struct hd_struct *part);
 
 static inline void hd_struct_get(struct hd_struct *part)
 {
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 0b1b67f50652..13d61ed76e0e 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -274,10 +274,10 @@ struct device_type part_type = {
 	.uevent		= part_uevent,
 };
 
-static void delete_partition_work_fn(struct work_struct *work)
+static void hd_struct_free_work(struct work_struct *work)
 {
-	struct hd_struct *part = container_of(to_rcu_work(work), struct hd_struct,
-					rcu_work);
+	struct hd_struct *part =
+		container_of(to_rcu_work(work), struct hd_struct, rcu_work);
 
 	part->start_sect = 0;
 	part->nr_sects = 0;
@@ -285,13 +285,21 @@ static void delete_partition_work_fn(struct work_struct *work)
 	put_device(part_to_dev(part));
 }
 
-void __delete_partition(struct percpu_ref *ref)
+static void hd_struct_free(struct percpu_ref *ref)
 {
 	struct hd_struct *part = container_of(ref, struct hd_struct, ref);
-	INIT_RCU_WORK(&part->rcu_work, delete_partition_work_fn);
+
+	INIT_RCU_WORK(&part->rcu_work, hd_struct_free_work);
 	queue_rcu_work(system_wq, &part->rcu_work);
 }
 
+int hd_ref_init(struct hd_struct *part)
+{
+	if (percpu_ref_init(&part->ref, hd_struct_free, 0, GFP_KERNEL))
+		return -ENOMEM;
+	return 0;
+}
+
 /*
  * Must be called either with bd_mutex held, before a disk can be opened or
  * after all disk users are gone.
-- 
2.25.1


  parent reply	other threads:[~2020-04-08 19:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 19:44 Christoph Hellwig
2020-04-08 19:44 ` [PATCH 01/10] block: refactor blkpg_ioctl Christoph Hellwig
2020-04-09 11:21   ` Johannes Thumshirn
2020-04-08 19:44 ` [PATCH 02/10] block: pass a hd_struct to delete_partition Christoph Hellwig
2020-04-09 11:27   ` Johannes Thumshirn
2020-04-09 12:02   ` Johannes Thumshirn
2020-04-08 19:44 ` Christoph Hellwig [this message]
2020-04-09 11:30   ` [PATCH 03/10] block: cleanup hd_struct freeing Johannes Thumshirn
2020-04-13 13:41     ` Christoph Hellwig
2020-04-08 19:44 ` [PATCH 04/10] block: remove hd_struct_kill Christoph Hellwig
2020-04-09 11:31   ` Johannes Thumshirn
2020-04-08 19:44 ` [PATCH 05/10] block: remove the disk argument from blk_drop_partitions Christoph Hellwig
2020-04-09 11:33   ` Johannes Thumshirn
2020-04-08 19:44 ` [PATCH 06/10] dasd: use blk_drop_partitions instead of badly reimplementing it Christoph Hellwig
2020-04-08 19:44 ` [PATCH 07/10] block: don't call invalidate_partition from blk_drop_partitions Christoph Hellwig
2020-04-08 19:44 ` [PATCH 08/10] block: simplify block device syncing in bdev_del_partition Christoph Hellwig
2020-04-09 12:01   ` Johannes Thumshirn
2020-04-08 19:44 ` [PATCH 09/10] block: mark invalidate_partition static Christoph Hellwig
2020-04-09 12:04   ` Johannes Thumshirn
2020-04-08 19:44 ` [PATCH 10/10] block: fold bdev_unhash_inode into invalidate_partition Christoph Hellwig
2020-04-09 12:06   ` Johannes Thumshirn
2020-04-14  7:28 more partition handling cleanups v2 Christoph Hellwig
2020-04-14  7:28 ` [PATCH 03/10] block: cleanup hd_struct freeing 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=20200408194439.1580699-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=hoeppner@linux.ibm.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sth@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.