From: Josh Triplett <josh@joshtriplett.org>
To: Jens Axboe <axboe@kernel.dk>, Josef Bacik <josef@toxicpanda.com>,
linux-block@vger.kernel.org, nbd@other.debian.org
Subject: [PATCH] nbd: Support Kconfig configuration of nbds_max and max_part
Date: Fri, 9 Oct 2020 14:18:37 -0700 [thread overview]
Message-ID: <f0a162a4c7073e3ed47d981b86d845d3bb9aa955.1602278122.git.josh@joshtriplett.org> (raw)
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@joshtriplett.org>
---
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
reply other threads:[~2020-10-09 21:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0a162a4c7073e3ed47d981b86d845d3bb9aa955.1602278122.git.josh@joshtriplett.org \
--to=josh@joshtriplett.org \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=nbd@other.debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).