Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

null_blk: add module parameters for 4 options

Add as module parameters these options:

memory_backed
discard
mbps
cache_size

Previously these could only be set via configfs.

Still missing is bad_blocks.

The kernel test robot found a documentation formatting issue in v1 of
this patch.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
Link: https://lore.kernel.org/r/20220708174943.87787-2-vincent.fu@samsung.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Vincent Fu and committed by
Jens Axboe
058efe00 ce11bdf9

+42
+22
Documentation/block/null_blk.rst
··· 72 72 hw_queue_depth=[0..qdepth]: Default: 64 73 73 The hardware queue depth of the device. 74 74 75 + memory_backed=[0/1]: Default: 0 76 + Whether or not to use a memory buffer to respond to IO requests 77 + 78 + = ============================================= 79 + 0 Transfer no data in response to IO requests 80 + 1 Use a memory buffer to respond to IO requests 81 + = ============================================= 82 + 83 + discard=[0/1]: Default: 0 84 + Support discard operations (requires memory-backed null_blk device). 85 + 86 + = ===================================== 87 + 0 Do not support discard operations 88 + 1 Enable support for discard operations 89 + = ===================================== 90 + 91 + cache_size=[Size in MB]: Default: 0 92 + Cache size in MB for memory-backed device. 93 + 94 + mbps=[Maximum bandwidth in MB/s]: Default: 0 (no limit) 95 + Bandwidth limit for device performance. 96 + 75 97 Multi-queue specific parameters 76 98 ------------------------------- 77 99
+20
drivers/block/null_blk/main.c
··· 201 201 module_param_named(use_per_node_hctx, g_use_per_node_hctx, bool, 0444); 202 202 MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: false"); 203 203 204 + static bool g_memory_backed; 205 + module_param_named(memory_backed, g_memory_backed, bool, 0444); 206 + MODULE_PARM_DESC(memory_backed, "Create a memory-backed block device. Default: false"); 207 + 208 + static bool g_discard; 209 + module_param_named(discard, g_discard, bool, 0444); 210 + MODULE_PARM_DESC(discard, "Support discard operations (requires memory-backed null_blk device). Default: false"); 211 + 212 + static unsigned long g_cache_size; 213 + module_param_named(cache_size, g_cache_size, ulong, 0444); 214 + MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (none)"); 215 + 216 + static unsigned int g_mbps; 217 + module_param_named(mbps, g_mbps, uint, 0444); 218 + MODULE_PARM_DESC(mbps, "Limit maximum bandwidth (in MiB/s). Default: 0 (no limit)"); 219 + 204 220 static bool g_zoned; 205 221 module_param_named(zoned, g_zoned, bool, S_IRUGO); 206 222 MODULE_PARM_DESC(zoned, "Make device as a host-managed zoned block device. Default: false"); ··· 666 650 dev->irqmode = g_irqmode; 667 651 dev->hw_queue_depth = g_hw_queue_depth; 668 652 dev->blocking = g_blocking; 653 + dev->memory_backed = g_memory_backed; 654 + dev->discard = g_discard; 655 + dev->cache_size = g_cache_size; 656 + dev->mbps = g_mbps; 669 657 dev->use_per_node_hctx = g_use_per_node_hctx; 670 658 dev->zoned = g_zoned; 671 659 dev->zone_size = g_zone_size;