提交 ff98781b 编写于 作者: E Eduard - Gabriel Munteanu 提交者: Steven Rostedt

tracing: Move pipe waiting code out of tracing_read_pipe().

This moves the pipe waiting code from tracing_read_pipe() into
tracing_wait_pipe(), which is useful to implement other fops, like
splice_read.
Signed-off-by: NEduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
上级 3c56819b
...@@ -2388,37 +2388,15 @@ tracing_poll_pipe(struct file *filp, poll_table *poll_table) ...@@ -2388,37 +2388,15 @@ tracing_poll_pipe(struct file *filp, poll_table *poll_table)
} }
} }
/* /* Must be called with trace_types_lock mutex held. */
* Consumer reader. static int tracing_wait_pipe(struct file *filp)
*/
static ssize_t
tracing_read_pipe(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
{ {
struct trace_iterator *iter = filp->private_data; struct trace_iterator *iter = filp->private_data;
ssize_t sret;
/* return any leftover data */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (sret != -EBUSY)
return sret;
trace_seq_reset(&iter->seq);
mutex_lock(&trace_types_lock);
if (iter->trace->read) {
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
if (sret)
goto out;
}
waitagain:
sret = 0;
while (trace_empty(iter)) { while (trace_empty(iter)) {
if ((filp->f_flags & O_NONBLOCK)) { if ((filp->f_flags & O_NONBLOCK)) {
sret = -EAGAIN; return -EAGAIN;
goto out;
} }
/* /*
...@@ -2443,12 +2421,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, ...@@ -2443,12 +2421,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
iter->tr->waiter = NULL; iter->tr->waiter = NULL;
if (signal_pending(current)) { if (signal_pending(current)) {
sret = -EINTR; return -EINTR;
goto out;
} }
if (iter->trace != current_trace) if (iter->trace != current_trace)
goto out; return 0;
/* /*
* We block until we read something and tracing is disabled. * We block until we read something and tracing is disabled.
...@@ -2465,9 +2442,43 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, ...@@ -2465,9 +2442,43 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
continue; continue;
} }
return 1;
}
/*
* Consumer reader.
*/
static ssize_t
tracing_read_pipe(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
{
struct trace_iterator *iter = filp->private_data;
ssize_t sret;
/* return any leftover data */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
if (sret != -EBUSY)
return sret;
trace_seq_reset(&iter->seq);
mutex_lock(&trace_types_lock);
if (iter->trace->read) {
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
if (sret)
goto out;
}
waitagain:
sret = tracing_wait_pipe(filp);
if (sret <= 0)
goto out;
/* stop when tracing is finished */ /* stop when tracing is finished */
if (trace_empty(iter)) if (trace_empty(iter)) {
sret = 0;
goto out; goto out;
}
if (cnt >= PAGE_SIZE) if (cnt >= PAGE_SIZE)
cnt = PAGE_SIZE - 1; cnt = PAGE_SIZE - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册