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> |
Dmitry Monakhov | 6adc4a2 | 2014-12-12 16:58:00 -0800 | [diff] [blame] | 8 | #include <linux/ratelimit.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 9 | #include <linux/atomic.h> |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 10 | |
| 11 | /* |
| 12 | * For explanation of the elements of this struct, see |
| 13 | * Documentation/fault-injection/fault-injection.txt |
| 14 | */ |
| 15 | struct fault_attr { |
| 16 | unsigned long probability; |
| 17 | unsigned long interval; |
| 18 | atomic_t times; |
| 19 | atomic_t space; |
| 20 | unsigned long verbose; |
Viresh Kumar | 621a5f7 | 2015-09-26 15:04:07 -0700 | [diff] [blame] | 21 | bool task_filter; |
Akinobu Mita | 329409a | 2006-12-08 02:39:48 -0800 | [diff] [blame] | 22 | unsigned long stacktrace_depth; |
| 23 | unsigned long require_start; |
| 24 | unsigned long require_end; |
| 25 | unsigned long reject_start; |
| 26 | unsigned long reject_end; |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 27 | |
| 28 | unsigned long count; |
Dmitry Monakhov | 6adc4a2 | 2014-12-12 16:58:00 -0800 | [diff] [blame] | 29 | struct ratelimit_state ratelimit_state; |
| 30 | struct dentry *dname; |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 31 | }; |
| 32 | |
Dmitry Monakhov | 6adc4a2 | 2014-12-12 16:58:00 -0800 | [diff] [blame] | 33 | #define FAULT_ATTR_INITIALIZER { \ |
| 34 | .interval = 1, \ |
| 35 | .times = ATOMIC_INIT(1), \ |
| 36 | .require_end = ULONG_MAX, \ |
| 37 | .stacktrace_depth = 32, \ |
| 38 | .ratelimit_state = RATELIMIT_STATE_INIT_DISABLED, \ |
| 39 | .verbose = 2, \ |
| 40 | .dname = NULL, \ |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 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); |
Don Mullis | 08b3df2 | 2006-12-08 02:39:51 -0800 | [diff] [blame] | 45 | bool should_fail(struct fault_attr *attr, ssize_t size); |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 46 | |
| 47 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
| 48 | |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 49 | 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 | |
| 52 | #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
| 53 | |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 54 | static inline struct dentry *fault_create_debugfs_attr(const char *name, |
| 55 | struct dentry *parent, struct fault_attr *attr) |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 56 | { |
Akinobu Mita | dd48c08 | 2011-08-03 16:21:01 -0700 | [diff] [blame] | 57 | return ERR_PTR(-ENODEV); |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ |
| 61 | |
| 62 | #endif /* CONFIG_FAULT_INJECTION */ |
| 63 | |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 64 | #ifdef CONFIG_FAILSLAB |
Jesper Dangaard Brouer | fab9963 | 2016-03-15 14:53:38 -0700 | [diff] [blame] | 65 | extern bool should_failslab(struct kmem_cache *s, gfp_t gfpflags); |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 66 | #else |
Jesper Dangaard Brouer | fab9963 | 2016-03-15 14:53:38 -0700 | [diff] [blame] | 67 | static inline bool should_failslab(struct kmem_cache *s, gfp_t gfpflags) |
Akinobu Mita | 773ff60 | 2008-12-23 19:37:01 +0900 | [diff] [blame] | 68 | { |
| 69 | return false; |
| 70 | } |
| 71 | #endif /* CONFIG_FAILSLAB */ |
| 72 | |
Akinobu Mita | 6ff1cb3 | 2006-12-08 02:39:43 -0800 | [diff] [blame] | 73 | #endif /* _LINUX_FAULT_INJECT_H */ |