diff options
Diffstat (limited to 'lib/fault-inject.c')
-rw-r--r-- | lib/fault-inject.c | 115 |
1 files changed, 27 insertions, 88 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 882fd3b6a6ad..2577b121c7c1 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c | |||
@@ -199,48 +199,7 @@ static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode, | |||
199 | 199 | ||
200 | void cleanup_fault_attr_dentries(struct fault_attr *attr) | 200 | void cleanup_fault_attr_dentries(struct fault_attr *attr) |
201 | { | 201 | { |
202 | debugfs_remove(attr->dentries.probability_file); | 202 | debugfs_remove_recursive(attr->dir); |
203 | attr->dentries.probability_file = NULL; | ||
204 | |||
205 | debugfs_remove(attr->dentries.interval_file); | ||
206 | attr->dentries.interval_file = NULL; | ||
207 | |||
208 | debugfs_remove(attr->dentries.times_file); | ||
209 | attr->dentries.times_file = NULL; | ||
210 | |||
211 | debugfs_remove(attr->dentries.space_file); | ||
212 | attr->dentries.space_file = NULL; | ||
213 | |||
214 | debugfs_remove(attr->dentries.verbose_file); | ||
215 | attr->dentries.verbose_file = NULL; | ||
216 | |||
217 | debugfs_remove(attr->dentries.task_filter_file); | ||
218 | attr->dentries.task_filter_file = NULL; | ||
219 | |||
220 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | ||
221 | |||
222 | debugfs_remove(attr->dentries.stacktrace_depth_file); | ||
223 | attr->dentries.stacktrace_depth_file = NULL; | ||
224 | |||
225 | debugfs_remove(attr->dentries.require_start_file); | ||
226 | attr->dentries.require_start_file = NULL; | ||
227 | |||
228 | debugfs_remove(attr->dentries.require_end_file); | ||
229 | attr->dentries.require_end_file = NULL; | ||
230 | |||
231 | debugfs_remove(attr->dentries.reject_start_file); | ||
232 | attr->dentries.reject_start_file = NULL; | ||
233 | |||
234 | debugfs_remove(attr->dentries.reject_end_file); | ||
235 | attr->dentries.reject_end_file = NULL; | ||
236 | |||
237 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | ||
238 | |||
239 | if (attr->dentries.dir) | ||
240 | WARN_ON(!simple_empty(attr->dentries.dir)); | ||
241 | |||
242 | debugfs_remove(attr->dentries.dir); | ||
243 | attr->dentries.dir = NULL; | ||
244 | } | 203 | } |
245 | 204 | ||
246 | int init_fault_attr_dentries(struct fault_attr *attr, const char *name) | 205 | int init_fault_attr_dentries(struct fault_attr *attr, const char *name) |
@@ -248,66 +207,46 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name) | |||
248 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 207 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; |
249 | struct dentry *dir; | 208 | struct dentry *dir; |
250 | 209 | ||
251 | memset(&attr->dentries, 0, sizeof(attr->dentries)); | ||
252 | |||
253 | dir = debugfs_create_dir(name, NULL); | 210 | dir = debugfs_create_dir(name, NULL); |
254 | if (!dir) | 211 | if (!dir) |
255 | goto fail; | 212 | return -ENOMEM; |
256 | attr->dentries.dir = dir; | ||
257 | |||
258 | attr->dentries.probability_file = | ||
259 | debugfs_create_ul("probability", mode, dir, &attr->probability); | ||
260 | 213 | ||
261 | attr->dentries.interval_file = | 214 | attr->dir = dir; |
262 | debugfs_create_ul("interval", mode, dir, &attr->interval); | ||
263 | 215 | ||
264 | attr->dentries.times_file = | 216 | if (!debugfs_create_ul("probability", mode, dir, &attr->probability)) |
265 | debugfs_create_atomic_t("times", mode, dir, &attr->times); | 217 | goto fail; |
266 | 218 | if (!debugfs_create_ul("interval", mode, dir, &attr->interval)) | |
267 | attr->dentries.space_file = | 219 | goto fail; |
268 | debugfs_create_atomic_t("space", mode, dir, &attr->space); | 220 | if (!debugfs_create_atomic_t("times", mode, dir, &attr->times)) |
269 | 221 | goto fail; | |
270 | attr->dentries.verbose_file = | 222 | if (!debugfs_create_atomic_t("space", mode, dir, &attr->space)) |
271 | debugfs_create_ul("verbose", mode, dir, &attr->verbose); | 223 | goto fail; |
272 | 224 | if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose)) | |
273 | attr->dentries.task_filter_file = debugfs_create_bool("task-filter", | 225 | goto fail; |
274 | mode, dir, &attr->task_filter); | 226 | if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter)) |
275 | |||
276 | if (!attr->dentries.probability_file || !attr->dentries.interval_file || | ||
277 | !attr->dentries.times_file || !attr->dentries.space_file || | ||
278 | !attr->dentries.verbose_file || !attr->dentries.task_filter_file) | ||
279 | goto fail; | 227 | goto fail; |
280 | 228 | ||
281 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER | 229 | #ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER |
282 | 230 | ||
283 | attr->dentries.stacktrace_depth_file = | 231 | if (!debugfs_create_stacktrace_depth("stacktrace-depth", mode, dir, |
284 | debugfs_create_stacktrace_depth( | 232 | &attr->stacktrace_depth)) |
285 | "stacktrace-depth", mode, dir, &attr->stacktrace_depth); | 233 | goto fail; |
286 | 234 | if (!debugfs_create_ul("require-start", mode, dir, | |
287 | attr->dentries.require_start_file = | 235 | &attr->require_start)) |
288 | debugfs_create_ul("require-start", mode, dir, &attr->require_start); | 236 | goto fail; |
289 | 237 | if (!debugfs_create_ul("require-end", mode, dir, &attr->require_end)) | |
290 | attr->dentries.require_end_file = | 238 | goto fail; |
291 | debugfs_create_ul("require-end", mode, dir, &attr->require_end); | 239 | if (!debugfs_create_ul("reject-start", mode, dir, &attr->reject_start)) |
292 | 240 | goto fail; | |
293 | attr->dentries.reject_start_file = | 241 | if (!debugfs_create_ul("reject-end", mode, dir, &attr->reject_end)) |
294 | debugfs_create_ul("reject-start", mode, dir, &attr->reject_start); | ||
295 | |||
296 | attr->dentries.reject_end_file = | ||
297 | debugfs_create_ul("reject-end", mode, dir, &attr->reject_end); | ||
298 | |||
299 | if (!attr->dentries.stacktrace_depth_file || | ||
300 | !attr->dentries.require_start_file || | ||
301 | !attr->dentries.require_end_file || | ||
302 | !attr->dentries.reject_start_file || | ||
303 | !attr->dentries.reject_end_file) | ||
304 | goto fail; | 242 | goto fail; |
305 | 243 | ||
306 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ | 244 | #endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ |
307 | 245 | ||
308 | return 0; | 246 | return 0; |
309 | fail: | 247 | fail: |
310 | cleanup_fault_attr_dentries(attr); | 248 | debugfs_remove_recursive(attr->dir); |
249 | |||
311 | return -ENOMEM; | 250 | return -ENOMEM; |
312 | } | 251 | } |
313 | 252 | ||