Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252253
b: refs/heads/master
c: 8892cba
h: refs/heads/master
i:
  252251: cac0a67
v: v3
  • Loading branch information
Namhyung Kim authored and Jens Axboe committed May 26, 2011
1 parent 2146019 commit e816991
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 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: 13868b76ab8135389fe1d8cf1c6a4847c9fef0a7
refs/heads/master: 8892cbaf686fb18a5f0558b9fd7773b32c0c7852
19 changes: 15 additions & 4 deletions trunk/drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ static int rd_nr;
int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
static int max_part;
static int part_shift;
module_param(rd_nr, int, 0);
module_param(rd_nr, int, S_IRUGO);
MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
module_param(rd_size, int, 0);
module_param(rd_size, int, S_IRUGO);
MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
module_param(max_part, int, 0);
module_param(max_part, int, S_IRUGO);
MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
Expand Down Expand Up @@ -578,9 +578,20 @@ static int __init brd_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;

Expand Down

0 comments on commit e816991

Please sign in to comment.