Lines Matching refs:attr
17 int setup_fault_attr(struct fault_attr *attr, char *str) in setup_fault_attr() argument
32 attr->probability = probability; in setup_fault_attr()
33 attr->interval = interval; in setup_fault_attr()
34 atomic_set(&attr->times, times); in setup_fault_attr()
35 atomic_set(&attr->space, space); in setup_fault_attr()
41 static void fail_dump(struct fault_attr *attr) in fail_dump() argument
43 if (attr->verbose > 0 && __ratelimit(&attr->ratelimit_state)) { in fail_dump()
46 "space %d, times %d\n", attr->dname, in fail_dump()
47 attr->interval, attr->probability, in fail_dump()
48 atomic_read(&attr->space), in fail_dump()
49 atomic_read(&attr->times)); in fail_dump()
50 if (attr->verbose > 1) in fail_dump()
57 static bool fail_task(struct fault_attr *attr, struct task_struct *task) in fail_task() argument
66 static bool fail_stacktrace(struct fault_attr *attr) in fail_stacktrace() argument
69 int depth = attr->stacktrace_depth; in fail_stacktrace()
72 bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX); in fail_stacktrace()
84 if (attr->reject_start <= entries[n] && in fail_stacktrace()
85 entries[n] < attr->reject_end) in fail_stacktrace()
87 if (attr->require_start <= entries[n] && in fail_stacktrace()
88 entries[n] < attr->require_end) in fail_stacktrace()
96 static inline bool fail_stacktrace(struct fault_attr *attr) in fail_stacktrace() argument
108 bool should_fail(struct fault_attr *attr, ssize_t size) in should_fail() argument
111 if (attr->probability == 0) in should_fail()
114 if (attr->task_filter && !fail_task(attr, current)) in should_fail()
117 if (atomic_read(&attr->times) == 0) in should_fail()
120 if (atomic_read(&attr->space) > size) { in should_fail()
121 atomic_sub(size, &attr->space); in should_fail()
125 if (attr->interval > 1) { in should_fail()
126 attr->count++; in should_fail()
127 if (attr->count % attr->interval) in should_fail()
131 if (attr->probability <= prandom_u32() % 100) in should_fail()
134 if (!fail_stacktrace(attr)) in should_fail()
137 fail_dump(attr); in should_fail()
139 if (atomic_read(&attr->times) != -1) in should_fail()
140 atomic_dec_not_zero(&attr->times); in should_fail()
192 struct dentry *parent, struct fault_attr *attr) in fault_create_debugfs_attr() argument
201 if (!debugfs_create_ul("probability", mode, dir, &attr->probability)) in fault_create_debugfs_attr()
203 if (!debugfs_create_ul("interval", mode, dir, &attr->interval)) in fault_create_debugfs_attr()
205 if (!debugfs_create_atomic_t("times", mode, dir, &attr->times)) in fault_create_debugfs_attr()
207 if (!debugfs_create_atomic_t("space", mode, dir, &attr->space)) in fault_create_debugfs_attr()
209 if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose)) in fault_create_debugfs_attr()
212 &attr->ratelimit_state.interval)) in fault_create_debugfs_attr()
215 &attr->ratelimit_state.burst)) in fault_create_debugfs_attr()
217 if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter)) in fault_create_debugfs_attr()
223 &attr->stacktrace_depth)) in fault_create_debugfs_attr()
226 &attr->require_start)) in fault_create_debugfs_attr()
228 if (!debugfs_create_ul("require-end", mode, dir, &attr->require_end)) in fault_create_debugfs_attr()
230 if (!debugfs_create_ul("reject-start", mode, dir, &attr->reject_start)) in fault_create_debugfs_attr()
232 if (!debugfs_create_ul("reject-end", mode, dir, &attr->reject_end)) in fault_create_debugfs_attr()
237 attr->dname = dget(dir); in fault_create_debugfs_attr()