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
11
12
13
14struct fault_attr {
15 unsigned long probability;
16 unsigned long interval;
17 atomic_t times;
18 atomic_t space;
19 unsigned long verbose;
20 u32 task_filter;
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;
26
27 unsigned long count;
28};
29
30#define FAULT_ATTR_INITIALIZER { \
31 .interval = 1, \
32 .times = ATOMIC_INIT(1), \
33 .require_end = ULONG_MAX, \
34 .stacktrace_depth = 32, \
35 .verbose = 2, \
36 }
37
38#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
39int setup_fault_attr(struct fault_attr *attr, char *str);
40bool should_fail(struct fault_attr *attr, ssize_t size);
41
42#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
43
44struct dentry *fault_create_debugfs_attr(const char *name,
45 struct dentry *parent, struct fault_attr *attr);
46
47#else
48
49static inline struct dentry *fault_create_debugfs_attr(const char *name,
50 struct dentry *parent, struct fault_attr *attr)
51{
52 return ERR_PTR(-ENODEV);
53}
54
55#endif
56
57#endif
58
59#ifdef CONFIG_FAILSLAB
60extern bool should_failslab(size_t size, gfp_t gfpflags, unsigned long flags);
61#else
62static inline bool should_failslab(size_t size, gfp_t gfpflags,
63 unsigned long flags)
64{
65 return false;
66}
67#endif
68
69#endif
70