Commit 098c879e authored by Steven Rostedt (Red Hat)'s avatar Steven Rostedt (Red Hat) Committed by Steven Rostedt

tracing: Add generic tracing_lseek() function

Trace event triggers added a lseek that uses the ftrace_filter_lseek()
function. Unfortunately, when function tracing is not configured in
that function is not defined and the kernel fails to build.

This is the second time that function was added to a file ops and
it broke the build due to requiring special config dependencies.

Make a generic tracing_lseek() that all the tracing utilities may
use.

Also, modify the old ftrace_filter_lseek() to return 0 instead of
1 on WRONLY. Not sure why it was a 1 as that does not make sense.

This also changes the old tracing_seek() to modify the file pos
pointer on WRONLY as well.
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Tested-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Acked-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent ac38fb85
...@@ -570,8 +570,6 @@ static inline int ...@@ -570,8 +570,6 @@ static inline int
ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; } ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; }
#endif /* CONFIG_DYNAMIC_FTRACE */ #endif /* CONFIG_DYNAMIC_FTRACE */
loff_t ftrace_filter_lseek(struct file *file, loff_t offset, int whence);
/* totally disable ftrace - can not re-enable after this */ /* totally disable ftrace - can not re-enable after this */
void ftrace_kill(void); void ftrace_kill(void);
......
...@@ -1082,19 +1082,6 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer) ...@@ -1082,19 +1082,6 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
static struct pid * const ftrace_swapper_pid = &init_struct_pid; static struct pid * const ftrace_swapper_pid = &init_struct_pid;
loff_t
ftrace_filter_lseek(struct file *file, loff_t offset, int whence)
{
loff_t ret;
if (file->f_mode & FMODE_READ)
ret = seq_lseek(file, offset, whence);
else
file->f_pos = ret = 1;
return ret;
}
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
#ifndef CONFIG_FTRACE_MCOUNT_RECORD #ifndef CONFIG_FTRACE_MCOUNT_RECORD
...@@ -2739,7 +2726,7 @@ static void ftrace_filter_reset(struct ftrace_hash *hash) ...@@ -2739,7 +2726,7 @@ static void ftrace_filter_reset(struct ftrace_hash *hash)
* routine, you can use ftrace_filter_write() for the write * routine, you can use ftrace_filter_write() for the write
* routine if @flag has FTRACE_ITER_FILTER set, or * routine if @flag has FTRACE_ITER_FILTER set, or
* ftrace_notrace_write() if @flag has FTRACE_ITER_NOTRACE set. * ftrace_notrace_write() if @flag has FTRACE_ITER_NOTRACE set.
* ftrace_filter_lseek() should be used as the lseek routine, and * tracing_lseek() should be used as the lseek routine, and
* release must call ftrace_regex_release(). * release must call ftrace_regex_release().
*/ */
int int
...@@ -3767,7 +3754,7 @@ static const struct file_operations ftrace_filter_fops = { ...@@ -3767,7 +3754,7 @@ static const struct file_operations ftrace_filter_fops = {
.open = ftrace_filter_open, .open = ftrace_filter_open,
.read = seq_read, .read = seq_read,
.write = ftrace_filter_write, .write = ftrace_filter_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_regex_release, .release = ftrace_regex_release,
}; };
...@@ -3775,7 +3762,7 @@ static const struct file_operations ftrace_notrace_fops = { ...@@ -3775,7 +3762,7 @@ static const struct file_operations ftrace_notrace_fops = {
.open = ftrace_notrace_open, .open = ftrace_notrace_open,
.read = seq_read, .read = seq_read,
.write = ftrace_notrace_write, .write = ftrace_notrace_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_regex_release, .release = ftrace_regex_release,
}; };
...@@ -4038,7 +4025,7 @@ static const struct file_operations ftrace_graph_fops = { ...@@ -4038,7 +4025,7 @@ static const struct file_operations ftrace_graph_fops = {
.open = ftrace_graph_open, .open = ftrace_graph_open,
.read = seq_read, .read = seq_read,
.write = ftrace_graph_write, .write = ftrace_graph_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_graph_release, .release = ftrace_graph_release,
}; };
...@@ -4046,7 +4033,7 @@ static const struct file_operations ftrace_graph_notrace_fops = { ...@@ -4046,7 +4033,7 @@ static const struct file_operations ftrace_graph_notrace_fops = {
.open = ftrace_graph_notrace_open, .open = ftrace_graph_notrace_open,
.read = seq_read, .read = seq_read,
.write = ftrace_graph_write, .write = ftrace_graph_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_graph_release, .release = ftrace_graph_release,
}; };
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
...@@ -4719,7 +4706,7 @@ static const struct file_operations ftrace_pid_fops = { ...@@ -4719,7 +4706,7 @@ static const struct file_operations ftrace_pid_fops = {
.open = ftrace_pid_open, .open = ftrace_pid_open,
.write = ftrace_pid_write, .write = ftrace_pid_write,
.read = seq_read, .read = seq_read,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_pid_release, .release = ftrace_pid_release,
}; };
......
...@@ -3183,19 +3183,23 @@ tracing_write_stub(struct file *filp, const char __user *ubuf, ...@@ -3183,19 +3183,23 @@ tracing_write_stub(struct file *filp, const char __user *ubuf,
return count; return count;
} }
static loff_t tracing_seek(struct file *file, loff_t offset, int origin) loff_t tracing_lseek(struct file *file, loff_t offset, int whence)
{ {
int ret;
if (file->f_mode & FMODE_READ) if (file->f_mode & FMODE_READ)
return seq_lseek(file, offset, origin); ret = seq_lseek(file, offset, whence);
else else
return 0; file->f_pos = ret = 0;
return ret;
} }
static const struct file_operations tracing_fops = { static const struct file_operations tracing_fops = {
.open = tracing_open, .open = tracing_open,
.read = seq_read, .read = seq_read,
.write = tracing_write_stub, .write = tracing_write_stub,
.llseek = tracing_seek, .llseek = tracing_lseek,
.release = tracing_release, .release = tracing_release,
}; };
...@@ -4940,7 +4944,7 @@ static const struct file_operations snapshot_fops = { ...@@ -4940,7 +4944,7 @@ static const struct file_operations snapshot_fops = {
.open = tracing_snapshot_open, .open = tracing_snapshot_open,
.read = seq_read, .read = seq_read,
.write = tracing_snapshot_write, .write = tracing_snapshot_write,
.llseek = tracing_seek, .llseek = tracing_lseek,
.release = tracing_snapshot_release, .release = tracing_snapshot_release,
}; };
......
...@@ -588,6 +588,8 @@ void tracing_start_sched_switch_record(void); ...@@ -588,6 +588,8 @@ void tracing_start_sched_switch_record(void);
int register_tracer(struct tracer *type); int register_tracer(struct tracer *type);
int is_tracing_stopped(void); int is_tracing_stopped(void);
loff_t tracing_lseek(struct file *file, loff_t offset, int whence);
extern cpumask_var_t __read_mostly tracing_buffer_mask; extern cpumask_var_t __read_mostly tracing_buffer_mask;
#define for_each_tracing_cpu(cpu) \ #define for_each_tracing_cpu(cpu) \
......
...@@ -281,7 +281,7 @@ const struct file_operations event_trigger_fops = { ...@@ -281,7 +281,7 @@ const struct file_operations event_trigger_fops = {
.open = event_trigger_open, .open = event_trigger_open,
.read = seq_read, .read = seq_read,
.write = event_trigger_write, .write = event_trigger_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = event_trigger_release, .release = event_trigger_release,
}; };
......
...@@ -382,7 +382,7 @@ static const struct file_operations stack_trace_filter_fops = { ...@@ -382,7 +382,7 @@ static const struct file_operations stack_trace_filter_fops = {
.open = stack_trace_filter_open, .open = stack_trace_filter_open,
.read = seq_read, .read = seq_read,
.write = ftrace_filter_write, .write = ftrace_filter_write,
.llseek = ftrace_filter_lseek, .llseek = tracing_lseek,
.release = ftrace_regex_release, .release = ftrace_regex_release,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment