diff mbox series

[40/44] block: pass a block_device to invalidate_partition

Message ID 20201126130422.92945-41-hch@lst.de (mailing list archive)
State New
Headers show
Series [01/44] blk-cgroup: fix a hd_struct leak in blkcg_fill_root_iostats | expand

Commit Message

Christoph Hellwig Nov. 26, 2020, 1:04 p.m. UTC
Pass the block_device actually needed instead of looking it up using
bdget_disk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/genhd.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Jan Kara Nov. 26, 2020, 5:49 p.m. UTC | #1
On Thu 26-11-20 14:04:18, Christoph Hellwig wrote:
> Pass the block_device actually needed instead of looking it up using
> bdget_disk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  block/genhd.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 89cd0ba8e3b84a..28299b24173be1 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -792,14 +792,8 @@ void device_add_disk_no_queue_reg(struct device *parent, struct gendisk *disk)
>  }
>  EXPORT_SYMBOL(device_add_disk_no_queue_reg);
>  
> -static void invalidate_partition(struct gendisk *disk, int partno)
> +static void invalidate_partition(struct block_device *bdev)
>  {
> -	struct block_device *bdev;
> -
> -	bdev = bdget_disk(disk, partno);
> -	if (!bdev)
> -		return;
> -
>  	fsync_bdev(bdev);
>  	__invalidate_device(bdev, true);
>  
> @@ -808,7 +802,6 @@ static void invalidate_partition(struct gendisk *disk, int partno)
>  	 * up any more even if openers still hold references to it.
>  	 */
>  	remove_inode_hash(bdev->bd_inode);
> -	bdput(bdev);
>  }
>  
>  /**
> @@ -853,12 +846,12 @@ void del_gendisk(struct gendisk *disk)
>  	disk_part_iter_init(&piter, disk,
>  			     DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
>  	while ((part = disk_part_iter_next(&piter))) {
> -		invalidate_partition(disk, part->bdev->bd_partno);
> +		invalidate_partition(part->bdev);
>  		delete_partition(part);
>  	}
>  	disk_part_iter_exit(&piter);
>  
> -	invalidate_partition(disk, 0);
> +	invalidate_partition(disk->part0);
>  	set_capacity(disk, 0);
>  	disk->flags &= ~GENHD_FL_UP;
>  	up_write(&bdev_lookup_sem);
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 89cd0ba8e3b84a..28299b24173be1 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -792,14 +792,8 @@  void device_add_disk_no_queue_reg(struct device *parent, struct gendisk *disk)
 }
 EXPORT_SYMBOL(device_add_disk_no_queue_reg);
 
-static void invalidate_partition(struct gendisk *disk, int partno)
+static void invalidate_partition(struct block_device *bdev)
 {
-	struct block_device *bdev;
-
-	bdev = bdget_disk(disk, partno);
-	if (!bdev)
-		return;
-
 	fsync_bdev(bdev);
 	__invalidate_device(bdev, true);
 
@@ -808,7 +802,6 @@  static void invalidate_partition(struct gendisk *disk, int partno)
 	 * up any more even if openers still hold references to it.
 	 */
 	remove_inode_hash(bdev->bd_inode);
-	bdput(bdev);
 }
 
 /**
@@ -853,12 +846,12 @@  void del_gendisk(struct gendisk *disk)
 	disk_part_iter_init(&piter, disk,
 			     DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
 	while ((part = disk_part_iter_next(&piter))) {
-		invalidate_partition(disk, part->bdev->bd_partno);
+		invalidate_partition(part->bdev);
 		delete_partition(part);
 	}
 	disk_part_iter_exit(&piter);
 
-	invalidate_partition(disk, 0);
+	invalidate_partition(disk->part0);
 	set_capacity(disk, 0);
 	disk->flags &= ~GENHD_FL_UP;
 	up_write(&bdev_lookup_sem);