Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95294
b: refs/heads/master
c: d7853d1
h: refs/heads/master
v: v3
  • Loading branch information
Laurent Vivier authored and Linus Torvalds committed Apr 30, 2008
1 parent b9b7331 commit 9d6aeec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 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: 237fc6e7a35076f584b9d0794a5204fe4bd9b9e5
refs/heads/master: d7853d1f8932c847a8d7b3b38e6baedf77148cfb
19 changes: 14 additions & 5 deletions trunk/drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,14 @@ static struct block_device_operations brd_fops = {
*/
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_PARM_DESC(rd_nr, "Maximum number of brd devices");
module_param(rd_size, int, 0);
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_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);

Expand Down Expand Up @@ -435,11 +439,11 @@ static struct brd_device *brd_alloc(int i)
blk_queue_max_sectors(brd->brd_queue, 1024);
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)
goto out_free_queue;
disk->major = RAMDISK_MAJOR;
disk->first_minor = i;
disk->first_minor = i << part_shift;
disk->fops = &brd_fops;
disk->private_data = brd;
disk->queue = brd->brd_queue;
Expand Down Expand Up @@ -523,15 +527,20 @@ static int __init brd_init(void)
* themselves and have kernel automatically instantiate actual
* 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;

if (rd_nr) {
nr = rd_nr;
range = rd_nr;
} else {
nr = CONFIG_BLK_DEV_RAM_COUNT;
range = 1UL << MINORBITS;
range = 1UL << (MINORBITS - part_shift);
}

if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
Expand Down Expand Up @@ -570,7 +579,7 @@ static void __exit brd_exit(void)
unsigned long range;
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)
brd_del_one(brd);
Expand Down

0 comments on commit 9d6aeec

Please sign in to comment.