diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-05-26 15:06:50 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2011-05-26 15:06:50 -0400 |
commit | 8892cbaf686fb18a5f0558b9fd7773b32c0c7852 (patch) | |
tree | d42261b88e9ead68894e226d8d9afc838fa7cfb1 | |
parent | 13868b76ab8135389fe1d8cf1c6a4847c9fef0a7 (diff) |
brd: export module parameters
Export 'rd_nr', 'rd_size' and 'max_part' parameters to sysfs so user can
know that how many devices are allowed, how big each device is and how
many partitions are supported. 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>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
-rw-r--r-- | drivers/block/brd.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index d904d0da2928..dba1c32e1ddf 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -436,11 +436,11 @@ static int rd_nr; | |||
436 | int rd_size = CONFIG_BLK_DEV_RAM_SIZE; | 436 | int rd_size = CONFIG_BLK_DEV_RAM_SIZE; |
437 | static int max_part; | 437 | static int max_part; |
438 | static int part_shift; | 438 | static int part_shift; |
439 | module_param(rd_nr, int, 0); | 439 | module_param(rd_nr, int, S_IRUGO); |
440 | MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); | 440 | MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); |
441 | module_param(rd_size, int, 0); | 441 | module_param(rd_size, int, S_IRUGO); |
442 | MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); | 442 | MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); |
443 | module_param(max_part, int, 0); | 443 | module_param(max_part, int, S_IRUGO); |
444 | MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); | 444 | MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); |
445 | MODULE_LICENSE("GPL"); | 445 | MODULE_LICENSE("GPL"); |
446 | MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); | 446 | MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); |
@@ -578,9 +578,20 @@ static int __init brd_init(void) | |||
578 | */ | 578 | */ |
579 | 579 | ||
580 | part_shift = 0; | 580 | part_shift = 0; |
581 | if (max_part > 0) | 581 | if (max_part > 0) { |
582 | part_shift = fls(max_part); | 582 | part_shift = fls(max_part); |
583 | 583 | ||
584 | /* | ||
585 | * Adjust max_part according to part_shift as it is exported | ||
586 | * to user space so that user can decide correct minor number | ||
587 | * if [s]he want to create more devices. | ||
588 | * | ||
589 | * Note that -1 is required because partition 0 is reserved | ||
590 | * for the whole disk. | ||
591 | */ | ||
592 | max_part = (1UL << part_shift) - 1; | ||
593 | } | ||
594 | |||
584 | if ((1UL << part_shift) > DISK_MAX_PARTS) | 595 | if ((1UL << part_shift) > DISK_MAX_PARTS) |
585 | return -EINVAL; | 596 | return -EINVAL; |
586 | 597 | ||