dm: make nr_requests tunable Make it possible to change the value nr_requests for device mapper devices. Signed-off-by: Mikulas Patocka --- block/blk-sysfs.c | 9 +++++++-- drivers/md/dm.c | 11 ++++++++++- include/linux/blkdev.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) Index: linux-4.7-rc1/drivers/md/dm.c =================================================================== --- linux-4.7-rc1.orig/drivers/md/dm.c 2016-05-30 17:55:32.000000000 +0200 +++ linux-4.7-rc1/drivers/md/dm.c 2016-05-30 17:55:44.000000000 +0200 @@ -274,6 +274,11 @@ static struct kmem_cache *_rq_cache; static unsigned reserved_bio_based_ios = RESERVED_BIO_BASED_IOS; /* + * nr_requests limit for newly created devices. + */ +static unsigned default_nr_requests = DEFAULT_NR_REQUESTS; + +/* * Request-based DM's mempools' reserved IOs set by the user. */ static unsigned reserved_rq_based_ios = RESERVED_REQUEST_BASED_IOS; @@ -2366,7 +2371,8 @@ static void dm_init_normal_md_queue(stru md->queue->backing_dev_info.congested_fn = dm_any_congested; blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY); - md->queue->nr_requests = DEFAULT_NR_REQUESTS; + md->queue->nr_requests = max(default_nr_requests, (unsigned)BLKDEV_MIN_RQ); + queue_flag_set_unlocked(QUEUE_FLAG_NR_REQUESTS, md->queue); } static void cleanup_mapped_device(struct mapped_device *md) @@ -3825,6 +3831,9 @@ MODULE_PARM_DESC(dm_mq_queue_depth, "Que module_param(dm_numa_node, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(dm_numa_node, "NUMA node for DM device memory allocations"); +module_param(default_nr_requests, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(default_nr_requests, "Default limit of in-flight I/Os"); + MODULE_DESCRIPTION(DM_NAME " driver"); MODULE_AUTHOR("Joe Thornber "); MODULE_LICENSE("GPL"); Index: linux-4.7-rc1/include/linux/blkdev.h =================================================================== --- linux-4.7-rc1.orig/include/linux/blkdev.h 2016-05-30 17:55:29.000000000 +0200 +++ linux-4.7-rc1/include/linux/blkdev.h 2016-05-30 17:56:15.000000000 +0200 @@ -494,6 +494,7 @@ struct request_queue { #define QUEUE_FLAG_WC 23 /* Write back caching */ #define QUEUE_FLAG_FUA 24 /* device supports FUA writes */ #define QUEUE_FLAG_FLUSH_NQ 25 /* flush not queueuable */ +#define QUEUE_FLAG_NR_REQUESTS 26 /* allow to set nr_requests */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_STACKABLE) | \ Index: linux-4.7-rc1/block/blk-sysfs.c =================================================================== --- linux-4.7-rc1.orig/block/blk-sysfs.c 2016-05-30 17:55:29.000000000 +0200 +++ linux-4.7-rc1/block/blk-sysfs.c 2016-05-30 17:55:44.000000000 +0200 @@ -52,7 +52,8 @@ queue_requests_store(struct request_queu unsigned long nr; int ret, err; - if (!q->request_fn && !q->mq_ops) + if (!q->request_fn && !q->mq_ops && + !test_bit(QUEUE_FLAG_NR_REQUESTS, &q->queue_flags)) return -EINVAL; ret = queue_var_store(&nr, page, count); @@ -64,8 +65,12 @@ queue_requests_store(struct request_queu if (q->request_fn) err = blk_update_nr_requests(q, nr); - else + else if (q->mq_ops) err = blk_mq_update_nr_requests(q, nr); + else { + q->nr_requests = nr; + err = 0; + } if (err) return err;