Commit 74fe6ba9 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

dm: convert to blk_alloc_disk/blk_cleanup_disk

Convert the dm driver to use the blk_alloc_disk and blk_cleanup_disk
helpers to simplify gendisk and request_queue allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-14-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent bc70852f
...@@ -1801,13 +1801,13 @@ static void cleanup_mapped_device(struct mapped_device *md) ...@@ -1801,13 +1801,13 @@ static void cleanup_mapped_device(struct mapped_device *md)
md->disk->private_data = NULL; md->disk->private_data = NULL;
spin_unlock(&_minor_lock); spin_unlock(&_minor_lock);
del_gendisk(md->disk); del_gendisk(md->disk);
put_disk(md->disk);
} }
if (md->queue) { if (md->queue)
dm_queue_destroy_keyslot_manager(md->queue); dm_queue_destroy_keyslot_manager(md->queue);
blk_cleanup_queue(md->queue);
} if (md->disk)
blk_cleanup_disk(md->disk);
cleanup_srcu_struct(&md->io_barrier); cleanup_srcu_struct(&md->io_barrier);
...@@ -1869,13 +1869,10 @@ static struct mapped_device *alloc_dev(int minor) ...@@ -1869,13 +1869,10 @@ static struct mapped_device *alloc_dev(int minor)
* established. If request-based table is loaded: blk-mq will * established. If request-based table is loaded: blk-mq will
* override accordingly. * override accordingly.
*/ */
md->queue = blk_alloc_queue(numa_node_id); md->disk = blk_alloc_disk(md->numa_node_id);
if (!md->queue)
goto bad;
md->disk = alloc_disk_node(1, md->numa_node_id);
if (!md->disk) if (!md->disk)
goto bad; goto bad;
md->queue = md->disk->queue;
init_waitqueue_head(&md->wait); init_waitqueue_head(&md->wait);
INIT_WORK(&md->work, dm_wq_work); INIT_WORK(&md->work, dm_wq_work);
...@@ -1888,6 +1885,7 @@ static struct mapped_device *alloc_dev(int minor) ...@@ -1888,6 +1885,7 @@ static struct mapped_device *alloc_dev(int minor)
md->disk->major = _major; md->disk->major = _major;
md->disk->first_minor = minor; md->disk->first_minor = minor;
md->disk->minors = 1;
md->disk->fops = &dm_blk_dops; md->disk->fops = &dm_blk_dops;
md->disk->queue = md->queue; md->disk->queue = md->queue;
md->disk->private_data = md; md->disk->private_data = md;
......
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