Configure the maximum number of loopback devices
PATCH 1/1 Configure the maximum number of loopback devices
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 <[email protected]>
drivers/block/Kconfig +8 -0
@@ -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
drivers/block/loop.c +14 -10
@@ -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 <[email protected]>, 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);