Blame view

include/linux/fault-inject.h 1.81 KB
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
1
2
3
4
5
6
7
  #ifndef _LINUX_FAULT_INJECT_H
  #define _LINUX_FAULT_INJECT_H
  
  #ifdef CONFIG_FAULT_INJECTION
  
  #include <linux/types.h>
  #include <linux/debugfs.h>
6adc4a22f   Dmitry Monakhov   fault-inject: add...
8
  #include <linux/ratelimit.h>
60063497a   Arun Sharma   atomic: use <linu...
9
  #include <linux/atomic.h>
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
10
11
12
13
14
15
16
17
18
19
20
  
  /*
   * For explanation of the elements of this struct, see
   * Documentation/fault-injection/fault-injection.txt
   */
  struct fault_attr {
  	unsigned long probability;
  	unsigned long interval;
  	atomic_t times;
  	atomic_t space;
  	unsigned long verbose;
621a5f7ad   Viresh Kumar   debugfs: Pass boo...
21
  	bool task_filter;
329409aed   Akinobu Mita   [PATCH] fault inj...
22
23
24
25
26
  	unsigned long stacktrace_depth;
  	unsigned long require_start;
  	unsigned long require_end;
  	unsigned long reject_start;
  	unsigned long reject_end;
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
27
28
  
  	unsigned long count;
6adc4a22f   Dmitry Monakhov   fault-inject: add...
29
30
  	struct ratelimit_state ratelimit_state;
  	struct dentry *dname;
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
31
  };
6adc4a22f   Dmitry Monakhov   fault-inject: add...
32
33
34
35
36
37
38
39
  #define FAULT_ATTR_INITIALIZER {					\
  		.interval = 1,						\
  		.times = ATOMIC_INIT(1),				\
  		.require_end = ULONG_MAX,				\
  		.stacktrace_depth = 32,					\
  		.ratelimit_state = RATELIMIT_STATE_INIT_DISABLED,	\
  		.verbose = 2,						\
  		.dname = NULL,						\
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
40
41
42
43
  	}
  
  #define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
  int setup_fault_attr(struct fault_attr *attr, char *str);
08b3df2d1   Don Mullis   [PATCH] fault-inj...
44
  bool should_fail(struct fault_attr *attr, ssize_t size);
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
45
46
  
  #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
dd48c085c   Akinobu Mita   fault-injection: ...
47
48
  struct dentry *fault_create_debugfs_attr(const char *name,
  			struct dentry *parent, struct fault_attr *attr);
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
49
50
  
  #else /* CONFIG_FAULT_INJECTION_DEBUG_FS */
dd48c085c   Akinobu Mita   fault-injection: ...
51
52
  static inline struct dentry *fault_create_debugfs_attr(const char *name,
  			struct dentry *parent, struct fault_attr *attr)
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
53
  {
dd48c085c   Akinobu Mita   fault-injection: ...
54
  	return ERR_PTR(-ENODEV);
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
55
56
57
58
59
  }
  
  #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
  
  #endif /* CONFIG_FAULT_INJECTION */
773ff60e8   Akinobu Mita   SLUB: failslab su...
60
  #ifdef CONFIG_FAILSLAB
fab9963a6   Jesper Dangaard Brouer   mm: fault-inject ...
61
  extern bool should_failslab(struct kmem_cache *s, gfp_t gfpflags);
773ff60e8   Akinobu Mita   SLUB: failslab su...
62
  #else
fab9963a6   Jesper Dangaard Brouer   mm: fault-inject ...
63
  static inline bool should_failslab(struct kmem_cache *s, gfp_t gfpflags)
773ff60e8   Akinobu Mita   SLUB: failslab su...
64
65
66
67
  {
  	return false;
  }
  #endif /* CONFIG_FAILSLAB */
6ff1cb355   Akinobu Mita   [PATCH] fault-inj...
68
  #endif /* _LINUX_FAULT_INJECT_H */