From: Andrew Morton <akpm@linux-foundation.org>
To: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: axboe@suse.de, linux-kernel@vger.kernel.org, Laurent.Vivier@bull.net
Subject: Re: [PATCH][RESEND][v3] Modify loop device to be able to manage partitions of the disk image
Date: Tue, 18 Mar 2008 13:54:23 -0700 [thread overview]
Message-ID: <20080318135423.6c7b745f.akpm@linux-foundation.org> (raw)
In-Reply-To: <12058427603971-git-send-email-Laurent.Vivier@bull.net>
On Tue, 18 Mar 2008 13:19:20 +0100
Laurent Vivier <Laurent.Vivier@bull.net> wrote:
> v3 is an updated version of v2, replacing a "%d" by a "%lu".
>
> This patch allows to use loop device with partitionned disk image.
>
> Original behavior of loop is not modified.
>
> A new parameter is introduced to define how many partition we want to be
> able to manage per loop device. This parameter is "loop_max_part".
>
> For instance, to manage 63 partitions / loop device, we will do:
> # modprobe loop loop_max_part=63
> # ls -l /dev/loop?
> brw-rw---- 1 root disk 7, 0 2008-03-05 14:55 /dev/loop0
> brw-rw---- 1 root disk 7, 64 2008-03-05 14:55 /dev/loop1
> brw-rw---- 1 root disk 7, 128 2008-03-05 14:55 /dev/loop2
> brw-rw---- 1 root disk 7, 192 2008-03-05 14:55 /dev/loop3
> brw-rw---- 1 root disk 7, 256 2008-03-05 14:55 /dev/loop4
> brw-rw---- 1 root disk 7, 320 2008-03-05 14:55 /dev/loop5
> brw-rw---- 1 root disk 7, 384 2008-03-05 14:55 /dev/loop6
> brw-rw---- 1 root disk 7, 448 2008-03-05 14:55 /dev/loop7
>
> And to attach a raw partitionned disk image, the original losetup is used:
>
> # losetup -f etch.img
> EXT3 FS on loop0p1, internal journal
> EXT3-fs: mounted filesystem with ordered data mode.
> loop: module loaded
> loop0: p1 p2 < p5 >
> # ls -l /dev/loop?*
> brw-rw---- 1 root disk 7, 0 2008-03-05 14:55 /dev/loop0
> brw-rw---- 1 root disk 7, 1 2008-03-05 14:57 /dev/loop0p1
> brw-rw---- 1 root disk 7, 2 2008-03-05 14:57 /dev/loop0p2
> brw-rw---- 1 root disk 7, 5 2008-03-05 14:57 /dev/loop0p5
> brw-rw---- 1 root disk 7, 64 2008-03-05 14:55 /dev/loop1
> brw-rw---- 1 root disk 7, 128 2008-03-05 14:55 /dev/loop2
> brw-rw---- 1 root disk 7, 192 2008-03-05 14:55 /dev/loop3
> brw-rw---- 1 root disk 7, 256 2008-03-05 14:55 /dev/loop4
> brw-rw---- 1 root disk 7, 320 2008-03-05 14:55 /dev/loop5
> brw-rw---- 1 root disk 7, 384 2008-03-05 14:55 /dev/loop6
> brw-rw---- 1 root disk 7, 448 2008-03-05 14:55 /dev/loop7
> # mount /dev/loop0p1 /mnt
> kjournald starting. Commit interval 5 seconds
> EXT3 FS on loop0p1, internal journal
> EXT3-fs: mounted filesystem with ordered data mode.
> # ls /mnt
> bench cdrom home lib mnt root srv usr
> bin dev initrd lost+found opt sbin sys var
> boot etc initrd.img media proc selinux tmp vmlinuz
> # umount /mnt
> # losetup -d /dev/loop0
>
> Of course, the same behavior can be done using kpartx on a loop device,
> but modifying loop avoids to stack several layers of block device (loop +
> device mapper), this is a very light modification (40% of modifications
> are to manage the new parameter).
>
> ...
>
> index 9a5b665..7f2fd52 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -1075,6 +1075,10 @@ and is between 256 and 4096 characters. It is defined in the file
> be mounted
> Format: <1-256>
>
> + loop_max_part= [LOOP] Maximum number of partitions per loopback device.
> + Should be greater than 0, the maximum value depends
> + on max_loop.
> +
This shouldn't be needed.
> @@ -1360,6 +1367,8 @@ static struct block_device_operations lo_fops = {
> static int max_loop;
> module_param(max_loop, int, 0);
> MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
> +module_param(loop_max_part, int, 0);
> +MODULE_PARM_DESC(loop_max_part, "Maximum number of partitions per loop device");
Because this module_param() gives us the loop.loop_max_part=N kernel boot
parameter.
Given which, I think we could rename it to just "max_part":
modprobe loop max_part=4
kernel vmlinuz-... loop.max_part=4
?
> __setup("max_loop=", max_loop_setup);
That could go away in the same way, but we have a back-compat problem.
> +
> +static int __init max_part_setup(char *str)
> +{
> + loop_max_part = simple_strtol(str, NULL, 0);
> + if (loop_max_part > (1UL << (MINORBITS - 1))) {
> + /* we must keep at least one bit for loop device number */
> + printk(KERN_ERR
> + "loop: loop_max_part cannot be greater than %lu\n",
> + 1UL << (MINORBITS - 1));
> + return 0;
> + }
> + return 1;
> +}
> +
> +__setup("loop_max_part=", max_part_setup);
next prev parent reply other threads:[~2008-03-19 20:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-18 12:19 Laurent Vivier
2008-03-18 20:54 ` Andrew Morton [this message]
2008-03-19 12:36 ` [PATCH][v4] " Laurent Vivier
2008-03-19 20:11 ` Randy Dunlap
2008-03-19 20:24 ` Laurent Vivier
2008-03-19 21:28 ` Andrew Morton
2008-03-19 21:39 ` Laurent Vivier
2008-03-19 21:43 ` Andrew Morton
2008-03-19 23:03 ` Randy Dunlap
2008-03-20 21:36 ` Bill Davidsen
2008-03-19 20:24 ` [PATCH][RESEND][v3] " Bill Davidsen
2008-03-19 20:32 ` Laurent Vivier
2008-03-23 23:33 ` Bill Davidsen
2008-03-25 10:34 ` [PATCH] Modify Network Block Device (nbd) to be able to manage partitions Laurent Vivier
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=20080318135423.6c7b745f.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Laurent.Vivier@bull.net \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome