diff options
Diffstat (limited to 'drivers/block/brd.c')
-rw-r--r-- | drivers/block/brd.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index e8e38faeafd8..a196ef7f147f 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -387,10 +387,14 @@ static struct block_device_operations brd_fops = { | |||
387 | */ | 387 | */ |
388 | static int rd_nr; | 388 | static int rd_nr; |
389 | int rd_size = CONFIG_BLK_DEV_RAM_SIZE; | 389 | int rd_size = CONFIG_BLK_DEV_RAM_SIZE; |
390 | static int max_part; | ||
391 | static int part_shift; | ||
390 | module_param(rd_nr, int, 0); | 392 | module_param(rd_nr, int, 0); |
391 | MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); | 393 | MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); |
392 | module_param(rd_size, int, 0); | 394 | module_param(rd_size, int, 0); |
393 | MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); | 395 | MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); |
396 | module_param(max_part, int, 0); | ||
397 | MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk"); | ||
394 | MODULE_LICENSE("GPL"); | 398 | MODULE_LICENSE("GPL"); |
395 | MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); | 399 | MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); |
396 | 400 | ||
@@ -435,11 +439,11 @@ static struct brd_device *brd_alloc(int i) | |||
435 | blk_queue_max_sectors(brd->brd_queue, 1024); | 439 | blk_queue_max_sectors(brd->brd_queue, 1024); |
436 | blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); | 440 | blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); |
437 | 441 | ||
438 | disk = brd->brd_disk = alloc_disk(1); | 442 | disk = brd->brd_disk = alloc_disk(1 << part_shift); |
439 | if (!disk) | 443 | if (!disk) |
440 | goto out_free_queue; | 444 | goto out_free_queue; |
441 | disk->major = RAMDISK_MAJOR; | 445 | disk->major = RAMDISK_MAJOR; |
442 | disk->first_minor = i; | 446 | disk->first_minor = i << part_shift; |
443 | disk->fops = &brd_fops; | 447 | disk->fops = &brd_fops; |
444 | disk->private_data = brd; | 448 | disk->private_data = brd; |
445 | disk->queue = brd->brd_queue; | 449 | disk->queue = brd->brd_queue; |
@@ -523,7 +527,12 @@ static int __init brd_init(void) | |||
523 | * themselves and have kernel automatically instantiate actual | 527 | * themselves and have kernel automatically instantiate actual |
524 | * device on-demand. | 528 | * device on-demand. |
525 | */ | 529 | */ |
526 | if (rd_nr > 1UL << MINORBITS) | 530 | |
531 | part_shift = 0; | ||
532 | if (max_part > 0) | ||
533 | part_shift = fls(max_part); | ||
534 | |||
535 | if (rd_nr > 1UL << (MINORBITS - part_shift)) | ||
527 | return -EINVAL; | 536 | return -EINVAL; |
528 | 537 | ||
529 | if (rd_nr) { | 538 | if (rd_nr) { |
@@ -531,7 +540,7 @@ static int __init brd_init(void) | |||
531 | range = rd_nr; | 540 | range = rd_nr; |
532 | } else { | 541 | } else { |
533 | nr = CONFIG_BLK_DEV_RAM_COUNT; | 542 | nr = CONFIG_BLK_DEV_RAM_COUNT; |
534 | range = 1UL << MINORBITS; | 543 | range = 1UL << (MINORBITS - part_shift); |
535 | } | 544 | } |
536 | 545 | ||
537 | if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) | 546 | if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) |
@@ -570,7 +579,7 @@ static void __exit brd_exit(void) | |||
570 | unsigned long range; | 579 | unsigned long range; |
571 | struct brd_device *brd, *next; | 580 | struct brd_device *brd, *next; |
572 | 581 | ||
573 | range = rd_nr ? rd_nr : 1UL << MINORBITS; | 582 | range = rd_nr ? rd_nr : 1UL << (MINORBITS - part_shift); |
574 | 583 | ||
575 | list_for_each_entry_safe(brd, next, &brd_devices, brd_list) | 584 | list_for_each_entry_safe(brd, next, &brd_devices, brd_list) |
576 | brd_del_one(brd); | 585 | brd_del_one(brd); |