浏览代码

NBD: remove limit on max number of nbd devices

Remove the arbitrary 128 device limit for NBD.  nbds_max can now be set to
any number.  In certain scenarios where devices are used sparsely we have
run into the 128 device limit.

Signed-off-by: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Paul Clements 17 年之前
父节点
当前提交
20a8143eaa
共有 2 个文件被更改,包括 4 次插入7 次删除
  1. 4 6
      drivers/block/nbd.c
  2. 0 1
      include/linux/nbd.h

+ 4 - 6
drivers/block/nbd.c

@@ -54,7 +54,7 @@ static unsigned int debugflags;
 #endif /* NDEBUG */
 #endif /* NDEBUG */
 
 
 static unsigned int nbds_max = 16;
 static unsigned int nbds_max = 16;
-static struct nbd_device nbd_dev[MAX_NBD];
+static struct nbd_device *nbd_dev;
 
 
 /*
 /*
  * Use just one lock (or at most 1 per NIC). Two arguments for this:
  * Use just one lock (or at most 1 per NIC). Two arguments for this:
@@ -649,11 +649,9 @@ static int __init nbd_init(void)
 
 
 	BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
 	BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
 
 
-	if (nbds_max > MAX_NBD) {
-		printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
-				nbds_max);
-		return -EINVAL;
-	}
+	nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
+	if (!nbd_dev)
+		return -ENOMEM;
 
 
 	for (i = 0; i < nbds_max; i++) {
 	for (i = 0; i < nbds_max; i++) {
 		struct gendisk *disk = alloc_disk(1);
 		struct gendisk *disk = alloc_disk(1);

+ 0 - 1
include/linux/nbd.h

@@ -35,7 +35,6 @@ enum {
 };
 };
 
 
 #define nbd_cmd(req) ((req)->cmd[0])
 #define nbd_cmd(req) ((req)->cmd[0])
-#define MAX_NBD 128
 
 
 /* userspace doesn't need the nbd_device structure */
 /* userspace doesn't need the nbd_device structure */
 #ifdef __KERNEL__
 #ifdef __KERNEL__