diff mbox series

[6/7] block: remove the disk argument to delete_partition

Message ID 20200831180239.2372776-7-hch@lst.de
State New, archived
Headers show
Series [1/7] block: remove the alignment_offset field from struct hd_struct | expand

Commit Message

Christoph Hellwig Aug. 31, 2020, 6:02 p.m. UTC
We can trivially derive the gendisk from the hd_struct.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk.h             | 2 +-
 block/genhd.c           | 2 +-
 block/partitions/core.c | 9 +++++----
 3 files changed, 7 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/block/blk.h b/block/blk.h
index 49e2928a163299..3e60ffd3f500e5 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -350,7 +350,7 @@  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 gendisk *disk, struct hd_struct *part);
+void delete_partition(struct hd_struct *part);
 int bdev_add_partition(struct block_device *bdev, int partno,
 		sector_t start, sector_t length);
 int bdev_del_partition(struct block_device *bdev, int partno);
diff --git a/block/genhd.c b/block/genhd.c
index 055ce9cf18358a..2055b5bf637a80 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -913,7 +913,7 @@  void del_gendisk(struct gendisk *disk)
 			     DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
 	while ((part = disk_part_iter_next(&piter))) {
 		invalidate_partition(disk, part->partno);
-		delete_partition(disk, part);
+		delete_partition(part);
 	}
 	disk_part_iter_exit(&piter);
 
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 1150474caca0cf..7af3f8796f0a2c 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -316,8 +316,9 @@  int hd_ref_init(struct hd_struct *part)
  * Must be called either with bd_mutex held, before a disk can be opened or
  * after all disk users are gone.
  */
-void delete_partition(struct gendisk *disk, struct hd_struct *part)
+void delete_partition(struct hd_struct *part)
 {
+	struct gendisk *disk = part_to_disk(part);
 	struct disk_part_tbl *ptbl =
 		rcu_dereference_protected(disk->part_tbl, 1);
 
@@ -325,7 +326,7 @@  void delete_partition(struct gendisk *disk, struct hd_struct *part)
 	 * ->part_tbl is referenced in this part's release handler, so
 	 *  we have to hold the disk device
 	 */
-	get_device(disk_to_dev(part_to_disk(part)));
+	get_device(disk_to_dev(disk));
 	rcu_assign_pointer(ptbl->part[part->partno], NULL);
 	kobject_put(part->holder_dir);
 	device_del(part_to_dev(part));
@@ -548,7 +549,7 @@  int bdev_del_partition(struct block_device *bdev, int partno)
 	invalidate_bdev(bdevp);
 
 	mutex_lock_nested(&bdev->bd_mutex, 1);
-	delete_partition(bdev->bd_disk, part);
+	delete_partition(part);
 	mutex_unlock(&bdev->bd_mutex);
 
 	ret = 0;
@@ -629,7 +630,7 @@  int blk_drop_partitions(struct block_device *bdev)
 
 	disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
 	while ((part = disk_part_iter_next(&piter)))
-		delete_partition(bdev->bd_disk, part);
+		delete_partition(part);
 	disk_part_iter_exit(&piter);
 
 	return 0;