]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] rd.c: separate queue per disk
authorAndrew Morton <akpm@digeo.com>
Sun, 25 May 2003 08:14:07 +0000 (01:14 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 25 May 2003 08:14:07 +0000 (01:14 -0700)
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.

drivers/block/rd.c

index 3a8c264f2c7225f5d3b615b9f1cee76143c307b6..0509a67c2eb80a522972e875dc730bc563aeb2cf 100644 (file)
@@ -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]);