From: "Ken Chen" <kenchen@google.com>
To: "Linus Torvalds" <torvalds@linux-foundation.org>
Cc: "Kay Sievers" <kay.sievers@vrfy.org>,
"Ray Lee" <ray-lk@madrabbit.org>,
"Al Viro" <viro@ftp.linux.org.uk>,
"Andrey Borzenkov" <arvidjaar@mail.ru>,
"Uwe Bugla" <uwe.bugla@gmx.de>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Michal Piotrowski" <michal.k.k.piotrowski@gmail.com>
Subject: Re: bug in 2.6.22-rc2: loop mount limited to one single iso image
Date: Mon, 21 May 2007 13:48:26 -0700 [thread overview]
Message-ID: <b040c32a0705211348r664e37f4hf03bec6ab27a7139@mail.gmail.com> (raw)
In-Reply-To: <b040c32a0705210937x3d1b8ac6wb9c8089337f5c683@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3820 bytes --]
On 5/21/07, Ken Chen <kenchen@google.com> wrote:
> The easiest way is to reinstate max_loop and create "max_loop" device
> up front at module load time. However, that will lose all the "fancy
> on-demand device instantiation feature".
>
> So I propose we do the following:
>
> 1. have the module honor "max_loop" parameter and create that many
> device upfront on module load (max_loop will also be a hard max) iff
> user specify the parameter.
> 2. if max_loop is not specified, default create 8 loop device. User
> can extent more loop device by create device node themselves and have
> kernel automatically instantiate loop device on-demand.
>
> Is this acceptable? Patch in a bit.
>
Could people who has problem with loop device please test this? I
tested it on my Ubuntu feisty distribution and it works fine. Though I
typically don't use loop device at all.
---
The kernel on-demand loop device instantiation breaks several user
space tools as the tools are not ready to cope with the "on-demand
feature". Fix it by instantiate default 8 loop devices and also
reinstate max_loop module parameter.
Signed-off-by: Ken Chen <kenchen@google.com>
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 5526ead..0aae8d8 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1354,7 +1354,7 @@ #endif
*/
static int max_loop;
module_param(max_loop, int, 0);
-MODULE_PARM_DESC(max_loop, "obsolete, loop device is created on-demand");
+MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
@@ -1462,34 +1462,66 @@ static struct kobject *loop_probe(dev_t
return kobj;
}
-static int __init loop_init(void)
-{
- if (register_blkdev(LOOP_MAJOR, "loop"))
- return -EIO;
- blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS,
- THIS_MODULE, loop_probe, NULL, NULL);
-
- if (max_loop) {
- printk(KERN_INFO "loop: the max_loop option is obsolete "
- "and will be removed in March 2008\n");
-
- }
- printk(KERN_INFO "loop: module loaded\n");
- return 0;
-}
-
static void __exit loop_exit(void)
{
+ unsigned long range;
struct loop_device *lo, *next;
+ range = max_loop ? max_loop : 1UL << MINORBITS;
+
list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
loop_del_one(lo);
- blk_unregister_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS);
+ blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range);
if (unregister_blkdev(LOOP_MAJOR, "loop"))
printk(KERN_WARNING "loop: cannot unregister blkdev\n");
}
+static int __init loop_init(void)
+{
+ int i, nr;
+ unsigned long range;
+
+ /*
+ * loop module now has a feature to instantiate underlying device
+ * structure on-demand, provided that there is an access dev node.
+ * However, this will not work well with user space tool that doesn't
+ * know about such "feature". In order to not break any existing
+ * tool, we do the following:
+ *
+ * (1) if max_loop is specified, create that many upfront, and this
+ * also becomes a hard limit.
+ * (2) if max_loop is not specified, create 8 loop device on module
+ * load, user can further extend loop device by create dev node
+ * themselves and have kernel automatically instantiate actual
+ * device on-demand.
+ */
+ if (max_loop) {
+ nr = max_loop;
+ range = max_loop;
+ } else {
+ nr = 8;
+ range = 1UL << MINORBITS;
+ }
+
+ if (register_blkdev(LOOP_MAJOR, "loop"))
+ return -EIO;
+ blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
+ THIS_MODULE, loop_probe, NULL, NULL);
+
+ for (i = 0; i < nr; i++) {
+ if (!loop_init_one(i))
+ goto err;
+ }
+
+ printk(KERN_INFO "loop: module loaded\n");
+ return 0;
+err:
+ loop_exit();
+ printk(KERN_INFO "loop: out of memory\n");
+ return -ENOMEM;
+}
+
module_init(loop_init);
module_exit(loop_exit);
[-- Attachment #2: loop_default_8.patch --]
[-- Type: text/x-patch, Size: 2670 bytes --]
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 5526ead..0aae8d8 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1354,7 +1354,7 @@ #endif
*/
static int max_loop;
module_param(max_loop, int, 0);
-MODULE_PARM_DESC(max_loop, "obsolete, loop device is created on-demand");
+MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
@@ -1462,34 +1462,66 @@ static struct kobject *loop_probe(dev_t
return kobj;
}
-static int __init loop_init(void)
-{
- if (register_blkdev(LOOP_MAJOR, "loop"))
- return -EIO;
- blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS,
- THIS_MODULE, loop_probe, NULL, NULL);
-
- if (max_loop) {
- printk(KERN_INFO "loop: the max_loop option is obsolete "
- "and will be removed in March 2008\n");
-
- }
- printk(KERN_INFO "loop: module loaded\n");
- return 0;
-}
-
static void __exit loop_exit(void)
{
+ unsigned long range;
struct loop_device *lo, *next;
+ range = max_loop ? max_loop : 1UL << MINORBITS;
+
list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
loop_del_one(lo);
- blk_unregister_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS);
+ blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range);
if (unregister_blkdev(LOOP_MAJOR, "loop"))
printk(KERN_WARNING "loop: cannot unregister blkdev\n");
}
+static int __init loop_init(void)
+{
+ int i, nr;
+ unsigned long range;
+
+ /*
+ * loop module now has a feature to instantiate underlying device
+ * structure on-demand, provided that there is an access dev node.
+ * However, this will not work well with user space tool that doesn't
+ * know about such "feature". In order to not break any existing
+ * tool, we do the following:
+ *
+ * (1) if max_loop is specified, create that many upfront, and this
+ * also becomes a hard limit.
+ * (2) if max_loop is not specified, create 8 loop device on module
+ * load, user can further extend loop device by create dev node
+ * themselves and have kernel automatically instantiate actual
+ * device on-demand.
+ */
+ if (max_loop) {
+ nr = max_loop;
+ range = max_loop;
+ } else {
+ nr = 8;
+ range = 1UL << MINORBITS;
+ }
+
+ if (register_blkdev(LOOP_MAJOR, "loop"))
+ return -EIO;
+ blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
+ THIS_MODULE, loop_probe, NULL, NULL);
+
+ for (i = 0; i < nr; i++) {
+ if (!loop_init_one(i))
+ goto err;
+ }
+
+ printk(KERN_INFO "loop: module loaded\n");
+ return 0;
+err:
+ loop_exit();
+ printk(KERN_INFO "loop: out of memory\n");
+ return -ENOMEM;
+}
+
module_init(loop_init);
module_exit(loop_exit);
next prev parent reply other threads:[~2007-05-21 20:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-19 18:33 Ray Lee
2007-05-19 19:17 ` Andrey Borzenkov
[not found] ` <200705200124.13026.uwe.bugla@gmx.de>
2007-05-20 4:45 ` Andrey Borzenkov
2007-05-20 6:16 ` Ray Lee
2007-05-20 6:28 ` Al Viro
2007-05-20 6:58 ` Andrey Borzenkov
2007-05-20 14:52 ` Uwe Bugla
2007-05-20 15:26 ` Ray Lee
2007-05-20 15:22 ` Ray Lee
2007-05-20 15:54 ` Kay Sievers
2007-05-20 16:02 ` Andrey Borzenkov
2007-05-20 16:23 ` Andreas Schwab
2007-05-20 16:10 ` Ray Lee
2007-05-20 16:16 ` Kay Sievers
2007-05-20 16:29 ` Uwe Bugla
2007-05-20 19:53 ` Michael Mauch
2007-05-21 16:11 ` Linus Torvalds
2007-05-21 16:27 ` Ken Chen
2007-05-21 16:35 ` Ray Lee
2007-05-21 16:37 ` Ken Chen
2007-05-21 16:50 ` Uwe Bugla
2007-05-21 17:11 ` Kay Sievers
2007-05-21 17:51 ` Andrey Borzenkov
2007-05-21 17:04 ` Linus Torvalds
2007-05-21 20:48 ` Ken Chen [this message]
2007-05-21 21:20 ` Uwe Bugla
2007-05-21 22:04 ` Andrew Morton
2007-05-22 0:10 ` Al Viro
2007-05-22 0:13 ` Al Viro
2007-05-20 16:09 ` Andrey Borzenkov
2007-05-20 16:14 ` Ray Lee
2007-05-22 20:18 ` Jan Engelhardt
2007-05-22 21:35 ` Uwe Bugla
2007-05-21 6:08 ` Ken Chen
2007-05-21 6:40 ` Ray Lee
2007-05-21 7:59 ` Uwe Bugla
-- strict thread matches above, loose matches on Subject: below --
2007-05-19 13:53 Uwe Bugla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b040c32a0705211348r664e37f4hf03bec6ab27a7139@mail.gmail.com \
--to=kenchen@google.com \
--cc=akpm@linux-foundation.org \
--cc=arvidjaar@mail.ru \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.k.k.piotrowski@gmail.com \
--cc=ray-lk@madrabbit.org \
--cc=torvalds@linux-foundation.org \
--cc=uwe.bugla@gmx.de \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®