mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-04 11:24:04 +08:00
block: Use bdev_open_by_dev() in disk_scan_partitions() and blkdev_bszset()
Convert disk_scan_partitions() and blkdev_bszset() to use bdev_open_by_dev(). Acked-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230927093442.25915-3-jack@suse.cz Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
841dd789b8
commit
acb083b555
@ -342,7 +342,7 @@ EXPORT_SYMBOL_GPL(disk_uevent);
|
|||||||
|
|
||||||
int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
|
int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct block_device *bdev;
|
struct bdev_handle *handle;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN))
|
if (disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN))
|
||||||
@ -366,12 +366,12 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_bit(GD_NEED_PART_SCAN, &disk->state);
|
set_bit(GD_NEED_PART_SCAN, &disk->state);
|
||||||
bdev = blkdev_get_by_dev(disk_devt(disk), mode & ~BLK_OPEN_EXCL, NULL,
|
handle = bdev_open_by_dev(disk_devt(disk), mode & ~BLK_OPEN_EXCL, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (IS_ERR(bdev))
|
if (IS_ERR(handle))
|
||||||
ret = PTR_ERR(bdev);
|
ret = PTR_ERR(handle);
|
||||||
else
|
else
|
||||||
blkdev_put(bdev, NULL);
|
bdev_release(handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If blkdev_get_by_dev() failed early, GD_NEED_PART_SCAN is still set,
|
* If blkdev_get_by_dev() failed early, GD_NEED_PART_SCAN is still set,
|
||||||
|
@ -467,6 +467,7 @@ static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode,
|
|||||||
int __user *argp)
|
int __user *argp)
|
||||||
{
|
{
|
||||||
int ret, n;
|
int ret, n;
|
||||||
|
struct bdev_handle *handle;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
if (!capable(CAP_SYS_ADMIN))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
@ -478,10 +479,11 @@ static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode,
|
|||||||
if (mode & BLK_OPEN_EXCL)
|
if (mode & BLK_OPEN_EXCL)
|
||||||
return set_blocksize(bdev, n);
|
return set_blocksize(bdev, n);
|
||||||
|
|
||||||
if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL)))
|
handle = bdev_open_by_dev(bdev->bd_dev, mode, &bdev, NULL);
|
||||||
|
if (IS_ERR(handle))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
ret = set_blocksize(bdev, n);
|
ret = set_blocksize(bdev, n);
|
||||||
blkdev_put(bdev, &bdev);
|
bdev_release(handle);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user