lkml.org 
[lkml]   [2004]   [Dec]   [10]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
FromKeith Owens <>
Subject[patch 2.6.10-rc3] Configure the maximum number of loopback devices
DateFri, 10 Dec 2004 18:01:48 +1100
Linux juke box servers can have more than 256 images loaded, so make
the maximum number of loopback devices a config option.  The default is
256 (no change).

Signed-off-by: Keith Owens <kaos@ocs.com.au>

Index: linux/drivers/block/Kconfig
===================================================================
--- linux.orig/drivers/block/Kconfig	Thu Dec  9 16:52:50 2004
+++ linux/drivers/block/Kconfig	Fri Dec 10 17:02:14 2004
@@ -251,6 +251,14 @@ config BLK_DEV_LOOP
 
 	  Most users will answer N here.
 
+config BLK_DEV_LOOP_MAX
+	int "Maximum number of loopback devices" if BLK_DEV_LOOP
+	default "256"
+	help
+          The default maximum number of loopback devices is 256. Set a
+          larger maximum if you need more than 256 loopback mounts.
+          Most users should take the default value.
+
 config BLK_DEV_CRYPTOLOOP
 	tristate "Cryptoloop Support"
 	select CRYPTO
Index: linux/drivers/block/loop.c
===================================================================
--- linux.orig/drivers/block/loop.c	Thu Dec  9 16:52:27 2004
+++ linux/drivers/block/loop.c	Fri Dec 10 17:48:49 2004
@@ -43,6 +43,9 @@
  * - Advisory locking is ignored here.
  * - Should use an own CAP_* category instead of CAP_SYS_ADMIN
  *
+ * Make the maximum loop count a config variable.
+ * Keith Owens <kaos@ocs.com.au>, Dec 2004
+ *
  */
 
 #include <linux/config.h>
@@ -67,6 +70,7 @@
 #include <linux/writeback.h>
 #include <linux/buffer_head.h>		/* for invalidate_bdev() */
 #include <linux/completion.h>
+#include <linux/vmalloc.h>
 
 #include <asm/uaccess.h>
 
@@ -1074,7 +1078,7 @@ static struct block_device_operations lo
  * And now the modules code and kernel interface.
  */
 module_param(max_loop, int, 0);
-MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)");
+MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-" __stringify(CONFIG_BLK_DEV_LOOP_MAX) ")");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
 
@@ -1118,21 +1122,21 @@ int __init loop_init(void)
 {
 	int	i;
 
-	if (max_loop < 1 || max_loop > 256) {
+	if (max_loop < 1 || max_loop > CONFIG_BLK_DEV_LOOP_MAX) {
 		printk(KERN_WARNING "loop: invalid max_loop (must be between"
-				    " 1 and 256), using default (8)\n");
+				    " 1 and " __stringify(CONFIG_BLK_DEV_LOOP_MAX) "), using default (8)\n");
 		max_loop = 8;
 	}
 
 	if (register_blkdev(LOOP_MAJOR, "loop"))
 		return -EIO;
 
-	loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
+	loop_dev = vmalloc(max_loop * sizeof(*loop_dev));
 	if (!loop_dev)
 		goto out_mem1;
-	memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
+	memset(loop_dev, 0, max_loop * sizeof(*loop_dev));
 
-	disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
+	disks = vmalloc(max_loop * sizeof(*disks));
 	if (!disks)
 		goto out_mem2;
 
@@ -1180,9 +1184,9 @@ out_mem4:
 out_mem3:
 	while (i--)
 		put_disk(disks[i]);
-	kfree(disks);
+	vfree(disks);
 out_mem2:
-	kfree(loop_dev);
+	vfree(loop_dev);
 out_mem1:
 	unregister_blkdev(LOOP_MAJOR, "loop");
 	printk(KERN_ERR "loop: ran out of memory\n");
@@ -1202,8 +1206,8 @@ void loop_exit(void)
 	if (unregister_blkdev(LOOP_MAJOR, "loop"))
 		printk(KERN_WARNING "loop: cannot unregister blkdev\n");
 
-	kfree(disks);
-	kfree(loop_dev);
+	vfree(disks);
+	vfree(loop_dev);
 }
 
 module_init(loop_init);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [from the cache]
©2003-2008