]> www.infradead.org Git - users/hch/block.git/commitdiff
block: remove the disk argument to delete_partition
authorChristoph Hellwig <hch@lst.de>
Tue, 30 Jun 2020 10:05:15 +0000 (12:05 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 31 Aug 2020 17:59:07 +0000 (19:59 +0200)
We can trivially derive the gendisk from the hd_struct.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk.h
block/genhd.c
block/partitions/core.c

index 49e2928a163299cf2729850bdeed8c18e35b98d6..3e60ffd3f500e5e96f5f8860dcb630dfc1361705 100644 (file)
@@ -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);
index 055ce9cf18358af9e365b1b274d5457a12e2956a..2055b5bf637a80c5719d21bd9c78357b8e8ee608 100644 (file)
@@ -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);
 
index 1150474caca0cf7cc616d3f09fbb8089318388c5..7af3f8796f0a2ce2b398b5db524f167bd9a3a7b4 100644 (file)
@@ -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;