[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 23/30] rnbd: use blk_mq_alloc_disk and blk_cleanup_disk



Use blk_mq_alloc_disk and blk_cleanup_disk to simplify the gendisk and
request_queue allocation.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 drivers/block/rnbd/rnbd-clt.c | 35 ++++++++---------------------------
 1 file changed, 8 insertions(+), 27 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index c604a402cd5c..f4fa45d24c0b 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -1353,18 +1353,6 @@ static void rnbd_init_mq_hw_queues(struct rnbd_clt_dev 
*dev)
        }
 }
 
-static int setup_mq_dev(struct rnbd_clt_dev *dev)
-{
-       dev->queue = blk_mq_init_queue(&dev->sess->tag_set);
-       if (IS_ERR(dev->queue)) {
-               rnbd_clt_err(dev, "Initializing multiqueue queue failed, err: 
%ld\n",
-                             PTR_ERR(dev->queue));
-               return PTR_ERR(dev->queue);
-       }
-       rnbd_init_mq_hw_queues(dev);
-       return 0;
-}
-
 static void setup_request_queue(struct rnbd_clt_dev *dev)
 {
        blk_queue_logical_block_size(dev->queue, dev->logical_block_size);
@@ -1393,13 +1381,13 @@ static void setup_request_queue(struct rnbd_clt_dev 
*dev)
        blk_queue_io_opt(dev->queue, dev->sess->max_io_size);
        blk_queue_virt_boundary(dev->queue, SZ_4K - 1);
        blk_queue_write_cache(dev->queue, dev->wc, dev->fua);
-       dev->queue->queuedata = dev;
 }
 
 static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev, int idx)
 {
        dev->gd->major          = rnbd_client_major;
        dev->gd->first_minor    = idx << RNBD_PART_BITS;
+       dev->gd->minors         = 1 << RNBD_PART_BITS;
        dev->gd->fops           = &rnbd_client_ops;
        dev->gd->queue          = dev->queue;
        dev->gd->private_data   = dev;
@@ -1426,24 +1414,18 @@ static void rnbd_clt_setup_gen_disk(struct rnbd_clt_dev 
*dev, int idx)
 
 static int rnbd_client_setup_device(struct rnbd_clt_dev *dev)
 {
-       int err, idx = dev->clt_device_id;
+       int idx = dev->clt_device_id;
 
        dev->size = dev->nsectors * dev->logical_block_size;
 
-       err = setup_mq_dev(dev);
-       if (err)
-               return err;
+       dev->gd = blk_mq_alloc_disk(&dev->sess->tag_set, dev);
+       if (IS_ERR(dev->gd))
+               return PTR_ERR(dev->gd);
+       dev->queue = dev->gd->queue;
+       rnbd_init_mq_hw_queues(dev);
 
        setup_request_queue(dev);
-
-       dev->gd = alloc_disk_node(1 << RNBD_PART_BITS,  NUMA_NO_NODE);
-       if (!dev->gd) {
-               blk_cleanup_queue(dev->queue);
-               return -ENOMEM;
-       }
-
        rnbd_clt_setup_gen_disk(dev, idx);
-
        return 0;
 }
 
@@ -1650,8 +1632,7 @@ struct rnbd_clt_dev *rnbd_clt_map_device(const char 
*sessname,
 static void destroy_gen_disk(struct rnbd_clt_dev *dev)
 {
        del_gendisk(dev->gd);
-       blk_cleanup_queue(dev->queue);
-       put_disk(dev->gd);
+       blk_cleanup_disk(dev->gd);
 }
 
 static void destroy_sysfs(struct rnbd_clt_dev *dev,
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.