fault-inject: clean up debugfs file creation logic
There is no need to check the return value of a debugfs_create_file call, a caller should never change what they do depending on if debugfs is working properly or not, so remove the checks, simplifying the logic in the file a lot. Also fix up the error check for debugfs_create_dir() which was not returning NULL for an error, but rather a error pointer. Cc: linux-kernel@vger.kernel.org Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9fd714cd7f
commit
053cf51040
|
@ -166,10 +166,10 @@ static int debugfs_ul_get(void *data, u64 *val)
|
|||
|
||||
DEFINE_SIMPLE_ATTRIBUTE(fops_ul, debugfs_ul_get, debugfs_ul_set, "%llu\n");
|
||||
|
||||
static struct dentry *debugfs_create_ul(const char *name, umode_t mode,
|
||||
struct dentry *parent, unsigned long *value)
|
||||
static void debugfs_create_ul(const char *name, umode_t mode,
|
||||
struct dentry *parent, unsigned long *value)
|
||||
{
|
||||
return debugfs_create_file(name, mode, parent, value, &fops_ul);
|
||||
debugfs_create_file(name, mode, parent, value, &fops_ul);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
|
||||
|
@ -185,12 +185,11 @@ static int debugfs_stacktrace_depth_set(void *data, u64 val)
|
|||
DEFINE_SIMPLE_ATTRIBUTE(fops_stacktrace_depth, debugfs_ul_get,
|
||||
debugfs_stacktrace_depth_set, "%llu\n");
|
||||
|
||||
static struct dentry *debugfs_create_stacktrace_depth(
|
||||
const char *name, umode_t mode,
|
||||
struct dentry *parent, unsigned long *value)
|
||||
static void debugfs_create_stacktrace_depth(const char *name, umode_t mode,
|
||||
struct dentry *parent,
|
||||
unsigned long *value)
|
||||
{
|
||||
return debugfs_create_file(name, mode, parent, value,
|
||||
&fops_stacktrace_depth);
|
||||
debugfs_create_file(name, mode, parent, value, &fops_stacktrace_depth);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
|
||||
|
@ -202,51 +201,31 @@ struct dentry *fault_create_debugfs_attr(const char *name,
|
|||
struct dentry *dir;
|
||||
|
||||
dir = debugfs_create_dir(name, parent);
|
||||
if (!dir)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (IS_ERR(dir))
|
||||
return dir;
|
||||
|
||||
if (!debugfs_create_ul("probability", mode, dir, &attr->probability))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("interval", mode, dir, &attr->interval))
|
||||
goto fail;
|
||||
if (!debugfs_create_atomic_t("times", mode, dir, &attr->times))
|
||||
goto fail;
|
||||
if (!debugfs_create_atomic_t("space", mode, dir, &attr->space))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("verbose", mode, dir, &attr->verbose))
|
||||
goto fail;
|
||||
if (!debugfs_create_u32("verbose_ratelimit_interval_ms", mode, dir,
|
||||
&attr->ratelimit_state.interval))
|
||||
goto fail;
|
||||
if (!debugfs_create_u32("verbose_ratelimit_burst", mode, dir,
|
||||
&attr->ratelimit_state.burst))
|
||||
goto fail;
|
||||
if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter))
|
||||
goto fail;
|
||||
debugfs_create_ul("probability", mode, dir, &attr->probability);
|
||||
debugfs_create_ul("interval", mode, dir, &attr->interval);
|
||||
debugfs_create_atomic_t("times", mode, dir, &attr->times);
|
||||
debugfs_create_atomic_t("space", mode, dir, &attr->space);
|
||||
debugfs_create_ul("verbose", mode, dir, &attr->verbose);
|
||||
debugfs_create_u32("verbose_ratelimit_interval_ms", mode, dir,
|
||||
&attr->ratelimit_state.interval);
|
||||
debugfs_create_u32("verbose_ratelimit_burst", mode, dir,
|
||||
&attr->ratelimit_state.burst);
|
||||
debugfs_create_bool("task-filter", mode, dir, &attr->task_filter);
|
||||
|
||||
#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
|
||||
|
||||
if (!debugfs_create_stacktrace_depth("stacktrace-depth", mode, dir,
|
||||
&attr->stacktrace_depth))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("require-start", mode, dir,
|
||||
&attr->require_start))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("require-end", mode, dir, &attr->require_end))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("reject-start", mode, dir, &attr->reject_start))
|
||||
goto fail;
|
||||
if (!debugfs_create_ul("reject-end", mode, dir, &attr->reject_end))
|
||||
goto fail;
|
||||
|
||||
debugfs_create_stacktrace_depth("stacktrace-depth", mode, dir,
|
||||
&attr->stacktrace_depth);
|
||||
debugfs_create_ul("require-start", mode, dir, &attr->require_start);
|
||||
debugfs_create_ul("require-end", mode, dir, &attr->require_end);
|
||||
debugfs_create_ul("reject-start", mode, dir, &attr->reject_start);
|
||||
debugfs_create_ul("reject-end", mode, dir, &attr->reject_end);
|
||||
#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
|
||||
|
||||
attr->dname = dget(dir);
|
||||
return dir;
|
||||
fail:
|
||||
debugfs_remove_recursive(dir);
|
||||
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fault_create_debugfs_attr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue