This allows configuring them at compile time, not just via the kernel command line or module parameters. This doesn't change the default defaults, just makes them configurable. Signed-off-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx> --- I'd like to be able to simplify the kernel command line I'm currently using, by removing the nbd module parameters from it; this change would make it possible to configure them when building the kernel, instead. drivers/block/Kconfig | 28 ++++++++++++++++++++++++++++ drivers/block/nbd.c | 10 ++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index ecceaaa1a66f..7df9a9609aee 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -273,6 +273,34 @@ config BLK_DEV_NBD If unsure, say N. +config BLK_DEV_NBD_DEFAULT_NBDS_MAX + int "Default maximum number of NBD devices" + depends on BLK_DEV_NBD + default 16 + help + The NBD driver can provide a set of unconfigured NBD devices (nbd0, + nbd1, ...) by default, so that userspace can open and configure these + devices via the ioctl interface. If you know that your userspace uses + exclusively the new netlink interface, you can set this to 0 to + reduce the amount of time needed for the NBD driver to initialize. + You can also set this parameter at runtime using the nbds_max module + parameter. + +config BLK_DEV_NBD_DEFAULT_MAX_PART + int "Default maximum number of NBD device partitions" + depends on BLK_DEV_NBD + default 16 + help + Once an NBD device is set up and opened, the kernel can probe it for + partitions, and set up corresponding devices for each partition + (nbd0p1, nbd0p2, ...). By default, the kernel probes for up to 16 + partitions per device. This also adds a bit of time to NBD device + initialization. You can set this to a lower number if you know you'll + never use more than that many partitions on an NBD device. If you + exclusively use unpartitioned NBD devices, you can set this to 0 to + skip partition probing entirely. You can also set this parameter at + runtime using the max_part module parameter. + config BLK_DEV_SKD tristate "STEC S1120 Block Driver" depends on PCI diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index edf8b632e3d2..42851956c9ce 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -145,8 +145,8 @@ static struct dentry *nbd_dbg_dir; #define NBD_DEF_BLKSIZE 1024 -static unsigned int nbds_max = 16; -static int max_part = 16; +static unsigned int nbds_max = CONFIG_BLK_DEV_NBD_DEFAULT_NBDS_MAX; +static int max_part = CONFIG_BLK_DEV_NBD_DEFAULT_MAX_PART; static int part_shift; static int nbd_dev_dbg_init(struct nbd_device *nbd); @@ -2456,6 +2456,8 @@ MODULE_DESCRIPTION("Network Block Device"); MODULE_LICENSE("GPL"); module_param(nbds_max, int, 0444); -MODULE_PARM_DESC(nbds_max, "number of network block devices to initialize (default: 16)"); +MODULE_PARM_DESC(nbds_max, "number of network block devices to initialize (default: " + __stringify(CONFIG_BLK_DEV_NBD_DEFAULT_NBDS_MAX) ")"); module_param(max_part, int, 0444); -MODULE_PARM_DESC(max_part, "number of partitions per device (default: 16)"); +MODULE_PARM_DESC(max_part, "number of partitions per device (default: " + __stringify(CONFIG_BLK_DEV_NBD_DEFAULT_MAX_PART) ")"); -- 2.28.0