diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2006-12-08 05:39:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 11:29:02 -0500 |
commit | c17bb4951752d3e0f49cd1ea9d2e868422f9e0d6 (patch) | |
tree | dcd23ef706ba09edae462528dc11a507b1d17af6 /block/genhd.c | |
parent | 933e312e73f8fc39652bd4d216a5393cc3a014b9 (diff) |
[PATCH] fault-injection capability for disk IO
This patch provides fault-injection capability for disk IO.
Boot option:
fail_make_request=<probability>,<interval>,<space>,<times>
<interval> -- specifies the interval of failures.
<probability> -- specifies how often it should fail in percent.
<space> -- specifies the size of free space where disk IO can be issued
safely in bytes.
<times> -- specifies how many times failures may happen at most.
Debugfs:
/debug/fail_make_request/interval
/debug/fail_make_request/probability
/debug/fail_make_request/specifies
/debug/fail_make_request/times
Example:
fail_make_request=10,100,0,-1
echo 1 > /sys/blocks/hda/hda1/make-it-fail
generic_make_request() on /dev/hda1 fails once per 10 times.
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/block/genhd.c b/block/genhd.c index 653919d50cd4..457fdac4c17d 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -417,6 +417,34 @@ static struct disk_attribute disk_attr_stat = { | |||
417 | .show = disk_stats_read | 417 | .show = disk_stats_read |
418 | }; | 418 | }; |
419 | 419 | ||
420 | #ifdef CONFIG_FAIL_MAKE_REQUEST | ||
421 | |||
422 | static ssize_t disk_fail_store(struct gendisk * disk, | ||
423 | const char *buf, size_t count) | ||
424 | { | ||
425 | int i; | ||
426 | |||
427 | if (count > 0 && sscanf(buf, "%d", &i) > 0) { | ||
428 | if (i == 0) | ||
429 | disk->flags &= ~GENHD_FL_FAIL; | ||
430 | else | ||
431 | disk->flags |= GENHD_FL_FAIL; | ||
432 | } | ||
433 | |||
434 | return count; | ||
435 | } | ||
436 | static ssize_t disk_fail_read(struct gendisk * disk, char *page) | ||
437 | { | ||
438 | return sprintf(page, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0); | ||
439 | } | ||
440 | static struct disk_attribute disk_attr_fail = { | ||
441 | .attr = {.name = "make-it-fail", .mode = S_IRUGO | S_IWUSR }, | ||
442 | .store = disk_fail_store, | ||
443 | .show = disk_fail_read | ||
444 | }; | ||
445 | |||
446 | #endif | ||
447 | |||
420 | static struct attribute * default_attrs[] = { | 448 | static struct attribute * default_attrs[] = { |
421 | &disk_attr_uevent.attr, | 449 | &disk_attr_uevent.attr, |
422 | &disk_attr_dev.attr, | 450 | &disk_attr_dev.attr, |
@@ -424,6 +452,9 @@ static struct attribute * default_attrs[] = { | |||
424 | &disk_attr_removable.attr, | 452 | &disk_attr_removable.attr, |
425 | &disk_attr_size.attr, | 453 | &disk_attr_size.attr, |
426 | &disk_attr_stat.attr, | 454 | &disk_attr_stat.attr, |
455 | #ifdef CONFIG_FAIL_MAKE_REQUEST | ||
456 | &disk_attr_fail.attr, | ||
457 | #endif | ||
427 | NULL, | 458 | NULL, |
428 | }; | 459 | }; |
429 | 460 | ||