]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - block/genhd.c
xtensa: types: use <asm-generic/int-*.h> for the xtensa architecture
[linux-2.6-omap-h63xx.git] / block / genhd.c
index de2ebb2fab436119cf16b862c720c15be6d991c4..fda9c7a63c29e3ecc323fa373365843771860ec4 100644 (file)
 #include <linux/buffer_head.h>
 #include <linux/mutex.h>
 
+#include "blk.h"
+
 static DEFINE_MUTEX(block_class_lock);
 #ifndef CONFIG_SYSFS_DEPRECATED
 struct kobject *block_depr;
 #endif
 
+static struct device_type disk_type;
+
 /*
  * Can be deleted altogether. Later.
  *
@@ -178,11 +182,17 @@ static int exact_lock(dev_t devt, void *data)
  */
 void add_disk(struct gendisk *disk)
 {
+       struct backing_dev_info *bdi;
+
        disk->flags |= GENHD_FL_UP;
        blk_register_region(MKDEV(disk->major, disk->first_minor),
                            disk->minors, NULL, exact_match, exact_lock, disk);
        register_disk(disk);
        blk_register_queue(disk);
+
+       bdi = &disk->queue->backing_dev_info;
+       bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
+       sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
 }
 
 EXPORT_SYMBOL(add_disk);
@@ -190,6 +200,8 @@ EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */
 
 void unlink_gendisk(struct gendisk *disk)
 {
+       sysfs_remove_link(&disk->dev.kobj, "bdi");
+       bdi_unregister(&disk->queue->backing_dev_info);
        blk_unregister_queue(disk);
        blk_unregister_region(MKDEV(disk->major, disk->first_minor),
                              disk->minors);
@@ -346,8 +358,6 @@ const struct seq_operations partitions_op = {
 #endif
 
 
-extern int blk_dev_init(void);
-
 static struct kobject *base_probe(dev_t devt, int *part, void *data)
 {
        if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
@@ -358,7 +368,9 @@ static struct kobject *base_probe(dev_t devt, int *part, void *data)
 
 static int __init genhd_device_init(void)
 {
-       class_register(&block_class);
+       int error = class_register(&block_class);
+       if (unlikely(error))
+               return error;
        bdev_map = kobj_map_init(base_probe, &block_class_lock);
        blk_dev_init();
 
@@ -502,7 +514,7 @@ struct class block_class = {
        .name           = "block",
 };
 
-struct device_type disk_type = {
+static struct device_type disk_type = {
        .name           = "disk",
        .groups         = disk_attr_groups,
        .release        = disk_release,
@@ -584,12 +596,28 @@ static int diskstats_show(struct seq_file *s, void *v)
        for (n = 0; n < gp->minors - 1; n++) {
                struct hd_struct *hd = gp->part[n];
 
-               if (hd && hd->nr_sects)
-                       seq_printf(s, "%4d %4d %s %u %u %u %u\n",
-                               gp->major, n + gp->first_minor + 1,
-                               disk_name(gp, n + 1, buf),
-                               hd->ios[0], hd->sectors[0],
-                               hd->ios[1], hd->sectors[1]);
+               if (!hd || !hd->nr_sects)
+                       continue;
+
+               preempt_disable();
+               part_round_stats(hd);
+               preempt_enable();
+               seq_printf(s, "%4d %4d %s %lu %lu %llu "
+                          "%u %lu %lu %llu %u %u %u %u\n",
+                          gp->major, n + gp->first_minor + 1,
+                          disk_name(gp, n + 1, buf),
+                          part_stat_read(hd, ios[0]),
+                          part_stat_read(hd, merges[0]),
+                          (unsigned long long)part_stat_read(hd, sectors[0]),
+                          jiffies_to_msecs(part_stat_read(hd, ticks[0])),
+                          part_stat_read(hd, ios[1]),
+                          part_stat_read(hd, merges[1]),
+                          (unsigned long long)part_stat_read(hd, sectors[1]),
+                          jiffies_to_msecs(part_stat_read(hd, ticks[1])),
+                          hd->in_flight,
+                          jiffies_to_msecs(part_stat_read(hd, io_ticks)),
+                          jiffies_to_msecs(part_stat_read(hd, time_in_queue))
+                       );
        }
  
        return 0;
@@ -616,12 +644,14 @@ static void media_change_notify_thread(struct work_struct *work)
        put_device(gd->driverfs_dev);
 }
 
+#if 0
 void genhd_media_change_notify(struct gendisk *disk)
 {
        get_device(disk->driverfs_dev);
        schedule_work(&disk->async_notify);
 }
 EXPORT_SYMBOL_GPL(genhd_media_change_notify);
+#endif  /*  0  */
 
 dev_t blk_lookup_devt(const char *name)
 {