* [patch 1/1] nbd: Don't create all MAX_NBD devices by default all the time
@ 2005-04-14 11:23 Lars Marowsky-Bree
2005-04-14 22:56 ` Domen Puncer
0 siblings, 1 reply; 3+ messages in thread
From: Lars Marowsky-Bree @ 2005-04-14 11:23 UTC (permalink / raw)
To: linux-kernel, akpm
From: Lars Marowsky-Bree <lmb@suse.de>
This patches adds the "nbds_max" parameter to the nbd kernel module,
which limits the number of nbds allocated. Previously, always all 128
entries were allocated unconditionally, which used to waste resources
and needlessly flood the hotplug system with events. (Defaults to 16
now.)
Signed-off-by: Lars Marowsky-Bree <lmb@suse.de>
---
nbd.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
Index: linux-2.6.11/drivers/block/nbd.c
===================================================================
--- linux-2.6.11.orig/drivers/block/nbd.c 2005-03-02 08:37:50.000000000 +0100
+++ linux-2.6.11/drivers/block/nbd.c 2005-04-14 13:08:40.100896527 +0200
@@ -78,6 +78,7 @@
#define DBG_RX 0x0200
#define DBG_TX 0x0400
static unsigned int debugflags;
+static unsigned int nbds_max;
#endif /* NDEBUG */
static struct nbd_device nbd_dev[MAX_NBD];
@@ -647,7 +648,13 @@ static int __init nbd_init(void)
return -EIO;
}
- for (i = 0; i < MAX_NBD; i++) {
+ if (nbds_max > MAX_NBD) {
+ printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
+ nbds_max);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = alloc_disk(1);
if (!disk)
goto out;
@@ -673,7 +680,7 @@ static int __init nbd_init(void)
dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags);
devfs_mk_dir("nbd");
- for (i = 0; i < MAX_NBD; i++) {
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = nbd_dev[i].disk;
nbd_dev[i].file = NULL;
nbd_dev[i].magic = LO_MAGIC;
@@ -706,8 +713,9 @@ out:
static void __exit nbd_cleanup(void)
{
int i;
- for (i = 0; i < MAX_NBD; i++) {
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = nbd_dev[i].disk;
+ nbd_dev[i].magic = 0;
if (disk) {
del_gendisk(disk);
blk_cleanup_queue(disk->queue);
@@ -725,6 +733,8 @@ module_exit(nbd_cleanup);
MODULE_DESCRIPTION("Network Block Device");
MODULE_LICENSE("GPL");
+module_param(nbds_max, int, 16);
+MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize.");
#ifndef NDEBUG
module_param(debugflags, int, 0644);
MODULE_PARM_DESC(debugflags, "flags for controlling debug output");
--
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 1/1] nbd: Don't create all MAX_NBD devices by default all the time
2005-04-14 11:23 [patch 1/1] nbd: Don't create all MAX_NBD devices by default all the time Lars Marowsky-Bree
@ 2005-04-14 22:56 ` Domen Puncer
2005-04-15 8:22 ` Lars Marowsky-Bree
0 siblings, 1 reply; 3+ messages in thread
From: Domen Puncer @ 2005-04-14 22:56 UTC (permalink / raw)
To: Lars Marowsky-Bree; +Cc: linux-kernel, akpm
On 14/04/05 13:23 +0200, Lars Marowsky-Bree wrote:
> From: Lars Marowsky-Bree <lmb@suse.de>
>
> This patches adds the "nbds_max" parameter to the nbd kernel module,
> which limits the number of nbds allocated. Previously, always all 128
> entries were allocated unconditionally, which used to waste resources
> and needlessly flood the hotplug system with events. (Defaults to 16
> now.)
>
...
>
> +module_param(nbds_max, int, 16);
This is permissions in sysfs (or 0 if no file is to be created).
> +MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize.");
> #ifndef NDEBUG
> module_param(debugflags, int, 0644);
> MODULE_PARM_DESC(debugflags, "flags for controlling debug output");
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 1/1] nbd: Don't create all MAX_NBD devices by default all the time
2005-04-14 22:56 ` Domen Puncer
@ 2005-04-15 8:22 ` Lars Marowsky-Bree
0 siblings, 0 replies; 3+ messages in thread
From: Lars Marowsky-Bree @ 2005-04-15 8:22 UTC (permalink / raw)
To: Domen Puncer; +Cc: linux-kernel, akpm
On 2005-04-15T00:56:35, Domen Puncer <domen@coderock.org> wrote:
> This is permissions in sysfs (or 0 if no file is to be created).
Duh. Should have caught that. Try this one.
Index: linux-2.6.11/drivers/block/nbd.c
===================================================================
--- linux-2.6.11.orig/drivers/block/nbd.c 2005-03-02 08:37:50.000000000 +0100
+++ linux-2.6.11/drivers/block/nbd.c 2005-04-15 09:36:10.374854551 +0200
@@ -78,6 +78,7 @@
#define DBG_RX 0x0200
#define DBG_TX 0x0400
static unsigned int debugflags;
+static unsigned int nbds_max = 16;
#endif /* NDEBUG */
static struct nbd_device nbd_dev[MAX_NBD];
@@ -647,7 +648,13 @@ static int __init nbd_init(void)
return -EIO;
}
- for (i = 0; i < MAX_NBD; i++) {
+ if (nbds_max > MAX_NBD) {
+ printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
+ nbds_max);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = alloc_disk(1);
if (!disk)
goto out;
@@ -673,7 +680,7 @@ static int __init nbd_init(void)
dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags);
devfs_mk_dir("nbd");
- for (i = 0; i < MAX_NBD; i++) {
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = nbd_dev[i].disk;
nbd_dev[i].file = NULL;
nbd_dev[i].magic = LO_MAGIC;
@@ -706,8 +713,9 @@ out:
static void __exit nbd_cleanup(void)
{
int i;
- for (i = 0; i < MAX_NBD; i++) {
+ for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = nbd_dev[i].disk;
+ nbd_dev[i].magic = 0;
if (disk) {
del_gendisk(disk);
blk_cleanup_queue(disk->queue);
@@ -725,6 +733,8 @@ module_exit(nbd_cleanup);
MODULE_DESCRIPTION("Network Block Device");
MODULE_LICENSE("GPL");
+module_param(nbds_max, int, 0444);
+MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize.");
#ifndef NDEBUG
module_param(debugflags, int, 0644);
MODULE_PARM_DESC(debugflags, "flags for controlling debug output");
Sincerely,
Lars Marowsky-Brée <lmb@suse.de>
--
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-15 8:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-14 11:23 [patch 1/1] nbd: Don't create all MAX_NBD devices by default all the time Lars Marowsky-Bree
2005-04-14 22:56 ` Domen Puncer
2005-04-15 8:22 ` Lars Marowsky-Bree
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox