diff mbox series

[02/14] block: switch register_disk to use blkdev_get_by_dev

Message ID 20200917165720.3285256-3-hch@lst.de
State New, archived
Headers show
Series [01/14] block: move the NEED_PART_SCAN flag to struct gendisk | expand

Commit Message

Christoph Hellwig Sept. 17, 2020, 4:57 p.m. UTC
Use blkdev_get_by_dev instead of open coding it using bdget_disk +
blkdev_get.

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

Comments

Sergei Shtylyov Sept. 18, 2020, 8:52 a.m. UTC | #1
Hello!

On 17.09.2020 19:57, Christoph Hellwig wrote:

> Use blkdev_get_by_dev instead of open coding it using bdget_disk +
> blkdev_get.

    I don't see where you are removing bdget_disk() call (situated just before
the below code?)...

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/genhd.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 7b56203c90a303..f778716fac6cde 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -732,10 +732,9 @@ static void register_disk(struct device *parent, struct gendisk *disk,
>   		goto exit;
>   
>   	set_bit(GD_NEED_PART_SCAN, &disk->state);
> -	err = blkdev_get(bdev, FMODE_READ, NULL);
> -	if (err < 0)
> -		goto exit;
> -	blkdev_put(bdev, FMODE_READ);
> +	bdev = blkdev_get_by_dev(disk_devt(disk), FMODE_READ, NULL);
> +	if (!IS_ERR(bdev))
> +		blkdev_put(bdev, FMODE_READ);
>   
>   exit:
>   	/* announce disk after possible partitions are created */

MBR, Sergei
Christoph Hellwig Sept. 19, 2020, 5:15 a.m. UTC | #2
On Fri, Sep 18, 2020 at 11:52:39AM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 17.09.2020 19:57, Christoph Hellwig wrote:
>
>> Use blkdev_get_by_dev instead of open coding it using bdget_disk +
>> blkdev_get.
>
>    I don't see where you are removing bdget_disk() call (situated just before
> the below code?)...

Indeed.  That's what you get for a messy last minute rebase.. :(
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 7b56203c90a303..f778716fac6cde 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -732,10 +732,9 @@  static void register_disk(struct device *parent, struct gendisk *disk,
 		goto exit;
 
 	set_bit(GD_NEED_PART_SCAN, &disk->state);
-	err = blkdev_get(bdev, FMODE_READ, NULL);
-	if (err < 0)
-		goto exit;
-	blkdev_put(bdev, FMODE_READ);
+	bdev = blkdev_get_by_dev(disk_devt(disk), FMODE_READ, NULL);
+	if (!IS_ERR(bdev))
+		blkdev_put(bdev, FMODE_READ);
 
 exit:
 	/* announce disk after possible partitions are created */