aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe2008-09-14 07:56:33 -0500
committerJens Axboe2008-10-09 01:56:17 -0500
commit581d4e28d9195aa8b2231383dbabc288988d615e (patch)
tree093bcac9a538ef67edcf91826f7532bdb88e6248 /block/blk-timeout.c
parent0a0d96b03a1f3bfd6bc3ea08008699e8e59fccd9 (diff)
downloadkernel-common-581d4e28d9195aa8b2231383dbabc288988d615e.tar.gz
kernel-common-581d4e28d9195aa8b2231383dbabc288988d615e.tar.xz
kernel-common-581d4e28d9195aa8b2231383dbabc288988d615e.zip
block: add fault injection mechanism for faking request timeouts
Only works for the generic request timer handling. Allows one to sporadically ignore request completions, thus exercising the timeout handling. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-timeout.c')
-rw-r--r--block/blk-timeout.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 6e5c781c5af..9b4ad138bb3 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -4,9 +4,68 @@
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/blkdev.h> 6#include <linux/blkdev.h>
7#include <linux/fault-inject.h>
7 8
8#include "blk.h" 9#include "blk.h"
9 10
11#ifdef CONFIG_FAIL_IO_TIMEOUT
12
13static DECLARE_FAULT_ATTR(fail_io_timeout);
14
15static int __init setup_fail_io_timeout(char *str)
16{
17 return setup_fault_attr(&fail_io_timeout, str);
18}
19__setup("fail_io_timeout=", setup_fail_io_timeout);
20
21int blk_should_fake_timeout(struct request_queue *q)
22{
23 if (!test_bit(QUEUE_FLAG_FAIL_IO, &q->queue_flags))
24 return 0;
25
26 return should_fail(&fail_io_timeout, 1);
27}
28
29static int __init fail_io_timeout_debugfs(void)
30{
31 return init_fault_attr_dentries(&fail_io_timeout, "fail_io_timeout");
32}
33
34late_initcall(fail_io_timeout_debugfs);
35
36ssize_t part_timeout_show(struct device *dev, struct device_attribute *attr,
37 char *buf)
38{
39 struct gendisk *disk = dev_to_disk(dev);
40 int set = test_bit(QUEUE_FLAG_FAIL_IO, &disk->queue->queue_flags);
41
42 return sprintf(buf, "%d\n", set != 0);
43}
44
45ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr,
46 const char *buf, size_t count)
47{
48 struct gendisk *disk = dev_to_disk(dev);
49 int val;
50
51 if (count) {
52 struct request_queue *q = disk->queue;
53 char *p = (char *) buf;
54
55 val = simple_strtoul(p, &p, 10);
56 spin_lock_irq(q->queue_lock);
57 if (val)
58 queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
59 else
60 queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
61 spin_unlock_irq(q->queue_lock);
62 }
63
64 return count;
65}
66
67#endif /* CONFIG_FAIL_IO_TIMEOUT */
68
10/* 69/*
11 * blk_delete_timer - Delete/cancel timer for a given function. 70 * blk_delete_timer - Delete/cancel timer for a given function.
12 * @req: request that we are canceling timer for 71 * @req: request that we are canceling timer for