diff mbox

[J,1/1] UBUNTU: SAUCE: Revert "loop: Fix the max_loop commandline argument treatment when it is set to 0"

Message ID 20230725182707.948427-2-mfo@canonical.com
State New
Headers show

Commit Message

Mauricio Faria de Oliveira July 25, 2023, 6:27 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2015400

This reverts commit a94ed06da526df9c479046e85ceb8f112c8fa33b.

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
---
 drivers/block/loop.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 8a686e88b13c..8ce1f94d23b4 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2164,16 +2164,7 @@  static const struct block_device_operations lo_fops = {
 /*
  * And now the modules code and kernel interface.
  */
-
-/*
- * If max_loop is specified, create that many devices upfront.
- * This also becomes a hard limit. If max_loop is not specified,
- * create CONFIG_BLK_DEV_LOOP_MIN_COUNT loop devices at module
- * init time. Loop devices can be requested on-demand with the
- * /dev/loop-control interface, or be instantiated by accessing
- * a 'dead' device node.
- */
-static int max_loop = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
+static int max_loop;
 module_param(max_loop, int, 0444);
 MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
 module_param(max_part, int, 0444);
@@ -2627,7 +2618,7 @@  MODULE_ALIAS("devname:loop-control");
 
 static int __init loop_init(void)
 {
-	int i;
+	int i, nr;
 	int err;
 
 	part_shift = 0;
@@ -2655,6 +2646,19 @@  static int __init loop_init(void)
 		goto err_out;
 	}
 
+	/*
+	 * If max_loop is specified, create that many devices upfront.
+	 * This also becomes a hard limit. If max_loop is not specified,
+	 * create CONFIG_BLK_DEV_LOOP_MIN_COUNT loop devices at module
+	 * init time. Loop devices can be requested on-demand with the
+	 * /dev/loop-control interface, or be instantiated by accessing
+	 * a 'dead' device node.
+	 */
+	if (max_loop)
+		nr = max_loop;
+	else
+		nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
+
 	err = misc_register(&loop_misc);
 	if (err < 0)
 		goto err_out;
@@ -2666,7 +2670,7 @@  static int __init loop_init(void)
 	}
 
 	/* pre-create number of devices given by config or max_loop */
-	for (i = 0; i < max_loop; i++)
+	for (i = 0; i < nr; i++)
 		loop_add(i);
 
 	printk(KERN_INFO "loop: module loaded\n");