diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2011-08-03 19:21:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-03 20:25:20 -0400 |
commit | dd48c085c1cdf9446f92826f1fd451167fb6c2fd (patch) | |
tree | d62870378cc08af36ea7a41531436bdebddec232 /mm | |
parent | f48d1915b86f06a943087e5f9b29542a1ef4cd4d (diff) |
fault-injection: add ability to export fault_attr in arbitrary directory
init_fault_attr_dentries() is used to export fault_attr via debugfs.
But it can only export it in debugfs root directory.
Per Forlin is working on mmc_fail_request which adds support to inject
data errors after a completed host transfer in MMC subsystem.
The fault_attr for mmc_fail_request should be defined per mmc host and
export it in debugfs directory per mmc host like
/sys/kernel/debug/mmc0/mmc_fail_request.
init_fault_attr_dentries() doesn't help for mmc_fail_request. So this
introduces fault_create_debugfs_attr() which is able to create a
directory in the arbitrary directory and replace
init_fault_attr_dentries().
[akpm@linux-foundation.org: extraneous semicolon, per Randy]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Tested-by: Per Forlin <per.forlin@linaro.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/failslab.c | 14 | ||||
-rw-r--r-- | mm/page_alloc.c | 13 |
2 files changed, 12 insertions, 15 deletions
diff --git a/mm/failslab.c b/mm/failslab.c index 1ce58c201dc..0dd7b8fec71 100644 --- a/mm/failslab.c +++ b/mm/failslab.c | |||
@@ -34,23 +34,23 @@ __setup("failslab=", setup_failslab); | |||
34 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | 34 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
35 | static int __init failslab_debugfs_init(void) | 35 | static int __init failslab_debugfs_init(void) |
36 | { | 36 | { |
37 | struct dentry *dir; | ||
37 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 38 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; |
38 | int err; | ||
39 | 39 | ||
40 | err = init_fault_attr_dentries(&failslab.attr, "failslab"); | 40 | dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr); |
41 | if (err) | 41 | if (IS_ERR(dir)) |
42 | return err; | 42 | return PTR_ERR(dir); |
43 | 43 | ||
44 | if (!debugfs_create_bool("ignore-gfp-wait", mode, failslab.attr.dir, | 44 | if (!debugfs_create_bool("ignore-gfp-wait", mode, dir, |
45 | &failslab.ignore_gfp_wait)) | 45 | &failslab.ignore_gfp_wait)) |
46 | goto fail; | 46 | goto fail; |
47 | if (!debugfs_create_bool("cache-filter", mode, failslab.attr.dir, | 47 | if (!debugfs_create_bool("cache-filter", mode, dir, |
48 | &failslab.cache_filter)) | 48 | &failslab.cache_filter)) |
49 | goto fail; | 49 | goto fail; |
50 | 50 | ||
51 | return 0; | 51 | return 0; |
52 | fail: | 52 | fail: |
53 | cleanup_fault_attr_dentries(&failslab.attr); | 53 | debugfs_remove_recursive(dir); |
54 | 54 | ||
55 | return -ENOMEM; | 55 | return -ENOMEM; |
56 | } | 56 | } |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1dbcf8888f1..6e8ecb6e021 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1409,14 +1409,11 @@ static int __init fail_page_alloc_debugfs(void) | |||
1409 | { | 1409 | { |
1410 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 1410 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; |
1411 | struct dentry *dir; | 1411 | struct dentry *dir; |
1412 | int err; | ||
1413 | 1412 | ||
1414 | err = init_fault_attr_dentries(&fail_page_alloc.attr, | 1413 | dir = fault_create_debugfs_attr("fail_page_alloc", NULL, |
1415 | "fail_page_alloc"); | 1414 | &fail_page_alloc.attr); |
1416 | if (err) | 1415 | if (IS_ERR(dir)) |
1417 | return err; | 1416 | return PTR_ERR(dir); |
1418 | |||
1419 | dir = fail_page_alloc.attr.dir; | ||
1420 | 1417 | ||
1421 | if (!debugfs_create_bool("ignore-gfp-wait", mode, dir, | 1418 | if (!debugfs_create_bool("ignore-gfp-wait", mode, dir, |
1422 | &fail_page_alloc.ignore_gfp_wait)) | 1419 | &fail_page_alloc.ignore_gfp_wait)) |
@@ -1430,7 +1427,7 @@ static int __init fail_page_alloc_debugfs(void) | |||
1430 | 1427 | ||
1431 | return 0; | 1428 | return 0; |
1432 | fail: | 1429 | fail: |
1433 | cleanup_fault_attr_dentries(&fail_page_alloc.attr); | 1430 | debugfs_remove_recursive(dir); |
1434 | 1431 | ||
1435 | return -ENOMEM; | 1432 | return -ENOMEM; |
1436 | } | 1433 | } |