[05/10] block: remove the disk argument from blk_drop_partitions
diff mbox series

Message ID 20200408194439.1580699-6-hch@lst.de
State New
Headers show
Series
  • [01/10] block: refactor blkpg_ioctl
Related show

Commit Message

Christoph Hellwig April 8, 2020, 7:44 p.m. UTC
The gendisk can be trivially deducted from the block_device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/partitions/core.c | 10 +++++-----
 fs/block_dev.c          |  2 +-
 include/linux/genhd.h   |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

Johannes Thumshirn April 9, 2020, 11:33 a.m. UTC | #1
On 08/04/2020 21:45, Christoph Hellwig wrote:
> -int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev)
> +int blk_drop_partitions(struct block_device *bdev)
>   {
>   	struct disk_part_iter piter;
>   	struct hd_struct *part;
>   	int res;
>   
> -	if (!disk_part_scan_enabled(disk))
> +	if (!disk_part_scan_enabled(bdev->bd_disk))
>   		return 0;
>   	if (bdev->bd_part_count || bdev->bd_openers)
>   		return -EBUSY;
> -	res = invalidate_partition(disk, 0);
> +	res = invalidate_partition(bdev->bd_disk, 0);
>   	if (res)
>   		return res;
>   
> -	disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
> +	disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
>   	while ((part = disk_part_iter_next(&piter)))
> -		delete_partition(disk, part);
> +		delete_partition(bdev->bd_disk, part);
>   	disk_part_iter_exit(&piter);

I would have probably added a local 'struct gendisk *disk' variable, but 
that's personal preference I guess.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Patch
diff mbox series

diff --git a/block/partitions/core.c b/block/partitions/core.c
index f10968b601be..e0ff8a49279f 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -603,23 +603,23 @@  static bool disk_unlock_native_capacity(struct gendisk *disk)
 	}
 }
 
-int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev)
+int blk_drop_partitions(struct block_device *bdev)
 {
 	struct disk_part_iter piter;
 	struct hd_struct *part;
 	int res;
 
-	if (!disk_part_scan_enabled(disk))
+	if (!disk_part_scan_enabled(bdev->bd_disk))
 		return 0;
 	if (bdev->bd_part_count || bdev->bd_openers)
 		return -EBUSY;
-	res = invalidate_partition(disk, 0);
+	res = invalidate_partition(bdev->bd_disk, 0);
 	if (res)
 		return res;
 
-	disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
+	disk_part_iter_init(&piter, bdev->bd_disk, DISK_PITER_INCL_EMPTY);
 	while ((part = disk_part_iter_next(&piter)))
-		delete_partition(disk, part);
+		delete_partition(bdev->bd_disk, part);
 	disk_part_iter_exit(&piter);
 
 	return 0;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 52b6f646cdbd..9c8de54fa0c9 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1517,7 +1517,7 @@  int bdev_disk_changed(struct block_device *bdev, bool invalidate)
 	lockdep_assert_held(&bdev->bd_mutex);
 
 rescan:
-	ret = blk_drop_partitions(disk, bdev);
+	ret = blk_drop_partitions(bdev);
 	if (ret)
 		return ret;
 
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 9b3fffdf4011..058d895544c7 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -339,7 +339,7 @@  extern dev_t blk_lookup_devt(const char *name, int partno);
 
 int bdev_disk_changed(struct block_device *bdev, bool invalidate);
 int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);
-int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev);
+int blk_drop_partitions(struct block_device *bdev);
 extern void printk_all_partitions(void);
 
 extern struct gendisk *__alloc_disk_node(int minors, int node_id);