dm: Convert to bdev_open_by_dev()
Convert device mapper to use bdev_open_by_dev() and pass the handle around. CC: Alasdair Kergon <agk@redhat.com> CC: Mike Snitzer <snitzer@kernel.org> CC: dm-devel@redhat.com Acked-by: Christoph Hellwig <hch@lst.de> Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230927093442.25915-10-jack@suse.cz Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
631b001fd6
commit
c2fce61fb2
@ -724,7 +724,7 @@ static struct table_device *open_table_device(struct mapped_device *md,
|
|||||||
dev_t dev, blk_mode_t mode)
|
dev_t dev, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct table_device *td;
|
struct table_device *td;
|
||||||
struct block_device *bdev;
|
struct bdev_handle *bdev_handle;
|
||||||
u64 part_off;
|
u64 part_off;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -733,9 +733,9 @@ static struct table_device *open_table_device(struct mapped_device *md,
|
|||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
refcount_set(&td->count, 1);
|
refcount_set(&td->count, 1);
|
||||||
|
|
||||||
bdev = blkdev_get_by_dev(dev, mode, _dm_claim_ptr, NULL);
|
bdev_handle = bdev_open_by_dev(dev, mode, _dm_claim_ptr, NULL);
|
||||||
if (IS_ERR(bdev)) {
|
if (IS_ERR(bdev_handle)) {
|
||||||
r = PTR_ERR(bdev);
|
r = PTR_ERR(bdev_handle);
|
||||||
goto out_free_td;
|
goto out_free_td;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,20 +745,22 @@ static struct table_device *open_table_device(struct mapped_device *md,
|
|||||||
* called.
|
* called.
|
||||||
*/
|
*/
|
||||||
if (md->disk->slave_dir) {
|
if (md->disk->slave_dir) {
|
||||||
r = bd_link_disk_holder(bdev, md->disk);
|
r = bd_link_disk_holder(bdev_handle->bdev, md->disk);
|
||||||
if (r)
|
if (r)
|
||||||
goto out_blkdev_put;
|
goto out_blkdev_put;
|
||||||
}
|
}
|
||||||
|
|
||||||
td->dm_dev.mode = mode;
|
td->dm_dev.mode = mode;
|
||||||
td->dm_dev.bdev = bdev;
|
td->dm_dev.bdev = bdev_handle->bdev;
|
||||||
td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev, &part_off, NULL, NULL);
|
td->dm_dev.bdev_handle = bdev_handle;
|
||||||
|
td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev, &part_off,
|
||||||
|
NULL, NULL);
|
||||||
format_dev_t(td->dm_dev.name, dev);
|
format_dev_t(td->dm_dev.name, dev);
|
||||||
list_add(&td->list, &md->table_devices);
|
list_add(&td->list, &md->table_devices);
|
||||||
return td;
|
return td;
|
||||||
|
|
||||||
out_blkdev_put:
|
out_blkdev_put:
|
||||||
blkdev_put(bdev, _dm_claim_ptr);
|
bdev_release(bdev_handle);
|
||||||
out_free_td:
|
out_free_td:
|
||||||
kfree(td);
|
kfree(td);
|
||||||
return ERR_PTR(r);
|
return ERR_PTR(r);
|
||||||
@ -771,7 +773,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md
|
|||||||
{
|
{
|
||||||
if (md->disk->slave_dir)
|
if (md->disk->slave_dir)
|
||||||
bd_unlink_disk_holder(td->dm_dev.bdev, md->disk);
|
bd_unlink_disk_holder(td->dm_dev.bdev, md->disk);
|
||||||
blkdev_put(td->dm_dev.bdev, _dm_claim_ptr);
|
bdev_release(td->dm_dev.bdev_handle);
|
||||||
put_dax(td->dm_dev.dax_dev);
|
put_dax(td->dm_dev.dax_dev);
|
||||||
list_del(&td->list);
|
list_del(&td->list);
|
||||||
kfree(td);
|
kfree(td);
|
||||||
|
@ -165,6 +165,7 @@ void dm_error(const char *message);
|
|||||||
|
|
||||||
struct dm_dev {
|
struct dm_dev {
|
||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
|
struct bdev_handle *bdev_handle;
|
||||||
struct dax_device *dax_dev;
|
struct dax_device *dax_dev;
|
||||||
blk_mode_t mode;
|
blk_mode_t mode;
|
||||||
char name[16];
|
char name[16];
|
||||||
|
Loading…
Reference in New Issue
Block a user