Commit a28d893e authored by Christian Brauner's avatar Christian Brauner
parent 190f676a
...@@ -726,7 +726,8 @@ static struct table_device *open_table_device(struct mapped_device *md, ...@@ -726,7 +726,8 @@ 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 bdev_handle *bdev_handle; struct file *bdev_file;
struct block_device *bdev;
u64 part_off; u64 part_off;
int r; int r;
...@@ -735,34 +736,36 @@ static struct table_device *open_table_device(struct mapped_device *md, ...@@ -735,34 +736,36 @@ 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_handle = bdev_open_by_dev(dev, mode, _dm_claim_ptr, NULL); bdev_file = bdev_file_open_by_dev(dev, mode, _dm_claim_ptr, NULL);
if (IS_ERR(bdev_handle)) { if (IS_ERR(bdev_file)) {
r = PTR_ERR(bdev_handle); r = PTR_ERR(bdev_file);
goto out_free_td; goto out_free_td;
} }
bdev = file_bdev(bdev_file);
/* /*
* We can be called before the dm disk is added. In that case we can't * We can be called before the dm disk is added. In that case we can't
* register the holder relation here. It will be done once add_disk was * register the holder relation here. It will be done once add_disk was
* called. * called.
*/ */
if (md->disk->slave_dir) { if (md->disk->slave_dir) {
r = bd_link_disk_holder(bdev_handle->bdev, md->disk); r = bd_link_disk_holder(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_handle->bdev; td->dm_dev.bdev = bdev;
td->dm_dev.bdev_handle = bdev_handle; td->dm_dev.bdev_file = bdev_file;
td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev, &part_off, td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev, &part_off,
NULL, NULL); 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:
bdev_release(bdev_handle); fput(bdev_file);
out_free_td: out_free_td:
kfree(td); kfree(td);
return ERR_PTR(r); return ERR_PTR(r);
...@@ -775,7 +778,7 @@ static void close_table_device(struct table_device *td, struct mapped_device *md ...@@ -775,7 +778,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);
bdev_release(td->dm_dev.bdev_handle); fput(td->dm_dev.bdev_file);
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);
......
...@@ -2578,7 +2578,7 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev) ...@@ -2578,7 +2578,7 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev)
if (test_bit(AutoDetected, &rdev->flags)) if (test_bit(AutoDetected, &rdev->flags))
md_autodetect_dev(rdev->bdev->bd_dev); md_autodetect_dev(rdev->bdev->bd_dev);
#endif #endif
bdev_release(rdev->bdev_handle); fput(rdev->bdev_file);
rdev->bdev = NULL; rdev->bdev = NULL;
kobject_put(&rdev->kobj); kobject_put(&rdev->kobj);
} }
...@@ -3773,16 +3773,16 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe ...@@ -3773,16 +3773,16 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
if (err) if (err)
goto out_clear_rdev; goto out_clear_rdev;
rdev->bdev_handle = bdev_open_by_dev(newdev, rdev->bdev_file = bdev_file_open_by_dev(newdev,
BLK_OPEN_READ | BLK_OPEN_WRITE, BLK_OPEN_READ | BLK_OPEN_WRITE,
super_format == -2 ? &claim_rdev : rdev, NULL); super_format == -2 ? &claim_rdev : rdev, NULL);
if (IS_ERR(rdev->bdev_handle)) { if (IS_ERR(rdev->bdev_file)) {
pr_warn("md: could not open device unknown-block(%u,%u).\n", pr_warn("md: could not open device unknown-block(%u,%u).\n",
MAJOR(newdev), MINOR(newdev)); MAJOR(newdev), MINOR(newdev));
err = PTR_ERR(rdev->bdev_handle); err = PTR_ERR(rdev->bdev_file);
goto out_clear_rdev; goto out_clear_rdev;
} }
rdev->bdev = rdev->bdev_handle->bdev; rdev->bdev = file_bdev(rdev->bdev_file);
kobject_init(&rdev->kobj, &rdev_ktype); kobject_init(&rdev->kobj, &rdev_ktype);
...@@ -3813,7 +3813,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe ...@@ -3813,7 +3813,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
return rdev; return rdev;
out_blkdev_put: out_blkdev_put:
bdev_release(rdev->bdev_handle); fput(rdev->bdev_file);
out_clear_rdev: out_clear_rdev:
md_rdev_clear(rdev); md_rdev_clear(rdev);
out_free_rdev: out_free_rdev:
......
...@@ -59,7 +59,7 @@ struct md_rdev { ...@@ -59,7 +59,7 @@ struct md_rdev {
*/ */
struct block_device *meta_bdev; struct block_device *meta_bdev;
struct block_device *bdev; /* block device handle */ struct block_device *bdev; /* block device handle */
struct bdev_handle *bdev_handle; /* Handle from open for bdev */ struct file *bdev_file; /* Handle from open for bdev */
struct page *sb_page, *bb_page; struct page *sb_page, *bb_page;
int sb_loaded; int sb_loaded;
......
...@@ -165,7 +165,7 @@ void dm_error(const char *message); ...@@ -165,7 +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 file *bdev_file;
struct dax_device *dax_dev; struct dax_device *dax_dev;
blk_mode_t mode; blk_mode_t mode;
char name[16]; char name[16];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment