aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2011-07-26 19:09:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-26 19:49:46 -0400
commit7f5ddcc8d3eaccd5e169fda738530f937509645e (patch)
tree14f5581871040f98bbdab864314e1afc00a19a4c
parent8307fc257cf3931d87e172bd8663e80c3d1e56a3 (diff)
fault-injection: use debugfs_remove_recursive
Use debugfs_remove_recursive() to simplify initialization and deinitialization of fault injection debugfs files. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/fault-inject.h18
-rw-r--r--lib/fault-inject.c115
-rw-r--r--mm/failslab.c2
-rw-r--r--mm/page_alloc.c2
4 files changed, 30 insertions, 107 deletions
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
index 7b72328cc8fe..a842db638380 100644
--- a/include/linux/fault-inject.h
+++ b/include/linux/fault-inject.h
@@ -27,23 +27,7 @@ struct fault_attr {
27 unsigned long count; 27 unsigned long count;
28 28
29#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 29#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
30 30 struct dentry *dir;
31 struct {
32 struct dentry *dir;
33
34 struct dentry *probability_file;
35 struct dentry *interval_file;
36 struct dentry *times_file;
37 struct dentry *space_file;
38 struct dentry *verbose_file;
39 struct dentry *task_filter_file;
40 struct dentry *stacktrace_depth_file;
41 struct dentry *require_start_file;
42 struct dentry *require_end_file;
43 struct dentry *reject_start_file;
44 struct dentry *reject_end_file;
45 } dentries;
46
47#endif 31#endif
48}; 32};
49 33
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
200void cleanup_fault_attr_dentries(struct fault_attr *attr) 200void 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
246int init_fault_attr_dentries(struct fault_attr *attr, const char *name) 205int 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;
309fail: 247fail:
310 cleanup_fault_attr_dentries(attr); 248 debugfs_remove_recursive(attr->dir);
249
311 return -ENOMEM; 250 return -ENOMEM;
312} 251}
313 252
diff --git a/mm/failslab.c b/mm/failslab.c
index c5f88f240ddc..7df9f7f0abf1 100644
--- a/mm/failslab.c
+++ b/mm/failslab.c
@@ -45,7 +45,7 @@ static int __init failslab_debugfs_init(void)
45 err = init_fault_attr_dentries(&failslab.attr, "failslab"); 45 err = init_fault_attr_dentries(&failslab.attr, "failslab");
46 if (err) 46 if (err)
47 return err; 47 return err;
48 dir = failslab.attr.dentries.dir; 48 dir = failslab.attr.dir;
49 49
50 failslab.ignore_gfp_wait_file = 50 failslab.ignore_gfp_wait_file =
51 debugfs_create_bool("ignore-gfp-wait", mode, dir, 51 debugfs_create_bool("ignore-gfp-wait", mode, dir,
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 094472377d81..72c6820a345c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1424,7 +1424,7 @@ static int __init fail_page_alloc_debugfs(void)
1424 "fail_page_alloc"); 1424 "fail_page_alloc");
1425 if (err) 1425 if (err)
1426 return err; 1426 return err;
1427 dir = fail_page_alloc.attr.dentries.dir; 1427 dir = fail_page_alloc.attr.dir;
1428 1428
1429 fail_page_alloc.ignore_gfp_wait_file = 1429 fail_page_alloc.ignore_gfp_wait_file =
1430 debugfs_create_bool("ignore-gfp-wait", mode, dir, 1430 debugfs_create_bool("ignore-gfp-wait", mode, dir,