Commit 0f1d2e06 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

md: convert to blk_alloc_disk/blk_cleanup_disk

Convert the md 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 avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-15-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 74fe6ba9
...@@ -5598,12 +5598,10 @@ static void md_free(struct kobject *ko) ...@@ -5598,12 +5598,10 @@ static void md_free(struct kobject *ko)
if (mddev->sysfs_level) if (mddev->sysfs_level)
sysfs_put(mddev->sysfs_level); sysfs_put(mddev->sysfs_level);
if (mddev->gendisk) if (mddev->gendisk) {
del_gendisk(mddev->gendisk); del_gendisk(mddev->gendisk);
if (mddev->queue) blk_cleanup_disk(mddev->gendisk);
blk_cleanup_queue(mddev->queue); }
if (mddev->gendisk)
put_disk(mddev->gendisk);
percpu_ref_exit(&mddev->writes_pending); percpu_ref_exit(&mddev->writes_pending);
bioset_exit(&mddev->bio_set); bioset_exit(&mddev->bio_set);
...@@ -5711,20 +5709,13 @@ static int md_alloc(dev_t dev, char *name) ...@@ -5711,20 +5709,13 @@ static int md_alloc(dev_t dev, char *name)
goto abort; goto abort;
error = -ENOMEM; error = -ENOMEM;
mddev->queue = blk_alloc_queue(NUMA_NO_NODE); disk = blk_alloc_disk(NUMA_NO_NODE);
if (!mddev->queue) if (!disk)
goto abort; goto abort;
blk_set_stacking_limits(&mddev->queue->limits);
disk = alloc_disk(1 << shift);
if (!disk) {
blk_cleanup_queue(mddev->queue);
mddev->queue = NULL;
goto abort;
}
disk->major = MAJOR(mddev->unit); disk->major = MAJOR(mddev->unit);
disk->first_minor = unit << shift; disk->first_minor = unit << shift;
disk->minors = 1 << shift;
if (name) if (name)
strcpy(disk->disk_name, name); strcpy(disk->disk_name, name);
else if (partitioned) else if (partitioned)
...@@ -5733,7 +5724,9 @@ static int md_alloc(dev_t dev, char *name) ...@@ -5733,7 +5724,9 @@ static int md_alloc(dev_t dev, char *name)
sprintf(disk->disk_name, "md%d", unit); sprintf(disk->disk_name, "md%d", unit);
disk->fops = &md_fops; disk->fops = &md_fops;
disk->private_data = mddev; disk->private_data = mddev;
disk->queue = mddev->queue;
mddev->queue = disk->queue;
blk_set_stacking_limits(&mddev->queue->limits);
blk_queue_write_cache(mddev->queue, true, true); blk_queue_write_cache(mddev->queue, true, true);
/* Allow extended partitions. This makes the /* Allow extended partitions. This makes the
* 'mdp' device redundant, but we can't really * 'mdp' device redundant, but we can't really
......
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