Skip to content

Commit

Permalink
pd: use blk_mq_alloc_disk and blk_cleanup_disk
Browse files Browse the repository at this point in the history
Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
request_queue allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210602065345.355274-22-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 11, 2021
1 parent 6759b1a commit 262d431
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions drivers/block/paride/pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,18 +879,6 @@ static void pd_probe_drive(struct pd_unit *disk)
{
struct gendisk *p;

p = alloc_disk(1 << PD_BITS);
if (!p)
return;

strcpy(p->disk_name, disk->name);
p->fops = &pd_fops;
p->major = major;
p->first_minor = (disk - pd) << PD_BITS;
p->events = DISK_EVENT_MEDIA_CHANGE;
disk->gd = p;
p->private_data = disk;

memset(&disk->tag_set, 0, sizeof(disk->tag_set));
disk->tag_set.ops = &pd_mq_ops;
disk->tag_set.cmd_size = sizeof(struct pd_req);
Expand All @@ -903,14 +891,21 @@ static void pd_probe_drive(struct pd_unit *disk)
if (blk_mq_alloc_tag_set(&disk->tag_set))
return;

p->queue = blk_mq_init_queue(&disk->tag_set);
if (IS_ERR(p->queue)) {
p = blk_mq_alloc_disk(&disk->tag_set, disk);
if (!p) {
blk_mq_free_tag_set(&disk->tag_set);
p->queue = NULL;
return;
}
disk->gd = p;

strcpy(p->disk_name, disk->name);
p->fops = &pd_fops;
p->major = major;
p->first_minor = (disk - pd) << PD_BITS;
p->minors = 1 << PD_BITS;
p->events = DISK_EVENT_MEDIA_CHANGE;
p->private_data = disk;

p->queue->queuedata = disk;
blk_queue_max_hw_sectors(p->queue, cluster);
blk_queue_bounce_limit(p->queue, BLK_BOUNCE_HIGH);

Expand Down Expand Up @@ -1019,9 +1014,8 @@ static void __exit pd_exit(void)
if (p) {
disk->gd = NULL;
del_gendisk(p);
blk_cleanup_queue(p->queue);
blk_mq_free_tag_set(&disk->tag_set);
put_disk(p);
blk_cleanup_disk(p);
pi_release(disk->pi);
}
}
Expand Down

0 comments on commit 262d431

Please sign in to comment.