|
@@ -387,10 +387,14 @@ static struct block_device_operations brd_fops = {
|
|
*/
|
|
*/
|
|
static int rd_nr;
|
|
static int rd_nr;
|
|
int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
|
|
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, 0);
|
|
MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
|
|
MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
|
|
module_param(rd_size, int, 0);
|
|
module_param(rd_size, int, 0);
|
|
MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
|
|
MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
|
|
|
|
+module_param(max_part, int, 0);
|
|
|
|
+MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
|
|
MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
|
|
|
|
|
|
@@ -435,11 +439,11 @@ static struct brd_device *brd_alloc(int i)
|
|
blk_queue_max_sectors(brd->brd_queue, 1024);
|
|
blk_queue_max_sectors(brd->brd_queue, 1024);
|
|
blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
|
|
blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
|
|
|
|
|
|
- disk = brd->brd_disk = alloc_disk(1);
|
|
|
|
|
|
+ disk = brd->brd_disk = alloc_disk(1 << part_shift);
|
|
if (!disk)
|
|
if (!disk)
|
|
goto out_free_queue;
|
|
goto out_free_queue;
|
|
disk->major = RAMDISK_MAJOR;
|
|
disk->major = RAMDISK_MAJOR;
|
|
- disk->first_minor = i;
|
|
|
|
|
|
+ disk->first_minor = i << part_shift;
|
|
disk->fops = &brd_fops;
|
|
disk->fops = &brd_fops;
|
|
disk->private_data = brd;
|
|
disk->private_data = brd;
|
|
disk->queue = brd->brd_queue;
|
|
disk->queue = brd->brd_queue;
|
|
@@ -523,7 +527,12 @@ static int __init brd_init(void)
|
|
* themselves and have kernel automatically instantiate actual
|
|
* themselves and have kernel automatically instantiate actual
|
|
* device on-demand.
|
|
* device on-demand.
|
|
*/
|
|
*/
|
|
- if (rd_nr > 1UL << MINORBITS)
|
|
|
|
|
|
+
|
|
|
|
+ part_shift = 0;
|
|
|
|
+ if (max_part > 0)
|
|
|
|
+ part_shift = fls(max_part);
|
|
|
|
+
|
|
|
|
+ if (rd_nr > 1UL << (MINORBITS - part_shift))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
if (rd_nr) {
|
|
if (rd_nr) {
|
|
@@ -531,7 +540,7 @@ static int __init brd_init(void)
|
|
range = rd_nr;
|
|
range = rd_nr;
|
|
} else {
|
|
} else {
|
|
nr = CONFIG_BLK_DEV_RAM_COUNT;
|
|
nr = CONFIG_BLK_DEV_RAM_COUNT;
|
|
- range = 1UL << MINORBITS;
|
|
|
|
|
|
+ range = 1UL << (MINORBITS - part_shift);
|
|
}
|
|
}
|
|
|
|
|
|
if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
|
|
if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
|
|
@@ -570,7 +579,7 @@ static void __exit brd_exit(void)
|
|
unsigned long range;
|
|
unsigned long range;
|
|
struct brd_device *brd, *next;
|
|
struct brd_device *brd, *next;
|
|
|
|
|
|
- range = rd_nr ? rd_nr : 1UL << MINORBITS;
|
|
|
|
|
|
+ range = rd_nr ? rd_nr : 1UL << (MINORBITS - part_shift);
|
|
|
|
|
|
list_for_each_entry_safe(brd, next, &brd_devices, brd_list)
|
|
list_for_each_entry_safe(brd, next, &brd_devices, brd_list)
|
|
brd_del_one(brd);
|
|
brd_del_one(brd);
|