Commit afea05a1 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

sunvdc: use blk_mq_alloc_disk

Use the blk_mq_alloc_disk API to simplify the gendisk and request_queue
allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210602065345.355274-14-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 51fbfedf
...@@ -780,27 +780,6 @@ static const struct blk_mq_ops vdc_mq_ops = { ...@@ -780,27 +780,6 @@ static const struct blk_mq_ops vdc_mq_ops = {
.queue_rq = vdc_queue_rq, .queue_rq = vdc_queue_rq,
}; };
static void cleanup_queue(struct request_queue *q)
{
struct vdc_port *port = q->queuedata;
blk_cleanup_queue(q);
blk_mq_free_tag_set(&port->tag_set);
}
static struct request_queue *init_queue(struct vdc_port *port)
{
struct request_queue *q;
q = blk_mq_init_sq_queue(&port->tag_set, &vdc_mq_ops, VDC_TX_RING_SIZE,
BLK_MQ_F_SHOULD_MERGE);
if (IS_ERR(q))
return q;
q->queuedata = port;
return q;
}
static int probe_disk(struct vdc_port *port) static int probe_disk(struct vdc_port *port)
{ {
struct request_queue *q; struct request_queue *q;
...@@ -838,21 +817,21 @@ static int probe_disk(struct vdc_port *port) ...@@ -838,21 +817,21 @@ static int probe_disk(struct vdc_port *port)
(u64)geom.num_sec); (u64)geom.num_sec);
} }
q = init_queue(port); err = blk_mq_alloc_sq_tag_set(&port->tag_set, &vdc_mq_ops,
if (IS_ERR(q)) { VDC_TX_RING_SIZE, BLK_MQ_F_SHOULD_MERGE);
printk(KERN_ERR PFX "%s: Could not allocate queue.\n", if (err)
port->vio.name); return err;
return PTR_ERR(q);
} g = blk_mq_alloc_disk(&port->tag_set, port);
g = alloc_disk(1 << PARTITION_SHIFT); if (IS_ERR(g)) {
if (!g) {
printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n", printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n",
port->vio.name); port->vio.name);
cleanup_queue(q); blk_mq_free_tag_set(&port->tag_set);
return -ENOMEM; return PTR_ERR(g);
} }
port->disk = g; port->disk = g;
q = g->queue;
/* Each segment in a request is up to an aligned page in size. */ /* Each segment in a request is up to an aligned page in size. */
blk_queue_segment_boundary(q, PAGE_SIZE - 1); blk_queue_segment_boundary(q, PAGE_SIZE - 1);
...@@ -862,6 +841,7 @@ static int probe_disk(struct vdc_port *port) ...@@ -862,6 +841,7 @@ static int probe_disk(struct vdc_port *port)
blk_queue_max_hw_sectors(q, port->max_xfer_size); blk_queue_max_hw_sectors(q, port->max_xfer_size);
g->major = vdc_major; g->major = vdc_major;
g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT; g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT;
g->minors = 1 << PARTITION_SHIFT;
strcpy(g->disk_name, port->disk_name); strcpy(g->disk_name, port->disk_name);
g->fops = &vdc_fops; g->fops = &vdc_fops;
...@@ -1083,9 +1063,8 @@ static int vdc_port_remove(struct vio_dev *vdev) ...@@ -1083,9 +1063,8 @@ static int vdc_port_remove(struct vio_dev *vdev)
del_timer_sync(&port->vio.timer); del_timer_sync(&port->vio.timer);
del_gendisk(port->disk); del_gendisk(port->disk);
cleanup_queue(port->disk->queue); blk_cleanup_disk(port->disk);
put_disk(port->disk); blk_mq_free_tag_set(&port->tag_set);
port->disk = NULL;
vdc_free_tx_ring(port); vdc_free_tx_ring(port);
vio_ldc_free(&port->vio); vio_ldc_free(&port->vio);
......
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