/* kobject and completion */
struct dm_kobject_holder kobj_holder;
- struct block_device *bdev;
-
struct dm_stats stats;
/* for blk-mq request-based DM support */
cleanup_srcu_struct(&md->io_barrier);
- if (md->bdev) {
- bdput(md->bdev);
- md->bdev = NULL;
- }
-
mutex_destroy(&md->suspend_lock);
mutex_destroy(&md->type_lock);
mutex_destroy(&md->table_devices_lock);
if (!md->wq)
goto bad;
- md->bdev = bdget_disk(md->disk, 0);
- if (!md->bdev)
- goto bad;
-
dm_stats_init(&md->stats);
/* Populate the mapping, nobody knows we exist yet */
*/
static int lock_fs(struct mapped_device *md)
{
+ struct block_device *bdev;
int r;
WARN_ON(test_bit(DMF_FROZEN, &md->flags));
- r = freeze_bdev(md->bdev);
+ bdev = bdget_disk(md->disk, 0);
+ if (!bdev)
+ return -ENOMEM;
+ r = freeze_bdev(bdev);
+ bdput(bdev);
if (!r)
set_bit(DMF_FROZEN, &md->flags);
return r;
static void unlock_fs(struct mapped_device *md)
{
+ struct block_device *bdev;
+
if (!test_bit(DMF_FROZEN, &md->flags))
return;
- thaw_bdev(md->bdev);
+
+ bdev = bdget_disk(md->disk, 0);
+ if (!bdev)
+ return;
+ thaw_bdev(bdev);
+ bdput(bdev);
clear_bit(DMF_FROZEN, &md->flags);
}