diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2006-12-08 05:39:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-08 11:29:02 -0500 |
commit | 6ff1cb355e628f8fc55fa2d01e269e5e1bbc2fe9 (patch) | |
tree | 393d94b6d7585e4c804d6415afaa11e1d6ec350d /include/linux | |
parent | de1ba09b214056365d9082982905b255caafb7a2 (diff) |
[PATCH] fault-injection capabilities infrastructure
This patch provides base functions implement to fault-injection
capabilities.
- The function should_fail() is taken from failmalloc-1.0
(http://www.nongnu.org/failmalloc/)
[akpm@osdl.org: cleanups, comments, add __init]
Cc: <okuji@enbug.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Don Mullis <dwm@meer.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/fault-inject.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h new file mode 100644 index 000000000000..4df4902bc8d8 --- /dev/null +++ b/include/linux/fault-inject.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef _LINUX_FAULT_INJECT_H | ||
2 | #define _LINUX_FAULT_INJECT_H | ||
3 | |||
4 | #ifdef CONFIG_FAULT_INJECTION | ||
5 | |||
6 | #include <linux/types.h> | ||
7 | #include <linux/debugfs.h> | ||
8 | #include <asm/atomic.h> | ||
9 | |||
10 | /* | ||
11 | * For explanation of the elements of this struct, see | ||
12 | * Documentation/fault-injection/fault-injection.txt | ||
13 | */ | ||
14 | struct fault_attr { | ||
15 | unsigned long probability; | ||
16 | unsigned long interval; | ||
17 | atomic_t times; | ||
18 | atomic_t space; | ||
19 | unsigned long verbose; | ||
20 | |||
21 | unsigned long count; | ||
22 | |||
23 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | ||
24 | |||
25 | struct { | ||
26 | struct dentry *dir; | ||
27 | |||
28 | struct dentry *probability_file; | ||
29 | struct dentry *interval_file; | ||
30 | struct dentry *times_file; | ||
31 | struct dentry *space_file; | ||
32 | struct dentry *verbose_file; | ||
33 | } dentries; | ||
34 | |||
35 | #endif | ||
36 | }; | ||
37 | |||
38 | #define FAULT_ATTR_INITIALIZER { \ | ||
39 | .interval = 1, \ | ||
40 | .times = ATOMIC_INIT(1), \ | ||
41 | } | ||
42 | |||
43 | #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER | ||
44 | int setup_fault_attr(struct fault_attr *attr, char *str); | ||
45 | void should_fail_srandom(unsigned long entropy); | ||
46 | int should_fail(struct fault_attr *attr, ssize_t size); | ||
47 | |||
48 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | ||
49 | |||
50 | int init_fault_attr_dentries(struct fault_attr *attr, const char *name); | ||
51 | void cleanup_fault_attr_dentries(struct fault_attr *attr); | ||
52 | |||
53 | #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | ||
54 | |||
55 | static inline int init_fault_attr_dentries(struct fault_attr *attr, | ||
56 | const char *name) | ||
57 | { | ||
58 | return -ENODEV; | ||
59 | } | ||
60 | |||
61 | static inline void cleanup_fault_attr_dentries(struct fault_attr *attr) | ||
62 | { | ||
63 | } | ||
64 | |||
65 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ | ||
66 | |||
67 | #endif /* CONFIG_FAULT_INJECTION */ | ||
68 | |||
69 | #endif /* _LINUX_FAULT_INJECT_H */ | ||