Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [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> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 8 | #include <linux/atomic.h> |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 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; |
Akinobu Mita | f4f154f | 2006-12-08 02:39:47 -0800 | [diff] [blame] | 20 | u32 task_filter; |
Akinobu Mita | 329409a | 2006-12-08 02:39:48 -0800 | [diff] [blame] | 21 | unsigned long stacktrace_depth; |
| 22 | unsigned long require_start; |
| 23 | unsigned long require_end; |
| 24 | unsigned long reject_start; |
| 25 | unsigned long reject_end; |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 26 | |
| 27 | unsigned long count; |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | #define FAULT_ATTR_INITIALIZER { \ |
| 31 | .interval = 1, \ |
| 32 | .times = ATOMIC_INIT(1), \ |
Akinobu Mita | 329409a | 2006-12-08 02:39:48 -0800 | [diff] [blame] | 33 | .require_end = ULONG_MAX, \ |
| 34 | .stacktrace_depth = 32, \ |
Don Mullis | 6b1b60f | 2006-12-08 02:39:53 -0800 | [diff] [blame] | 35 | .verbose = 2, \ |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER |
| 39 | int setup_fault_attr(struct fault_attr *attr, char *str); |
Don Mullis | 08b3df2 | 2006-12-08 02:39:51 -0800 | [diff] [blame] | 40 | bool should_fail(struct fault_attr *attr, ssize_t size); |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 41 | |
| 42 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
| 43 | |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 44 | struct dentry *fault_create_debugfs_attr(const char *name, |
| 45 | struct dentry *parent, struct fault_attr *attr); |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 46 | |
| 47 | #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
| 48 | |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 49 | static inline struct dentry *fault_create_debugfs_attr(const char *name, |
| 50 | struct dentry *parent, struct fault_attr *attr) |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 51 | { |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 52 | return ERR_PTR(-ENODEV); |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
| 56 | |
| 57 | #endif /* CONFIG_FAULT_INJECTION */ |
| 58 | |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 59 | #ifdef CONFIG_FAILSLAB |
Dmitry Monakhov | 4c13dd3 | 2010-02-26 09:36:12 +0300 | [diff] [blame] | 60 | extern bool should_failslab(size_t size, gfp_t gfpflags, unsigned long flags); |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 61 | #else |
Dmitry Monakhov | 4c13dd3 | 2010-02-26 09:36:12 +0300 | [diff] [blame] | 62 | static inline bool should_failslab(size_t size, gfp_t gfpflags, |
| 63 | unsigned long flags) |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 64 | { |
| 65 | return false; |
| 66 | } |
| 67 | #endif /* CONFIG_FAILSLAB */ |
| 68 | |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 69 | #endif /* _LINUX_FAULT_INJECT_H */ |