Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / block / rd.c
index b3c7f07..940bfd7 100644 (file)
@@ -48,6 +48,7 @@
 #include <asm/atomic.h>
 #include <linux/bio.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/pagemap.h>
 
 #include <asm/uaccess.h>
 
-/* The RAM disk size is now a parameter */
-#define NUM_RAMDISKS 16                /* This cannot be overridden (yet) */
-
 /* Various static variables go here.  Most are used only in the RAM disk code.
  */
 
-static struct gendisk *rd_disks[NUM_RAMDISKS];
-static struct block_device *rd_bdev[NUM_RAMDISKS];/* Protected device data */
-static struct request_queue *rd_queue[NUM_RAMDISKS];
+static struct gendisk *rd_disks[CONFIG_BLK_DEV_RAM_COUNT];
+static struct block_device *rd_bdev[CONFIG_BLK_DEV_RAM_COUNT];/* Protected device data */
+static struct request_queue *rd_queue[CONFIG_BLK_DEV_RAM_COUNT];
 
 /*
  * Parameters for the boot-loading of the RAM disk.  These are set by
@@ -88,7 +86,7 @@ int rd_size = CONFIG_BLK_DEV_RAM_SIZE;                /* Size of the RAM disks */
  * behaviour. The default is still BLOCK_SIZE (needed by rd_load_image that
  * supposes the filesystem in the image uses a BLOCK_SIZE blocksize).
  */
-int rd_blocksize = BLOCK_SIZE;                 /* blocksize of the RAM disks */
+static int rd_blocksize = BLOCK_SIZE;          /* blocksize of the RAM disks */
 
 /*
  * Copyright (C) 2000 Linus Torvalds.
@@ -156,7 +154,7 @@ static int ramdisk_commit_write(struct file *file, struct page *page,
 
 /*
  * ->writepage to the the blockdev's mapping has to redirty the page so that the
- * VM doesn't go and steal it.  We return WRITEPAGE_ACTIVATE so that the VM
+ * VM doesn't go and steal it.  We return AOP_WRITEPAGE_ACTIVATE so that the VM
  * won't try to (pointlessly) write the page again for a while.
  *
  * Really, these pages should not be on the LRU at all.
@@ -167,7 +165,7 @@ static int ramdisk_writepage(struct page *page, struct writeback_control *wbc)
                make_page_uptodate(page);
        SetPageDirty(page);
        if (wbc->for_reclaim)
-               return WRITEPAGE_ACTIVATE;
+               return AOP_WRITEPAGE_ACTIVATE;
        unlock_page(page);
        return 0;
 }
@@ -188,7 +186,8 @@ static int ramdisk_writepages(struct address_space *mapping,
  */
 static int ramdisk_set_page_dirty(struct page *page)
 {
-       SetPageDirty(page);
+       if (!TestSetPageDirty(page))
+               return 1;
        return 0;
 }
 
@@ -312,12 +311,12 @@ static int rd_ioctl(struct inode *inode, struct file *file,
         * cache
         */
        error = -EBUSY;
-       down(&bdev->bd_sem);
+       mutex_lock(&bdev->bd_mutex);
        if (bdev->bd_openers <= 2) {
                truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
                error = 0;
        }
-       up(&bdev->bd_sem);
+       mutex_unlock(&bdev->bd_mutex);
        return error;
 }
 
@@ -327,7 +326,7 @@ static int rd_ioctl(struct inode *inode, struct file *file,
  */
 static struct backing_dev_info rd_backing_dev_info = {
        .ra_pages       = 0,    /* No readahead */
-       .memory_backed  = 1,    /* Does not contribute to dirty memory */
+       .capabilities   = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK | BDI_CAP_MAP_COPY,
        .unplug_io_fn   = default_unplug_io_fn,
 };
 
@@ -338,7 +337,7 @@ static struct backing_dev_info rd_backing_dev_info = {
  */
 static struct backing_dev_info rd_file_backing_dev_info = {
        .ra_pages       = 0,    /* No readahead */
-       .memory_backed  = 0,    /* Does contribute to dirty memory */
+       .capabilities   = BDI_CAP_MAP_COPY,     /* Does contribute to dirty memory */
        .unplug_io_fn   = default_unplug_io_fn,
 };
 
@@ -350,7 +349,7 @@ static int rd_open(struct inode *inode, struct file *filp)
                struct block_device *bdev = inode->i_bdev;
                struct address_space *mapping;
                unsigned bsize;
-               int gfp_mask;
+               gfp_t gfp_mask;
 
                inode = igrab(bdev->bd_inode);
                rd_bdev[unit] = bdev;
@@ -402,7 +401,7 @@ static void __exit rd_cleanup(void)
 {
        int i;
 
-       for (i = 0; i < NUM_RAMDISKS; i++) {
+       for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
                struct block_device *bdev = rd_bdev[i];
                rd_bdev[i] = NULL;
                if (bdev) {
@@ -432,7 +431,7 @@ static int __init rd_init(void)
                rd_blocksize = BLOCK_SIZE;
        }
 
-       for (i = 0; i < NUM_RAMDISKS; i++) {
+       for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
                rd_disks[i] = alloc_disk(1);
                if (!rd_disks[i])
                        goto out;
@@ -445,7 +444,7 @@ static int __init rd_init(void)
 
        devfs_mk_dir("rd");
 
-       for (i = 0; i < NUM_RAMDISKS; i++) {
+       for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
                struct gendisk *disk = rd_disks[i];
 
                rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
@@ -470,7 +469,7 @@ static int __init rd_init(void)
        /* rd_size is given in kB */
        printk("RAMDISK driver initialized: "
                "%d RAM disks of %dK size %d blocksize\n",
-               NUM_RAMDISKS, rd_size, rd_blocksize);
+               CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize);
 
        return 0;
 out_queue:
@@ -508,9 +507,10 @@ __setup("ramdisk_blocksize=", ramdisk_blocksize);
 #endif
 
 /* options - modular */
-MODULE_PARM     (rd_size, "1i");
+module_param(rd_size, int, 0);
 MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
-MODULE_PARM     (rd_blocksize, "i");
+module_param(rd_blocksize, int, 0);
 MODULE_PARM_DESC(rd_blocksize, "Blocksize of each RAM disk in bytes.");
+MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
 
 MODULE_LICENSE("GPL");