failslab: simplify debugfs initialization
Now cleanup_fault_attr_dentries() recursively removes a directory, So we can simplify the error handling in the initialization code and no need to hold dentry structs for each debugfs file. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Matt Mackall <mpm@selenic.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7f5ddcc8d3
commit
810f09b87b
|
@ -5,10 +5,6 @@ static struct {
|
||||||
struct fault_attr attr;
|
struct fault_attr attr;
|
||||||
u32 ignore_gfp_wait;
|
u32 ignore_gfp_wait;
|
||||||
int cache_filter;
|
int cache_filter;
|
||||||
#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
|
|
||||||
struct dentry *ignore_gfp_wait_file;
|
|
||||||
struct dentry *cache_filter_file;
|
|
||||||
#endif
|
|
||||||
} failslab = {
|
} failslab = {
|
||||||
.attr = FAULT_ATTR_INITIALIZER,
|
.attr = FAULT_ATTR_INITIALIZER,
|
||||||
.ignore_gfp_wait = 1,
|
.ignore_gfp_wait = 1,
|
||||||
|
@ -39,31 +35,24 @@ __setup("failslab=", setup_failslab);
|
||||||
static int __init failslab_debugfs_init(void)
|
static int __init failslab_debugfs_init(void)
|
||||||
{
|
{
|
||||||
mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
|
mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
|
||||||
struct dentry *dir;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = init_fault_attr_dentries(&failslab.attr, "failslab");
|
err = init_fault_attr_dentries(&failslab.attr, "failslab");
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
dir = failslab.attr.dir;
|
|
||||||
|
|
||||||
failslab.ignore_gfp_wait_file =
|
if (!debugfs_create_bool("ignore-gfp-wait", mode, failslab.attr.dir,
|
||||||
debugfs_create_bool("ignore-gfp-wait", mode, dir,
|
&failslab.ignore_gfp_wait))
|
||||||
&failslab.ignore_gfp_wait);
|
goto fail;
|
||||||
|
if (!debugfs_create_bool("cache-filter", mode, failslab.attr.dir,
|
||||||
|
&failslab.cache_filter))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
failslab.cache_filter_file =
|
return 0;
|
||||||
debugfs_create_bool("cache-filter", mode, dir,
|
fail:
|
||||||
&failslab.cache_filter);
|
|
||||||
|
|
||||||
if (!failslab.ignore_gfp_wait_file ||
|
|
||||||
!failslab.cache_filter_file) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
debugfs_remove(failslab.cache_filter_file);
|
|
||||||
debugfs_remove(failslab.ignore_gfp_wait_file);
|
|
||||||
cleanup_fault_attr_dentries(&failslab.attr);
|
cleanup_fault_attr_dentries(&failslab.attr);
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
late_initcall(failslab_debugfs_init);
|
late_initcall(failslab_debugfs_init);
|
||||||
|
|
Loading…
Reference in New Issue