Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263131
b: refs/heads/master
c: d134b00
h: refs/heads/master
i:
  263129: a2d9c10
  263127: ceb0d1c
v: v3
  • Loading branch information
Kay Sievers authored and Jens Axboe committed Jul 31, 2011
1 parent cfa2303 commit 0cf3d80
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 770fe30a46a12b6fb6b63fbe1737654d28e84844
refs/heads/master: d134b00b9acca3fb054d7c88a5f5d562ecbb42d1
9 changes: 6 additions & 3 deletions trunk/Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
it is equivalent to "nosmp", which also disables
the IO APIC.

max_loop= [LOOP] Maximum number of loopback devices that can
be mounted
Format: <1-256>
max_loop= [LOOP] The number of loop block devices that get
(loop.max_loop) unconditionally pre-created at init time. The default
number is configured by BLK_DEV_LOOP_MIN_COUNT. Instead
of statically allocating a predefined number, loop
devices can be requested on-demand with the
/dev/loop-control interface.

mcatest= [IA-64]

Expand Down
15 changes: 15 additions & 0 deletions trunk/drivers/block/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ config BLK_DEV_LOOP

Most users will answer N here.

config BLK_DEV_LOOP_MIN_COUNT
int "Number of loop devices to pre-create at init time"
depends on BLK_DEV_LOOP
default 8
help
Static number of loop devices to be unconditionally pre-created
at init time.

This default value can be overwritten on the kernel command
line or with module-parameter loop.max_loop.

The historic default is 8. If a late 2011 version of losetup(8)
is used, it can be set to 0, since needed loop devices can be
dynamically allocated with the /dev/loop-control interface.

config BLK_DEV_CRYPTOLOOP
tristate "Cryptoloop Support"
select CRYPTO
Expand Down
27 changes: 10 additions & 17 deletions trunk/drivers/block/loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,21 +1793,6 @@ static int __init loop_init(void)
struct loop_device *lo;
int err;

/*
* 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.
*/

err = misc_register(&loop_misc);
if (err < 0)
return err;
Expand All @@ -1833,11 +1818,19 @@ static int __init loop_init(void)
if (max_loop > 1UL << (MINORBITS - part_shift))
return -EINVAL;

/*
* 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;
range = max_loop << part_shift;
} else {
nr = 8;
nr = CONFIG_BLK_DEV_LOOP_MIN_COUNT;
range = 1UL << MINORBITS;
}

Expand All @@ -1847,7 +1840,7 @@ static int __init loop_init(void)
blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
THIS_MODULE, loop_probe, NULL, NULL);

/* pre-create number devices of devices given by config or max_loop */
/* pre-create number of devices given by config or max_loop */
mutex_lock(&loop_index_mutex);
for (i = 0; i < nr; i++)
loop_add(&lo, i);
Expand Down

0 comments on commit 0cf3d80

Please sign in to comment.