block: get rid of elevator_t typedef
[safe/jmp/linux-2.6] / block / genhd.c
index 32ee73c..2f7feda 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
+#include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/kmod.h>
@@ -358,7 +359,6 @@ static int blk_mangle_minor(int minor)
 /**
  * blk_alloc_devt - allocate a dev_t for a partition
  * @part: partition to allocate dev_t for
- * @gfp_mask: memory allocation flag
  * @devt: out parameter for resulting dev_t
  *
  * Allocate a dev_t for block device.
@@ -535,7 +535,7 @@ void unlink_gendisk(struct gendisk *disk)
 /**
  * get_gendisk - get partitioning information for a given device
  * @devt: device to get partitioning information for
- * @part: returned partition index
+ * @partno: returned partition index
  *
  * This function gets the structure containing partitioning
  * information for the given device @devt.
@@ -584,7 +584,7 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno)
        struct block_device *bdev = NULL;
 
        part = disk_get_part(disk, partno);
-       if (part && (part->nr_sects || partno == 0))
+       if (part)
                bdev = bdget(part_devt(part));
        disk_put_part(part);
 
@@ -697,7 +697,7 @@ static void *show_partition_start(struct seq_file *seqf, loff_t *pos)
        static void *p;
 
        p = disk_seqf_start(seqf, pos);
-       if (!IS_ERR(p) && p)
+       if (!IS_ERR(p) && p && !*pos)
                seq_puts(seqf, "major minor  #blocks  name\n\n");
        return p;
 }
@@ -728,12 +728,24 @@ static int show_partition(struct seq_file *seqf, void *v)
        return 0;
 }
 
-const struct seq_operations partitions_op = {
+static const struct seq_operations partitions_op = {
        .start  = show_partition_start,
        .next   = disk_seqf_next,
        .stop   = disk_seqf_stop,
        .show   = show_partition
 };
+
+static int partitions_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &partitions_op);
+}
+
+static const struct file_operations proc_partitions_operations = {
+       .open           = partitions_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
 #endif
 
 
@@ -756,6 +768,8 @@ static int __init genhd_device_init(void)
        bdev_map = kobj_map_init(base_probe, &block_class_lock);
        blk_dev_init();
 
+       register_blkdev(BLOCK_EXT_MAJOR, "blkext");
+
 #ifndef CONFIG_SYSFS_DEPRECATED
        /* create top-level block dir */
        block_depr = kobject_create_and_add("block", NULL);
@@ -817,6 +831,11 @@ static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
 static struct device_attribute dev_attr_fail =
        __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store);
 #endif
+#ifdef CONFIG_FAIL_IO_TIMEOUT
+static struct device_attribute dev_attr_fail_timeout =
+       __ATTR(io-timeout-fail,  S_IRUGO|S_IWUSR, part_timeout_show,
+               part_timeout_store);
+#endif
 
 static struct attribute *disk_attrs[] = {
        &dev_attr_range.attr,
@@ -829,6 +848,9 @@ static struct attribute *disk_attrs[] = {
 #ifdef CONFIG_FAIL_MAKE_REQUEST
        &dev_attr_fail.attr,
 #endif
+#ifdef CONFIG_FAIL_IO_TIMEOUT
+       &dev_attr_fail_timeout.attr,
+#endif
        NULL
 };
 
@@ -985,12 +1007,32 @@ static int diskstats_show(struct seq_file *seqf, void *v)
        return 0;
 }
 
-const struct seq_operations diskstats_op = {
+static const struct seq_operations diskstats_op = {
        .start  = disk_seqf_start,
        .next   = disk_seqf_next,
        .stop   = disk_seqf_stop,
        .show   = diskstats_show
 };
+
+static int diskstats_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &diskstats_op);
+}
+
+static const struct file_operations proc_diskstats_operations = {
+       .open           = diskstats_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
+static int __init proc_genhd_init(void)
+{
+       proc_create("diskstats", 0, NULL, &proc_diskstats_operations);
+       proc_create("partitions", 0, NULL, &proc_partitions_operations);
+       return 0;
+}
+module_init(proc_genhd_init);
 #endif /* CONFIG_PROC_FS */
 
 static void media_change_notify_thread(struct work_struct *work)
@@ -1031,7 +1073,7 @@ dev_t blk_lookup_devt(const char *name, int partno)
                        continue;
 
                part = disk_get_part(disk, partno);
-               if (part && (part->nr_sects || partno == 0)) {
+               if (part) {
                        devt = part_devt(part);
                        disk_put_part(part);
                        break;
@@ -1060,6 +1102,7 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
                        kfree(disk);
                        return NULL;
                }
+               disk->node_id = node_id;
                if (disk_expand_part_tbl(disk, 0)) {
                        free_part_stats(&disk->part0);
                        kfree(disk);
@@ -1074,7 +1117,6 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
                device_initialize(disk_to_dev(disk));
                INIT_WORK(&disk->async_notify,
                        media_change_notify_thread);
-               disk->node_id = node_id;
        }
        return disk;
 }