1

block: pass a queue_limits argument to blk_mq_alloc_disk

Pass a queue_limits to blk_mq_alloc_disk and apply it if non-NULL.  This
will allow allocating queues with valid queue limits instead of setting
the values one at a time later.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20240213073425.1621680-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2024-02-13 08:34:20 +01:00 committed by Jens Axboe
parent 9ac4dd8c47
commit 27e32cd23f
30 changed files with 35 additions and 33 deletions

View File

@ -906,7 +906,7 @@ static int ubd_add(int n, char **error_out)
if (err)
goto out;
disk = blk_mq_alloc_disk(&ubd_dev->tag_set, ubd_dev);
disk = blk_mq_alloc_disk(&ubd_dev->tag_set, NULL, ubd_dev);
if (IS_ERR(disk)) {
err = PTR_ERR(disk);
goto out_cleanup_tags;

View File

@ -4130,13 +4130,14 @@ void blk_mq_destroy_queue(struct request_queue *q)
}
EXPORT_SYMBOL(blk_mq_destroy_queue);
struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set,
struct queue_limits *lim, void *queuedata,
struct lock_class_key *lkclass)
{
struct request_queue *q;
struct gendisk *disk;
q = blk_mq_alloc_queue(set, NULL, queuedata);
q = blk_mq_alloc_queue(set, lim, queuedata);
if (IS_ERR(q))
return ERR_CAST(q);

View File

@ -1779,7 +1779,7 @@ static int fd_alloc_disk(int drive, int system)
struct gendisk *disk;
int err;
disk = blk_mq_alloc_disk(&unit[drive].tag_set, NULL);
disk = blk_mq_alloc_disk(&unit[drive].tag_set, NULL, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);

View File

@ -371,7 +371,7 @@ aoeblk_gdalloc(void *vp)
goto err_mempool;
}
gd = blk_mq_alloc_disk(set, d);
gd = blk_mq_alloc_disk(set, NULL, d);
if (IS_ERR(gd)) {
pr_err("aoe: cannot allocate block queue for %ld.%d\n",
d->aoemajor, d->aoeminor);

View File

@ -1994,7 +1994,7 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type)
{
struct gendisk *disk;
disk = blk_mq_alloc_disk(&unit[drive].tag_set, NULL);
disk = blk_mq_alloc_disk(&unit[drive].tag_set, NULL, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);

View File

@ -4518,7 +4518,7 @@ static int floppy_alloc_disk(unsigned int drive, unsigned int type)
{
struct gendisk *disk;
disk = blk_mq_alloc_disk(&tag_sets[drive], NULL);
disk = blk_mq_alloc_disk(&tag_sets[drive], NULL, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);

View File

@ -2025,7 +2025,7 @@ static int loop_add(int i)
if (err)
goto out_free_idr;
disk = lo->lo_disk = blk_mq_alloc_disk(&lo->tag_set, lo);
disk = lo->lo_disk = blk_mq_alloc_disk(&lo->tag_set, NULL, lo);
if (IS_ERR(disk)) {
err = PTR_ERR(disk);
goto out_cleanup_tags;

View File

@ -3431,7 +3431,7 @@ static int mtip_block_initialize(struct driver_data *dd)
goto block_queue_alloc_tag_error;
}
dd->disk = blk_mq_alloc_disk(&dd->tags, dd);
dd->disk = blk_mq_alloc_disk(&dd->tags, NULL, dd);
if (IS_ERR(dd->disk)) {
dev_err(&dd->pdev->dev,
"Unable to allocate request queue\n");

View File

@ -1823,7 +1823,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
if (err < 0)
goto out_free_tags;
disk = blk_mq_alloc_disk(&nbd->tag_set, NULL);
disk = blk_mq_alloc_disk(&nbd->tag_set, NULL, NULL);
if (IS_ERR(disk)) {
err = PTR_ERR(disk);
goto out_free_idr;

View File

@ -2147,7 +2147,7 @@ static int null_add_dev(struct nullb_device *dev)
goto out_cleanup_queues;
nullb->tag_set->timeout = 5 * HZ;
nullb->disk = blk_mq_alloc_disk(nullb->tag_set, nullb);
nullb->disk = blk_mq_alloc_disk(nullb->tag_set, NULL, nullb);
if (IS_ERR(nullb->disk)) {
rv = PTR_ERR(nullb->disk);
goto out_cleanup_tags;

View File

@ -431,7 +431,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
if (error)
goto fail_teardown;
gendisk = blk_mq_alloc_disk(&priv->tag_set, dev);
gendisk = blk_mq_alloc_disk(&priv->tag_set, NULL, dev);
if (IS_ERR(gendisk)) {
dev_err(&dev->sbd.core, "%s:%u: blk_mq_alloc_disk failed\n",
__func__, __LINE__);

View File

@ -4966,7 +4966,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
if (err)
return err;
disk = blk_mq_alloc_disk(&rbd_dev->tag_set, rbd_dev);
disk = blk_mq_alloc_disk(&rbd_dev->tag_set, NULL, rbd_dev);
if (IS_ERR(disk)) {
err = PTR_ERR(disk);
goto out_tag_set;

View File

@ -1408,7 +1408,7 @@ static int rnbd_client_setup_device(struct rnbd_clt_dev *dev,
dev->size = le64_to_cpu(rsp->nsectors) *
le16_to_cpu(rsp->logical_block_size);
dev->gd = blk_mq_alloc_disk(&dev->sess->tag_set, dev);
dev->gd = blk_mq_alloc_disk(&dev->sess->tag_set, NULL, dev);
if (IS_ERR(dev->gd))
return PTR_ERR(dev->gd);
dev->queue = dev->gd->queue;

View File

@ -824,7 +824,7 @@ static int probe_disk(struct vdc_port *port)
if (err)
return err;
g = blk_mq_alloc_disk(&port->tag_set, port);
g = blk_mq_alloc_disk(&port->tag_set, NULL, port);
if (IS_ERR(g)) {
printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n",
port->vio.name);

View File

@ -820,7 +820,7 @@ static int swim_floppy_init(struct swim_priv *swd)
goto exit_put_disks;
swd->unit[drive].disk =
blk_mq_alloc_disk(&swd->unit[drive].tag_set,
blk_mq_alloc_disk(&swd->unit[drive].tag_set, NULL,
&swd->unit[drive]);
if (IS_ERR(swd->unit[drive].disk)) {
blk_mq_free_tag_set(&swd->unit[drive].tag_set);

View File

@ -1210,7 +1210,7 @@ static int swim3_attach(struct macio_dev *mdev,
if (rc)
goto out_unregister;
disk = blk_mq_alloc_disk(&fs->tag_set, fs);
disk = blk_mq_alloc_disk(&fs->tag_set, NULL, fs);
if (IS_ERR(disk)) {
rc = PTR_ERR(disk);
goto out_free_tag_set;

View File

@ -2222,7 +2222,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
goto out_unlock;
}
disk = blk_mq_alloc_disk(&ub->tag_set, NULL);
disk = blk_mq_alloc_disk(&ub->tag_set, NULL, NULL);
if (IS_ERR(disk)) {
ret = PTR_ERR(disk);
goto out_unlock;

View File

@ -1330,7 +1330,7 @@ static int virtblk_probe(struct virtio_device *vdev)
if (err)
goto out_free_vq;
vblk->disk = blk_mq_alloc_disk(&vblk->tag_set, vblk);
vblk->disk = blk_mq_alloc_disk(&vblk->tag_set, NULL, vblk);
if (IS_ERR(vblk->disk)) {
err = PTR_ERR(vblk->disk);
goto out_free_tags;

View File

@ -1136,7 +1136,7 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
if (err)
goto out_release_minors;
gd = blk_mq_alloc_disk(&info->tag_set, info);
gd = blk_mq_alloc_disk(&info->tag_set, NULL, info);
if (IS_ERR(gd)) {
err = PTR_ERR(gd);
goto out_free_tag_set;

View File

@ -318,7 +318,7 @@ static int z2ram_register_disk(int minor)
struct gendisk *disk;
int err;
disk = blk_mq_alloc_disk(&tag_set, NULL);
disk = blk_mq_alloc_disk(&tag_set, NULL, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);

View File

@ -778,7 +778,7 @@ static int probe_gdrom(struct platform_device *devptr)
if (err)
goto probe_fail_free_cd_info;
gd.disk = blk_mq_alloc_disk(&gd.tag_set, NULL);
gd.disk = blk_mq_alloc_disk(&gd.tag_set, NULL, NULL);
if (IS_ERR(gd.disk)) {
err = PTR_ERR(gd.disk);
goto probe_fail_free_tag_set;

View File

@ -2093,7 +2093,7 @@ static int msb_init_disk(struct memstick_dev *card)
if (rc)
goto out_release_id;
msb->disk = blk_mq_alloc_disk(&msb->tag_set, card);
msb->disk = blk_mq_alloc_disk(&msb->tag_set, NULL, card);
if (IS_ERR(msb->disk)) {
rc = PTR_ERR(msb->disk);
goto out_free_tag_set;

View File

@ -1138,7 +1138,7 @@ static int mspro_block_init_disk(struct memstick_dev *card)
if (rc)
goto out_release_id;
msb->disk = blk_mq_alloc_disk(&msb->tag_set, card);
msb->disk = blk_mq_alloc_disk(&msb->tag_set, NULL, card);
if (IS_ERR(msb->disk)) {
rc = PTR_ERR(msb->disk);
goto out_free_tag_set;

View File

@ -447,7 +447,7 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)
return ERR_PTR(ret);
disk = blk_mq_alloc_disk(&mq->tag_set, mq);
disk = blk_mq_alloc_disk(&mq->tag_set, NULL, mq);
if (IS_ERR(disk)) {
blk_mq_free_tag_set(&mq->tag_set);
return disk;

View File

@ -333,7 +333,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
goto out_kfree_tag_set;
/* Create gendisk */
gd = blk_mq_alloc_disk(new->tag_set, new);
gd = blk_mq_alloc_disk(new->tag_set, NULL, new);
if (IS_ERR(gd)) {
ret = PTR_ERR(gd);
goto out_free_tag_set;

View File

@ -393,7 +393,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
/* Initialize the gendisk of this ubiblock device */
gd = blk_mq_alloc_disk(&dev->tag_set, dev);
gd = blk_mq_alloc_disk(&dev->tag_set, NULL, dev);
if (IS_ERR(gd)) {
ret = PTR_ERR(gd);
goto out_free_tags;

View File

@ -3694,7 +3694,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
if (!ns)
return;
disk = blk_mq_alloc_disk(ctrl->tagset, ns);
disk = blk_mq_alloc_disk(ctrl->tagset, NULL, ns);
if (IS_ERR(disk))
goto out_free_ns;
disk->fops = &nvme_bdev_ops;

View File

@ -53,7 +53,7 @@ int dasd_gendisk_alloc(struct dasd_block *block)
if (rc)
return rc;
gdp = blk_mq_alloc_disk(&block->tag_set, block);
gdp = blk_mq_alloc_disk(&block->tag_set, NULL, block);
if (IS_ERR(gdp)) {
blk_mq_free_tag_set(&block->tag_set);
return PTR_ERR(gdp);

View File

@ -462,7 +462,7 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)
if (ret)
goto out;
bdev->gendisk = blk_mq_alloc_disk(&bdev->tag_set, scmdev);
bdev->gendisk = blk_mq_alloc_disk(&bdev->tag_set, NULL, scmdev);
if (IS_ERR(bdev->gendisk)) {
ret = PTR_ERR(bdev->gendisk);
goto out_tag;

View File

@ -682,13 +682,14 @@ enum {
#define BLK_MQ_NO_HCTX_IDX (-1U)
struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set, void *queuedata,
struct gendisk *__blk_mq_alloc_disk(struct blk_mq_tag_set *set,
struct queue_limits *lim, void *queuedata,
struct lock_class_key *lkclass);
#define blk_mq_alloc_disk(set, queuedata) \
#define blk_mq_alloc_disk(set, lim, queuedata) \
({ \
static struct lock_class_key __key; \
\
__blk_mq_alloc_disk(set, queuedata, &__key); \
__blk_mq_alloc_disk(set, lim, queuedata, &__key); \
})
struct gendisk *blk_mq_alloc_disk_for_queue(struct request_queue *q,
struct lock_class_key *lkclass);