Lines Matching refs:attr
18 int __init setup_fault_attr(struct fault_attr *attr, char *str)
33 attr->probability = probability;
34 attr->interval = interval;
35 atomic_set(&attr->times, times);
36 atomic_set(&attr->space, space);
41 static void fail_dump(struct fault_attr *attr)
43 if (attr->verbose > 0)
45 if (attr->verbose > 1)
51 static bool fail_task(struct fault_attr *attr, struct task_struct *task)
60 static bool fail_stacktrace(struct fault_attr *attr)
63 int depth = attr->stacktrace_depth;
66 bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
78 if (attr->reject_start <= entries[n] &&
79 entries[n] < attr->reject_end)
81 if (attr->require_start <= entries[n] &&
82 entries[n] < attr->require_end)
90 static inline bool fail_stacktrace(struct fault_attr *attr)
102 bool should_fail(struct fault_attr *attr, ssize_t size)
104 if (attr->task_filter && !fail_task(attr, current))
107 if (atomic_read(&attr->times) == 0)
110 if (atomic_read(&attr->space) > size) {
111 atomic_sub(size, &attr->space);
115 if (attr->interval > 1) {
116 attr->count++;
117 if (attr->count % attr->interval)
121 if (attr->probability <= random32() % 100)
124 if (!fail_stacktrace(attr))
127 fail_dump(attr);
129 if (atomic_read(&attr->times) != -1)
130 atomic_dec_not_zero(&attr->times);
201 void cleanup_fault_attr_dentries(struct fault_attr *attr)
203 debugfs_remove(attr->dentries.probability_file);
204 attr->dentries.probability_file = NULL;
206 debugfs_remove(attr->dentries.interval_file);
207 attr->dentries.interval_file = NULL;
209 debugfs_remove(attr->dentries.times_file);
210 attr->dentries.times_file = NULL;
212 debugfs_remove(attr->dentries.space_file);
213 attr->dentries.space_file = NULL;
215 debugfs_remove(attr->dentries.verbose_file);
216 attr->dentries.verbose_file = NULL;
218 debugfs_remove(attr->dentries.task_filter_file);
219 attr->dentries.task_filter_file = NULL;
223 debugfs_remove(attr->dentries.stacktrace_depth_file);
224 attr->dentries.stacktrace_depth_file = NULL;
226 debugfs_remove(attr->dentries.require_start_file);
227 attr->dentries.require_start_file = NULL;
229 debugfs_remove(attr->dentries.require_end_file);
230 attr->dentries.require_end_file = NULL;
232 debugfs_remove(attr->dentries.reject_start_file);
233 attr->dentries.reject_start_file = NULL;
235 debugfs_remove(attr->dentries.reject_end_file);
236 attr->dentries.reject_end_file = NULL;
240 if (attr->dentries.dir)
241 WARN_ON(!simple_empty(attr->dentries.dir));
243 debugfs_remove(attr->dentries.dir);
244 attr->dentries.dir = NULL;
247 int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
252 memset(&attr->dentries, 0, sizeof(attr->dentries));
257 attr->dentries.dir = dir;
259 attr->dentries.probability_file =
260 debugfs_create_ul("probability", mode, dir, &attr->probability);
262 attr->dentries.interval_file =
263 debugfs_create_ul("interval", mode, dir, &attr->interval);
265 attr->dentries.times_file =
266 debugfs_create_atomic_t("times", mode, dir, &attr->times);
268 attr->dentries.space_file =
269 debugfs_create_atomic_t("space", mode, dir, &attr->space);
271 attr->dentries.verbose_file =
272 debugfs_create_ul("verbose", mode, dir, &attr->verbose);
274 attr->dentries.task_filter_file = debugfs_create_bool("task-filter",
275 mode, dir, &attr->task_filter);
277 if (!attr->dentries.probability_file || !attr->dentries.interval_file ||
278 !attr->dentries.times_file || !attr->dentries.space_file ||
279 !attr->dentries.verbose_file || !attr->dentries.task_filter_file)
284 attr->dentries.stacktrace_depth_file =
286 "stacktrace-depth", mode, dir, &attr->stacktrace_depth);
288 attr->dentries.require_start_file =
289 debugfs_create_ul("require-start", mode, dir, &attr->require_start);
291 attr->dentries.require_end_file =
292 debugfs_create_ul("require-end", mode, dir, &attr->require_end);
294 attr->dentries.reject_start_file =
295 debugfs_create_ul("reject-start", mode, dir, &attr->reject_start);
297 attr->dentries.reject_end_file =
298 debugfs_create_ul("reject-end", mode, dir, &attr->reject_end);
300 if (!attr->dentries.stacktrace_depth_file ||
301 !attr->dentries.require_start_file ||
302 !attr->dentries.require_end_file ||
303 !attr->dentries.reject_start_file ||
304 !attr->dentries.reject_end_file)
311 cleanup_fault_attr_dentries(attr);