kbuild: move tags from ARCH and include/ ahead of drivers
[sfrench/cifs-2.6.git] / block / genhd.c
index 653919d50cd4d06aea68d8e027d15a473e5b4f5a..441432a142f231b871750caa5fed9a82c0cd750a 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/genhd.h>
+#include <linux/kdev_t.h>
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
 #include <linux/init.h>
@@ -417,6 +418,34 @@ static struct disk_attribute disk_attr_stat = {
        .show   = disk_stats_read
 };
 
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+
+static ssize_t disk_fail_store(struct gendisk * disk,
+                              const char *buf, size_t count)
+{
+       int i;
+
+       if (count > 0 && sscanf(buf, "%d", &i) > 0) {
+               if (i == 0)
+                       disk->flags &= ~GENHD_FL_FAIL;
+               else
+                       disk->flags |= GENHD_FL_FAIL;
+       }
+
+       return count;
+}
+static ssize_t disk_fail_read(struct gendisk * disk, char *page)
+{
+       return sprintf(page, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0);
+}
+static struct disk_attribute disk_attr_fail = {
+       .attr = {.name = "make-it-fail", .mode = S_IRUGO | S_IWUSR },
+       .store  = disk_fail_store,
+       .show   = disk_fail_read
+};
+
+#endif
+
 static struct attribute * default_attrs[] = {
        &disk_attr_uevent.attr,
        &disk_attr_dev.attr,
@@ -424,6 +453,9 @@ static struct attribute * default_attrs[] = {
        &disk_attr_removable.attr,
        &disk_attr_size.attr,
        &disk_attr_stat.attr,
+#ifdef CONFIG_FAIL_MAKE_REQUEST
+       &disk_attr_fail.attr,
+#endif
        NULL,
 };