Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 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 <linux/atomic.h> |
| 9 | |
| 10 | struct fault_attr { |
| 11 | unsigned long probability; |
| 12 | unsigned long interval; |
| 13 | atomic_t times; |
| 14 | atomic_t space; |
| 15 | unsigned long verbose; |
| 16 | u32 task_filter; |
| 17 | unsigned long stacktrace_depth; |
| 18 | unsigned long require_start; |
| 19 | unsigned long require_end; |
| 20 | unsigned long reject_start; |
| 21 | unsigned long reject_end; |
| 22 | |
| 23 | unsigned long count; |
| 24 | }; |
| 25 | |
| 26 | #define FAULT_ATTR_INITIALIZER { \ |
| 27 | .interval = 1, \ |
| 28 | .times = ATOMIC_INIT(1), \ |
| 29 | .require_end = ULONG_MAX, \ |
| 30 | .stacktrace_depth = 32, \ |
| 31 | .verbose = 2, \ |
| 32 | } |
| 33 | |
| 34 | #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER |
| 35 | int setup_fault_attr(struct fault_attr *attr, char *str); |
| 36 | bool should_fail(struct fault_attr *attr, ssize_t size); |
| 37 | |
| 38 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
| 39 | |
| 40 | struct dentry *fault_create_debugfs_attr(const char *name, |
| 41 | struct dentry *parent, struct fault_attr *attr); |
| 42 | |
| 43 | #else |
| 44 | |
| 45 | static inline struct dentry *fault_create_debugfs_attr(const char *name, |
| 46 | struct dentry *parent, struct fault_attr *attr) |
| 47 | { |
| 48 | return ERR_PTR(-ENODEV); |
| 49 | } |
| 50 | |
| 51 | #endif |
| 52 | |
| 53 | #endif |
| 54 | |
| 55 | #ifdef CONFIG_FAILSLAB |
| 56 | extern bool should_failslab(size_t size, gfp_t gfpflags, unsigned long flags); |
| 57 | #else |
| 58 | static inline bool should_failslab(size_t size, gfp_t gfpflags, |
| 59 | unsigned long flags) |
| 60 | { |
| 61 | return false; |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | #endif |