diff options
-rw-r--r-- | block/blk-core.c | 5 | ||||
-rw-r--r-- | block/genhd.c | 30 | ||||
-rw-r--r-- | fs/partitions/check.c | 10 | ||||
-rw-r--r-- | include/linux/genhd.h | 8 |
4 files changed, 16 insertions, 37 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index a4a7c08d2f20..505ec61067df 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -1273,8 +1273,9 @@ __setup("fail_make_request=", setup_fail_make_request); | |||
1273 | 1273 | ||
1274 | static int should_fail_request(struct bio *bio) | 1274 | static int should_fail_request(struct bio *bio) |
1275 | { | 1275 | { |
1276 | if ((bio->bi_bdev->bd_disk->flags & GENHD_FL_FAIL) || | 1276 | struct hd_struct *part = bio->bi_bdev->bd_part; |
1277 | bio->bi_bdev->bd_part->make_it_fail) | 1277 | |
1278 | if (part_to_disk(part)->part0.make_it_fail || part->make_it_fail) | ||
1278 | return should_fail(&fail_make_request, bio->bi_size); | 1279 | return should_fail(&fail_make_request, bio->bi_size); |
1279 | 1280 | ||
1280 | return 0; | 1281 | return 0; |
diff --git a/block/genhd.c b/block/genhd.c index 70358f3c7423..06a252f2b967 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -795,34 +795,6 @@ static ssize_t disk_stat_show(struct device *dev, | |||
795 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); | 795 | jiffies_to_msecs(disk_stat_read(disk, time_in_queue))); |
796 | } | 796 | } |
797 | 797 | ||
798 | #ifdef CONFIG_FAIL_MAKE_REQUEST | ||
799 | static ssize_t disk_fail_show(struct device *dev, | ||
800 | struct device_attribute *attr, char *buf) | ||
801 | { | ||
802 | struct gendisk *disk = dev_to_disk(dev); | ||
803 | |||
804 | return sprintf(buf, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0); | ||
805 | } | ||
806 | |||
807 | static ssize_t disk_fail_store(struct device *dev, | ||
808 | struct device_attribute *attr, | ||
809 | const char *buf, size_t count) | ||
810 | { | ||
811 | struct gendisk *disk = dev_to_disk(dev); | ||
812 | int i; | ||
813 | |||
814 | if (count > 0 && sscanf(buf, "%d", &i) > 0) { | ||
815 | if (i == 0) | ||
816 | disk->flags &= ~GENHD_FL_FAIL; | ||
817 | else | ||
818 | disk->flags |= GENHD_FL_FAIL; | ||
819 | } | ||
820 | |||
821 | return count; | ||
822 | } | ||
823 | |||
824 | #endif | ||
825 | |||
826 | static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); | 798 | static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); |
827 | static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); | 799 | static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); |
828 | static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); | 800 | static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); |
@@ -832,7 +804,7 @@ static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); | |||
832 | static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL); | 804 | static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL); |
833 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 805 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
834 | static struct device_attribute dev_attr_fail = | 806 | static struct device_attribute dev_attr_fail = |
835 | __ATTR(make-it-fail, S_IRUGO|S_IWUSR, disk_fail_show, disk_fail_store); | 807 | __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store); |
836 | #endif | 808 | #endif |
837 | 809 | ||
838 | static struct attribute *disk_attrs[] = { | 810 | static struct attribute *disk_attrs[] = { |
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 87298c0fc8ce..60592d9f43b6 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -238,17 +238,17 @@ static ssize_t part_stat_show(struct device *dev, | |||
238 | } | 238 | } |
239 | 239 | ||
240 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 240 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
241 | static ssize_t part_fail_show(struct device *dev, | 241 | ssize_t part_fail_show(struct device *dev, |
242 | struct device_attribute *attr, char *buf) | 242 | struct device_attribute *attr, char *buf) |
243 | { | 243 | { |
244 | struct hd_struct *p = dev_to_part(dev); | 244 | struct hd_struct *p = dev_to_part(dev); |
245 | 245 | ||
246 | return sprintf(buf, "%d\n", p->make_it_fail); | 246 | return sprintf(buf, "%d\n", p->make_it_fail); |
247 | } | 247 | } |
248 | 248 | ||
249 | static ssize_t part_fail_store(struct device *dev, | 249 | ssize_t part_fail_store(struct device *dev, |
250 | struct device_attribute *attr, | 250 | struct device_attribute *attr, |
251 | const char *buf, size_t count) | 251 | const char *buf, size_t count) |
252 | { | 252 | { |
253 | struct hd_struct *p = dev_to_part(dev); | 253 | struct hd_struct *p = dev_to_part(dev); |
254 | int i; | 254 | int i; |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 45a3682b5d87..3d15b42dc352 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -112,7 +112,6 @@ struct hd_struct { | |||
112 | #define GENHD_FL_CD 8 | 112 | #define GENHD_FL_CD 8 |
113 | #define GENHD_FL_UP 16 | 113 | #define GENHD_FL_UP 16 |
114 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 | 114 | #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 |
115 | #define GENHD_FL_FAIL 64 | ||
116 | 115 | ||
117 | struct gendisk { | 116 | struct gendisk { |
118 | /* major, first_minor, minors and ext_minors are input | 117 | /* major, first_minor, minors and ext_minors are input |
@@ -596,6 +595,13 @@ extern void blk_unregister_region(dev_t devt, unsigned long range); | |||
596 | 595 | ||
597 | extern ssize_t part_size_show(struct device *dev, | 596 | extern ssize_t part_size_show(struct device *dev, |
598 | struct device_attribute *attr, char *buf); | 597 | struct device_attribute *attr, char *buf); |
598 | #ifdef CONFIG_FAIL_MAKE_REQUEST | ||
599 | extern ssize_t part_fail_show(struct device *dev, | ||
600 | struct device_attribute *attr, char *buf); | ||
601 | extern ssize_t part_fail_store(struct device *dev, | ||
602 | struct device_attribute *attr, | ||
603 | const char *buf, size_t count); | ||
604 | #endif /* CONFIG_FAIL_MAKE_REQUEST */ | ||
599 | 605 | ||
600 | #else /* CONFIG_BLOCK */ | 606 | #else /* CONFIG_BLOCK */ |
601 | 607 | ||