tracing: make tracing_init_dentry() returns an integer instead of a d_entry pointer
Current tracing_init_dentry() return a d_entry pointer, while is not necessary. This function returns NULL on success or error on failure, which means there is no valid d_entry pointer return. Let's return 0 on success and negative value for error. Link: https://lkml.kernel.org/r/20200712011036.70948-5-richard.weiyang@linux.alibaba.com Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
dc300d77b8
commit
22c36b1826
|
@ -8971,21 +8971,21 @@ static struct vfsmount *trace_automount(struct dentry *mntpt, void *ingore)
|
|||
* directory. It is called via fs_initcall() by any of the boot up code
|
||||
* and expects to return the dentry of the top level tracing directory.
|
||||
*/
|
||||
struct dentry *tracing_init_dentry(void)
|
||||
int tracing_init_dentry(void)
|
||||
{
|
||||
struct trace_array *tr = &global_trace;
|
||||
|
||||
if (security_locked_down(LOCKDOWN_TRACEFS)) {
|
||||
pr_warn("Tracing disabled due to lockdown\n");
|
||||
return ERR_PTR(-EPERM);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/* The top level trace array uses NULL as parent */
|
||||
if (tr->dir)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
if (WARN_ON(!tracefs_initialized()))
|
||||
return ERR_PTR(-ENODEV);
|
||||
return -ENODEV;
|
||||
|
||||
/*
|
||||
* As there may still be users that expect the tracing
|
||||
|
@ -8996,7 +8996,7 @@ struct dentry *tracing_init_dentry(void)
|
|||
tr->dir = debugfs_create_automount("tracing", NULL,
|
||||
trace_automount, NULL);
|
||||
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern struct trace_eval_map *__start_ftrace_eval_maps[];
|
||||
|
@ -9083,48 +9083,48 @@ static struct notifier_block trace_module_nb = {
|
|||
|
||||
static __init int tracer_init_tracefs(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
|
||||
trace_access_lock_init();
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
event_trace_init();
|
||||
|
||||
init_tracer_tracefs(&global_trace, d_tracer);
|
||||
ftrace_init_tracefs_toplevel(&global_trace, d_tracer);
|
||||
init_tracer_tracefs(&global_trace, NULL);
|
||||
ftrace_init_tracefs_toplevel(&global_trace, NULL);
|
||||
|
||||
trace_create_file("tracing_thresh", 0644, d_tracer,
|
||||
trace_create_file("tracing_thresh", 0644, NULL,
|
||||
&global_trace, &tracing_thresh_fops);
|
||||
|
||||
trace_create_file("README", 0444, d_tracer,
|
||||
trace_create_file("README", 0444, NULL,
|
||||
NULL, &tracing_readme_fops);
|
||||
|
||||
trace_create_file("saved_cmdlines", 0444, d_tracer,
|
||||
trace_create_file("saved_cmdlines", 0444, NULL,
|
||||
NULL, &tracing_saved_cmdlines_fops);
|
||||
|
||||
trace_create_file("saved_cmdlines_size", 0644, d_tracer,
|
||||
trace_create_file("saved_cmdlines_size", 0644, NULL,
|
||||
NULL, &tracing_saved_cmdlines_size_fops);
|
||||
|
||||
trace_create_file("saved_tgids", 0444, d_tracer,
|
||||
trace_create_file("saved_tgids", 0444, NULL,
|
||||
NULL, &tracing_saved_tgids_fops);
|
||||
|
||||
trace_eval_init();
|
||||
|
||||
trace_create_eval_file(d_tracer);
|
||||
trace_create_eval_file(NULL);
|
||||
|
||||
#ifdef CONFIG_MODULES
|
||||
register_module_notifier(&trace_module_nb);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
|
||||
trace_create_file("dyn_ftrace_total_info", 0444, NULL,
|
||||
NULL, &tracing_dyn_info_fops);
|
||||
#endif
|
||||
|
||||
create_trace_instances(d_tracer);
|
||||
create_trace_instances(NULL);
|
||||
|
||||
update_tracer_options(&global_trace);
|
||||
|
||||
|
|
|
@ -737,7 +737,7 @@ struct dentry *trace_create_file(const char *name,
|
|||
void *data,
|
||||
const struct file_operations *fops);
|
||||
|
||||
struct dentry *tracing_init_dentry(void);
|
||||
int tracing_init_dentry(void);
|
||||
|
||||
struct ring_buffer_event;
|
||||
|
||||
|
|
|
@ -206,14 +206,14 @@ static const struct file_operations dynamic_events_ops = {
|
|||
/* Make a tracefs interface for controlling dynamic events */
|
||||
static __init int init_dynamic_event(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
struct dentry *entry;
|
||||
int ret;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
entry = tracefs_create_file("dynamic_events", 0644, d_tracer,
|
||||
entry = tracefs_create_file("dynamic_events", 0644, NULL,
|
||||
NULL, &dynamic_events_ops);
|
||||
|
||||
/* Event list interface */
|
||||
|
|
|
@ -1757,7 +1757,6 @@ static const struct file_operations synth_events_fops = {
|
|||
static __init int trace_events_synth_init(void)
|
||||
{
|
||||
struct dentry *entry = NULL;
|
||||
struct dentry *d_tracer;
|
||||
int err = 0;
|
||||
|
||||
err = dyn_event_register(&synth_event_ops);
|
||||
|
@ -1766,13 +1765,11 @@ static __init int trace_events_synth_init(void)
|
|||
return err;
|
||||
}
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer)) {
|
||||
err = PTR_ERR(d_tracer);
|
||||
err = tracing_init_dentry();
|
||||
if (err)
|
||||
goto err;
|
||||
}
|
||||
|
||||
entry = tracefs_create_file("synthetic_events", 0644, d_tracer,
|
||||
entry = tracefs_create_file("synthetic_events", 0644, NULL,
|
||||
NULL, &synth_events_fops);
|
||||
if (!entry) {
|
||||
err = -ENODEV;
|
||||
|
|
|
@ -1336,13 +1336,13 @@ static const struct file_operations graph_depth_fops = {
|
|||
|
||||
static __init int init_graph_tracefs(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
trace_create_file("max_graph_depth", 0644, d_tracer,
|
||||
trace_create_file("max_graph_depth", 0644, NULL,
|
||||
NULL, &graph_depth_fops);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -538,14 +538,14 @@ static const struct file_operations window_fops = {
|
|||
*/
|
||||
static int init_tracefs(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
struct dentry *top_dir;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return -ENOMEM;
|
||||
|
||||
top_dir = tracefs_create_dir("hwlat_detector", d_tracer);
|
||||
top_dir = tracefs_create_dir("hwlat_detector", NULL);
|
||||
if (!top_dir)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -1901,14 +1901,14 @@ subsys_initcall(init_kprobe_trace_early);
|
|||
/* Make a tracefs interface for controlling probe points */
|
||||
static __init int init_kprobe_trace(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
struct dentry *entry;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
entry = tracefs_create_file("kprobe_events", 0644, d_tracer,
|
||||
entry = tracefs_create_file("kprobe_events", 0644, NULL,
|
||||
NULL, &kprobe_events_ops);
|
||||
|
||||
/* Event list interface */
|
||||
|
@ -1916,7 +1916,7 @@ static __init int init_kprobe_trace(void)
|
|||
pr_warn("Could not create tracefs 'kprobe_events' entry\n");
|
||||
|
||||
/* Profile interface */
|
||||
entry = tracefs_create_file("kprobe_profile", 0444, d_tracer,
|
||||
entry = tracefs_create_file("kprobe_profile", 0444, NULL,
|
||||
NULL, &kprobe_profile_ops);
|
||||
|
||||
if (!entry)
|
||||
|
|
|
@ -367,13 +367,13 @@ static const struct file_operations ftrace_formats_fops = {
|
|||
|
||||
static __init int init_trace_printk_function_export(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
trace_create_file("printk_formats", 0444, d_tracer,
|
||||
trace_create_file("printk_formats", 0444, NULL,
|
||||
NULL, &ftrace_formats_fops);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -554,20 +554,20 @@ __setup("stacktrace", enable_stacktrace);
|
|||
|
||||
static __init int stack_trace_init(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
trace_create_file("stack_max_size", 0644, d_tracer,
|
||||
trace_create_file("stack_max_size", 0644, NULL,
|
||||
&stack_trace_max_size, &stack_max_size_fops);
|
||||
|
||||
trace_create_file("stack_trace", 0444, d_tracer,
|
||||
trace_create_file("stack_trace", 0444, NULL,
|
||||
NULL, &stack_trace_fops);
|
||||
|
||||
#ifdef CONFIG_DYNAMIC_FTRACE
|
||||
trace_create_file("stack_trace_filter", 0644, d_tracer,
|
||||
trace_create_file("stack_trace_filter", 0644, NULL,
|
||||
&trace_ops, &stack_trace_filter_fops);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -276,13 +276,13 @@ static const struct file_operations tracing_stat_fops = {
|
|||
|
||||
static int tracing_stat_init(void)
|
||||
{
|
||||
struct dentry *d_tracing;
|
||||
int ret;
|
||||
|
||||
d_tracing = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracing))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return -ENODEV;
|
||||
|
||||
stat_dir = tracefs_create_dir("trace_stat", d_tracing);
|
||||
stat_dir = tracefs_create_dir("trace_stat", NULL);
|
||||
if (!stat_dir) {
|
||||
pr_warn("Could not create tracefs 'trace_stat' entry\n");
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -1625,21 +1625,20 @@ void destroy_local_trace_uprobe(struct trace_event_call *event_call)
|
|||
/* Make a trace interface for controling probe points */
|
||||
static __init int init_uprobe_trace(void)
|
||||
{
|
||||
struct dentry *d_tracer;
|
||||
int ret;
|
||||
|
||||
ret = dyn_event_register(&trace_uprobe_ops);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
d_tracer = tracing_init_dentry();
|
||||
if (IS_ERR(d_tracer))
|
||||
ret = tracing_init_dentry();
|
||||
if (ret)
|
||||
return 0;
|
||||
|
||||
trace_create_file("uprobe_events", 0644, d_tracer,
|
||||
trace_create_file("uprobe_events", 0644, NULL,
|
||||
NULL, &uprobe_events_ops);
|
||||
/* Profile interface */
|
||||
trace_create_file("uprobe_profile", 0444, d_tracer,
|
||||
trace_create_file("uprobe_profile", 0444, NULL,
|
||||
NULL, &uprobe_profile_ops);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user