* [PATCH] loop: export module parameters
@ 2011-05-25 5:44 Namhyung Kim
2011-05-27 4:57 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2011-05-25 5:44 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, Laurent Vivier
Export 'max_loop' and 'max_part' parameters to sysfs so user can know
that how many devices are allowed and how many partitions are supported.
If 'max_loop' is 0, there is no restriction on the number of loop devices.
User can create/use the devices as many as minor numbers available. If
'max_part' is 0, it means simply the device doesn't support partitioning.
Also note that 'max_part' can be adjusted to power of 2 minus 1 form if
needed. User should check this value after the module loading if he/she
want to use that number correctly (i.e. fdisk, mknod, etc.).
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Laurent Vivier <Laurent.Vivier@bull.net>
---
drivers/block/loop.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index c59a672a3de0..76c8da78212b 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1540,9 +1540,9 @@ static const struct block_device_operations lo_fops = {
* And now the modules code and kernel interface.
*/
static int max_loop;
-module_param(max_loop, int, 0);
+module_param(max_loop, int, S_IRUGO);
MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
-module_param(max_part, int, 0);
+module_param(max_part, int, S_IRUGO);
MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
@@ -1688,9 +1688,20 @@ static int __init loop_init(void)
*/
part_shift = 0;
- if (max_part > 0)
+ if (max_part > 0) {
part_shift = fls(max_part);
+ /*
+ * Adjust max_part according to part_shift as it is exported
+ * to user space so that user can decide correct minor number
+ * if [s]he want to create more devices.
+ *
+ * Note that -1 is required because partition 0 is reserved
+ * for the whole disk.
+ */
+ max_part = (1UL << part_shift) - 1;
+ }
+
if ((1UL << part_shift) > DISK_MAX_PARTS)
return -EINVAL;
--
1.7.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] loop: export module parameters
2011-05-25 5:44 [PATCH] loop: export module parameters Namhyung Kim
@ 2011-05-27 4:57 ` Namhyung Kim
2011-05-27 5:59 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2011-05-27 4:57 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, Laurent Vivier
2011-05-25 (수), 14:44 +0900, Namhyung Kim:
> Export 'max_loop' and 'max_part' parameters to sysfs so user can know
> that how many devices are allowed and how many partitions are supported.
>
> If 'max_loop' is 0, there is no restriction on the number of loop devices.
> User can create/use the devices as many as minor numbers available. If
> 'max_part' is 0, it means simply the device doesn't support partitioning.
>
> Also note that 'max_part' can be adjusted to power of 2 minus 1 form if
> needed. User should check this value after the module loading if he/she
> want to use that number correctly (i.e. fdisk, mknod, etc.).
>
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> Cc: Laurent Vivier <Laurent.Vivier@bull.net>
> ---
> drivers/block/loop.c | 17 ++++++++++++++---
> 1 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index c59a672a3de0..76c8da78212b 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -1540,9 +1540,9 @@ static const struct block_device_operations lo_fops = {
> * And now the modules code and kernel interface.
> */
> static int max_loop;
> -module_param(max_loop, int, 0);
> +module_param(max_loop, int, S_IRUGO);
> MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
> -module_param(max_part, int, 0);
> +module_param(max_part, int, S_IRUGO);
> MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
> MODULE_LICENSE("GPL");
> MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
> @@ -1688,9 +1688,20 @@ static int __init loop_init(void)
> */
>
> part_shift = 0;
> - if (max_part > 0)
> + if (max_part > 0) {
> part_shift = fls(max_part);
>
> + /*
> + * Adjust max_part according to part_shift as it is exported
> + * to user space so that user can decide correct minor number
> + * if [s]he want to create more devices.
> + *
> + * Note that -1 is required because partition 0 is reserved
> + * for the whole disk.
> + */
> + max_part = (1UL << part_shift) - 1;
> + }
> +
> if ((1UL << part_shift) > DISK_MAX_PARTS)
> return -EINVAL;
>
Hi Jens,
Could you please consider applying this in your tree too? It's exactly
the same thing what I did for brd series.
Thanks.
--
Regards,
Namhyung Kim
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] loop: export module parameters
2011-05-27 4:57 ` Namhyung Kim
@ 2011-05-27 5:59 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2011-05-27 5:59 UTC (permalink / raw)
To: Namhyung Kim; +Cc: linux-kernel, Laurent Vivier
On 2011-05-27 06:57, Namhyung Kim wrote:
> 2011-05-25 (수), 14:44 +0900, Namhyung Kim:
>> Export 'max_loop' and 'max_part' parameters to sysfs so user can know
>> that how many devices are allowed and how many partitions are supported.
>>
>> If 'max_loop' is 0, there is no restriction on the number of loop devices.
>> User can create/use the devices as many as minor numbers available. If
>> 'max_part' is 0, it means simply the device doesn't support partitioning.
>>
>> Also note that 'max_part' can be adjusted to power of 2 minus 1 form if
>> needed. User should check this value after the module loading if he/she
>> want to use that number correctly (i.e. fdisk, mknod, etc.).
>>
>> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
>> Cc: Laurent Vivier <Laurent.Vivier@bull.net>
>> ---
>> drivers/block/loop.c | 17 ++++++++++++++---
>> 1 files changed, 14 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
>> index c59a672a3de0..76c8da78212b 100644
>> --- a/drivers/block/loop.c
>> +++ b/drivers/block/loop.c
>> @@ -1540,9 +1540,9 @@ static const struct block_device_operations lo_fops = {
>> * And now the modules code and kernel interface.
>> */
>> static int max_loop;
>> -module_param(max_loop, int, 0);
>> +module_param(max_loop, int, S_IRUGO);
>> MODULE_PARM_DESC(max_loop, "Maximum number of loop devices");
>> -module_param(max_part, int, 0);
>> +module_param(max_part, int, S_IRUGO);
>> MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
>> MODULE_LICENSE("GPL");
>> MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
>> @@ -1688,9 +1688,20 @@ static int __init loop_init(void)
>> */
>>
>> part_shift = 0;
>> - if (max_part > 0)
>> + if (max_part > 0) {
>> part_shift = fls(max_part);
>>
>> + /*
>> + * Adjust max_part according to part_shift as it is exported
>> + * to user space so that user can decide correct minor number
>> + * if [s]he want to create more devices.
>> + *
>> + * Note that -1 is required because partition 0 is reserved
>> + * for the whole disk.
>> + */
>> + max_part = (1UL << part_shift) - 1;
>> + }
>> +
>> if ((1UL << part_shift) > DISK_MAX_PARTS)
>> return -EINVAL;
>>
>
> Hi Jens,
>
> Could you please consider applying this in your tree too? It's exactly
> the same thing what I did for brd series.
Applied now, missed it yesterday. Thanks!
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-27 5:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 5:44 [PATCH] loop: export module parameters Namhyung Kim
2011-05-27 4:57 ` Namhyung Kim
2011-05-27 5:59 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).