Skip to content

Commit

Permalink
bcache: convert to blk_alloc_disk/blk_cleanup_disk
Browse files Browse the repository at this point in the history
Convert the bcache driver to use the blk_alloc_disk and blk_cleanup_disk
helpers to simplify gendisk and request_queue allocation.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Acked-by: Coly Li <[email protected]>
Reviewed-by: Ulf Hansson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 1, 2021
1 parent 1aabd53 commit bc70852
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/md/bcache/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,13 +890,9 @@ static void bcache_device_free(struct bcache_device *d)
if (disk_added)
del_gendisk(disk);

if (disk->queue)
blk_cleanup_queue(disk->queue);

blk_cleanup_disk(disk);
ida_simple_remove(&bcache_device_idx,
first_minor_to_idx(disk->first_minor));
if (disk_added)
put_disk(disk);
}

bioset_exit(&d->bio_split);
Expand Down Expand Up @@ -946,7 +942,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,
BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER))
goto err;

d->disk = alloc_disk(BCACHE_MINORS);
d->disk = blk_alloc_disk(NUMA_NO_NODE);
if (!d->disk)
goto err;

Expand All @@ -955,14 +951,11 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size,

d->disk->major = bcache_major;
d->disk->first_minor = idx_to_first_minor(idx);
d->disk->minors = BCACHE_MINORS;
d->disk->fops = ops;
d->disk->private_data = d;

q = blk_alloc_queue(NUMA_NO_NODE);
if (!q)
return -ENOMEM;

d->disk->queue = q;
q = d->disk->queue;
q->limits.max_hw_sectors = UINT_MAX;
q->limits.max_sectors = UINT_MAX;
q->limits.max_segment_size = UINT_MAX;
Expand Down

0 comments on commit bc70852

Please sign in to comment.