diff mbox series

[27/44] block: simplify part_to_disk

Message ID 20201126130422.92945-28-hch@lst.de (mailing list archive)
State New, archived
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
Now that struct hd_struct has a block_device pointer use that to
find the disk.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tejun Heo <tj@kernel.org>
---
 include/linux/genhd.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Jan Kara Nov. 26, 2020, 4:36 p.m. UTC | #1
On Thu 26-11-20 14:04:05, Christoph Hellwig wrote:
> Now that struct hd_struct has a block_device pointer use that to
> find the disk.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Acked-by: Tejun Heo <tj@kernel.org>

Looks good to me. You can add:

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

								Honza

> ---
>  include/linux/genhd.h | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 42a51653c7303e..6ba91ee54cb2f6 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -218,13 +218,9 @@ struct gendisk {
>  
>  static inline struct gendisk *part_to_disk(struct hd_struct *part)
>  {
> -	if (likely(part)) {
> -		if (part->partno)
> -			return dev_to_disk(part_to_dev(part)->parent);
> -		else
> -			return dev_to_disk(part_to_dev(part));
> -	}
> -	return NULL;
> +	if (unlikely(!part))
> +		return NULL;
> +	return part->bdev->bd_disk;
>  }
>  
>  static inline int disk_max_parts(struct gendisk *disk)
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 42a51653c7303e..6ba91ee54cb2f6 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -218,13 +218,9 @@  struct gendisk {
 
 static inline struct gendisk *part_to_disk(struct hd_struct *part)
 {
-	if (likely(part)) {
-		if (part->partno)
-			return dev_to_disk(part_to_dev(part)->parent);
-		else
-			return dev_to_disk(part_to_dev(part));
-	}
-	return NULL;
+	if (unlikely(!part))
+		return NULL;
+	return part->bdev->bd_disk;
 }
 
 static inline int disk_max_parts(struct gendisk *disk)