mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
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@lst.de> Reviewed-by: Jack Wang <jinpu.wang@ionos.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210602065345.355274-24-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
195b1956b8
commit
2c6ee0ae5f
@ -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 @@ put_sess:
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user