Commit a88e1cfb authored by Tom Zanussi's avatar Tom Zanussi Committed by Steven Rostedt

tracing: Add an unreg_all() callback to trigger commands

Add a new unreg_all() callback that can be used to remove all
command-specific triggers from an event and arrange to have it called
whenever a trigger file is opened with O_TRUNC set.

Commands that don't want truncate semantics, or existing commands that
don't implement this function simply do nothing and their triggers
remain intact.

Link: http://lkml.kernel.org/r/2b7d62854d01f28c19185e1bbb8f826f385edfba.1449767187.git.tom.zanussi@linux.intel.comSigned-off-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent a5863dae
...@@ -1298,8 +1298,8 @@ struct event_trigger_ops { ...@@ -1298,8 +1298,8 @@ struct event_trigger_ops {
* it (filters make a trigger require access to the trace record * it (filters make a trigger require access to the trace record
* but are not always present). * but are not always present).
* *
* All the methods below, except for @set_filter(), must be * All the methods below, except for @set_filter() and @unreg_all(),
* implemented. * must be implemented.
* *
* @func: The callback function responsible for parsing and * @func: The callback function responsible for parsing and
* registering the trigger written to the 'trigger' file by the * registering the trigger written to the 'trigger' file by the
...@@ -1324,6 +1324,10 @@ struct event_trigger_ops { ...@@ -1324,6 +1324,10 @@ struct event_trigger_ops {
* This is usually implemented by the generic utility function * This is usually implemented by the generic utility function
* @unregister_trigger() (see trace_event_triggers.c). * @unregister_trigger() (see trace_event_triggers.c).
* *
* @unreg_all: An optional function called to remove all the triggers
* from the list of triggers associated with the event. Called
* when a trigger file is opened in truncate mode.
*
* @set_filter: An optional function called to parse and set a filter * @set_filter: An optional function called to parse and set a filter
* for the trigger. If no @set_filter() method is set for the * for the trigger. If no @set_filter() method is set for the
* event command, filters set by the user for the command will be * event command, filters set by the user for the command will be
...@@ -1350,6 +1354,7 @@ struct event_command { ...@@ -1350,6 +1354,7 @@ struct event_command {
struct event_trigger_ops *ops, struct event_trigger_ops *ops,
struct event_trigger_data *data, struct event_trigger_data *data,
struct trace_event_file *file); struct trace_event_file *file);
void (*unreg_all)(struct trace_event_file *file);
int (*set_filter)(char *filter_str, int (*set_filter)(char *filter_str,
struct event_trigger_data *data, struct event_trigger_data *data,
struct trace_event_file *file); struct trace_event_file *file);
......
...@@ -193,6 +193,19 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file) ...@@ -193,6 +193,19 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file)
return -ENODEV; return -ENODEV;
} }
if ((file->f_mode & FMODE_WRITE) &&
(file->f_flags & O_TRUNC)) {
struct trace_event_file *event_file;
struct event_command *p;
event_file = event_file_data(file);
list_for_each_entry(p, &trigger_commands, list) {
if (p->unreg_all)
p->unreg_all(event_file);
}
}
if (file->f_mode & FMODE_READ) { if (file->f_mode & FMODE_READ) {
ret = seq_open(file, &event_triggers_seq_ops); ret = seq_open(file, &event_triggers_seq_ops);
if (!ret) { if (!ret) {
......
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