Commit cd388069 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] rd.c: separate queue per disk

From: Maneesh Soni <maneesh@in.ibm.com>

Provides a separate request queue for each ramdisk instance.  Without this,
the kernel oopses when the block later tries to unregister the same set of
kobject things multiple times.  This makes rd.c consistent with all other
"disk" devices.
parent 1e7c16a9
......@@ -67,6 +67,7 @@
static struct gendisk *rd_disks[NUM_RAMDISKS];
static struct block_device *rd_bdev[NUM_RAMDISKS];/* Protected device data */
static struct request_queue *rd_queue;
/*
* Parameters for the boot-loading of the RAM disk. These are set by
......@@ -308,12 +309,11 @@ static void __exit rd_cleanup (void)
del_gendisk(rd_disks[i]);
put_disk(rd_disks[i]);
}
kfree(rd_queue);
devfs_remove("rd");
unregister_blkdev(RAMDISK_MAJOR, "ramdisk" );
}
static struct request_queue rd_queue;
/* This is the registration and initialization section of the RAM disk driver */
static int __init rd_init (void)
{
......@@ -333,23 +333,28 @@ static int __init rd_init (void)
goto out;
}
rd_queue = kmalloc(NUM_RAMDISKS * sizeof(struct request_queue),
GFP_KERNEL);
if (!rd_queue)
goto out;
memset(rd_queue, 0, NUM_RAMDISKS * sizeof(struct request_queue));
if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) {
err = -EIO;
goto out;
goto out_queue;
}
blk_queue_make_request(&rd_queue, &rd_make_request);
devfs_mk_dir("rd");
for (i = 0; i < NUM_RAMDISKS; i++) {
struct gendisk *disk = rd_disks[i];
blk_queue_make_request(&rd_queue[i], &rd_make_request);
/* rd_size is given in kB */
disk->major = RAMDISK_MAJOR;
disk->first_minor = i;
disk->fops = &rd_bd_op;
disk->queue = &rd_queue;
disk->queue = &rd_queue[i];
sprintf(disk->disk_name, "ram%d", i);
sprintf(disk->devfs_name, "rd/%d", i);
set_capacity(disk, rd_size * 2);
......@@ -362,6 +367,8 @@ static int __init rd_init (void)
NUM_RAMDISKS, rd_size, rd_blocksize);
return 0;
out_queue:
kfree(rd_queue);
out:
while (i--)
put_disk(rd_disks[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment