aoe: pass queue_limits to blk_mq_alloc_disk
authorChristoph Hellwig <hch@lst.de>
Thu, 15 Feb 2024 07:02:45 +0000 (08:02 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Feb 2024 23:59:31 +0000 (16:59 -0700)
Pass the few limits aoe imposes directly to blk_mq_alloc_disk instead
of setting them one at a time and improve the way the default
max_hw_sectors is initialized while we're at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240215070300.2200308-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/aoe/aoeblk.c

index 2ff6e2da8cc41c8e36b89fd60dff04dd7eed3dd6..b6dac8cee70fe13a49a7699727e47f13a27be91c 100644 (file)
@@ -24,8 +24,8 @@ static DEFINE_MUTEX(aoeblk_mutex);
 static struct kmem_cache *buf_pool_cache;
 static struct dentry *aoe_debugfs_dir;
 
-/* GPFS needs a larger value than the default. */
-static int aoe_maxsectors;
+/* random default picked from the historic block max_sectors cap */
+static int aoe_maxsectors = 2560;
 module_param(aoe_maxsectors, int, 0644);
 MODULE_PARM_DESC(aoe_maxsectors,
        "When nonzero, set the maximum number of sectors per I/O request");
@@ -334,6 +334,10 @@ aoeblk_gdalloc(void *vp)
        mempool_t *mp;
        struct blk_mq_tag_set *set;
        sector_t ssize;
+       struct queue_limits lim = {
+               .max_hw_sectors         = aoe_maxsectors,
+               .io_opt                 = SZ_2M,
+       };
        ulong flags;
        int late = 0;
        int err;
@@ -371,7 +375,7 @@ aoeblk_gdalloc(void *vp)
                goto err_mempool;
        }
 
-       gd = blk_mq_alloc_disk(set, NULL, d);
+       gd = blk_mq_alloc_disk(set, &lim, d);
        if (IS_ERR(gd)) {
                pr_err("aoe: cannot allocate block queue for %ld.%d\n",
                        d->aoemajor, d->aoeminor);
@@ -384,14 +388,9 @@ aoeblk_gdalloc(void *vp)
        WARN_ON(d->flags & DEVFL_TKILL);
        WARN_ON(d->gd);
        WARN_ON(d->flags & DEVFL_UP);
-       /* random number picked from the history block max_sectors cap */
-       blk_queue_max_hw_sectors(gd->queue, 2560u);
-       blk_queue_io_opt(gd->queue, SZ_2M);
        d->bufpool = mp;
        d->blkq = gd->queue;
        d->gd = gd;
-       if (aoe_maxsectors)
-               blk_queue_max_hw_sectors(gd->queue, aoe_maxsectors);
        gd->major = AOE_MAJOR;
        gd->first_minor = d->sysminor;
        gd->minors = AOE_PARTITIONS;