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

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.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 51fbfedf
Loading
Loading
Loading
Loading
+13 −34
Original line number Diff line number Diff line
@@ -780,27 +780,6 @@ static const struct blk_mq_ops vdc_mq_ops = {
	.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)
{
	struct request_queue *q;
@@ -838,21 +817,21 @@ static int probe_disk(struct vdc_port *port)
				    (u64)geom.num_sec);
	}

	q = init_queue(port);
	if (IS_ERR(q)) {
		printk(KERN_ERR PFX "%s: Could not allocate queue.\n",
		       port->vio.name);
		return PTR_ERR(q);
	}
	g = alloc_disk(1 << PARTITION_SHIFT);
	if (!g) {
	err = blk_mq_alloc_sq_tag_set(&port->tag_set, &vdc_mq_ops,
			VDC_TX_RING_SIZE, BLK_MQ_F_SHOULD_MERGE);
	if (err)
		return err;

	g = blk_mq_alloc_disk(&port->tag_set, port);
	if (IS_ERR(g)) {
		printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n",
		       port->vio.name);
		cleanup_queue(q);
		return -ENOMEM;
		blk_mq_free_tag_set(&port->tag_set);
		return PTR_ERR(g);
	}

	port->disk = g;
	q = g->queue;

	/* Each segment in a request is up to an aligned page in size. */
	blk_queue_segment_boundary(q, PAGE_SIZE - 1);
@@ -862,6 +841,7 @@ static int probe_disk(struct vdc_port *port)
	blk_queue_max_hw_sectors(q, port->max_xfer_size);
	g->major = vdc_major;
	g->first_minor = port->vio.vdev->dev_no << PARTITION_SHIFT;
	g->minors = 1 << PARTITION_SHIFT;
	strcpy(g->disk_name, port->disk_name);

	g->fops = &vdc_fops;
@@ -1083,9 +1063,8 @@ static int vdc_port_remove(struct vio_dev *vdev)
		del_timer_sync(&port->vio.timer);

		del_gendisk(port->disk);
		cleanup_queue(port->disk->queue);
		put_disk(port->disk);
		port->disk = NULL;
		blk_cleanup_disk(port->disk);
		blk_mq_free_tag_set(&port->tag_set);

		vdc_free_tx_ring(port);
		vio_ldc_free(&port->vio);