|
@@ -5124,19 +5124,20 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
|
|
struct trace_iterator *iter = filp->private_data;
|
|
struct trace_iterator *iter = filp->private_data;
|
|
ssize_t sret;
|
|
ssize_t sret;
|
|
|
|
|
|
- /* return any leftover data */
|
|
|
|
- sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
|
|
|
- if (sret != -EBUSY)
|
|
|
|
- return sret;
|
|
|
|
-
|
|
|
|
- trace_seq_init(&iter->seq);
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* Avoid more than one consumer on a single file descriptor
|
|
* Avoid more than one consumer on a single file descriptor
|
|
* This is just a matter of traces coherency, the ring buffer itself
|
|
* This is just a matter of traces coherency, the ring buffer itself
|
|
* is protected.
|
|
* is protected.
|
|
*/
|
|
*/
|
|
mutex_lock(&iter->mutex);
|
|
mutex_lock(&iter->mutex);
|
|
|
|
+
|
|
|
|
+ /* return any leftover data */
|
|
|
|
+ sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
|
|
|
+ if (sret != -EBUSY)
|
|
|
|
+ goto out;
|
|
|
|
+
|
|
|
|
+ trace_seq_init(&iter->seq);
|
|
|
|
+
|
|
if (iter->trace->read) {
|
|
if (iter->trace->read) {
|
|
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
|
|
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
|
|
if (sret)
|
|
if (sret)
|
|
@@ -6163,9 +6164,6 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
|
return -EBUSY;
|
|
return -EBUSY;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- if (splice_grow_spd(pipe, &spd))
|
|
|
|
- return -ENOMEM;
|
|
|
|
-
|
|
|
|
if (*ppos & (PAGE_SIZE - 1))
|
|
if (*ppos & (PAGE_SIZE - 1))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
@@ -6175,6 +6173,9 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
|
len &= PAGE_MASK;
|
|
len &= PAGE_MASK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (splice_grow_spd(pipe, &spd))
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+
|
|
again:
|
|
again:
|
|
trace_access_lock(iter->cpu_file);
|
|
trace_access_lock(iter->cpu_file);
|
|
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
|
|
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
|
|
@@ -6232,19 +6233,21 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
|
/* did we read anything? */
|
|
/* did we read anything? */
|
|
if (!spd.nr_pages) {
|
|
if (!spd.nr_pages) {
|
|
if (ret)
|
|
if (ret)
|
|
- return ret;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
|
|
+ ret = -EAGAIN;
|
|
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
|
|
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
|
|
- return -EAGAIN;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
ret = wait_on_pipe(iter, true);
|
|
ret = wait_on_pipe(iter, true);
|
|
if (ret)
|
|
if (ret)
|
|
- return ret;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
goto again;
|
|
goto again;
|
|
}
|
|
}
|
|
|
|
|
|
ret = splice_to_pipe(pipe, &spd);
|
|
ret = splice_to_pipe(pipe, &spd);
|
|
|
|
+out:
|
|
splice_shrink_spd(&spd);
|
|
splice_shrink_spd(&spd);
|
|
|
|
|
|
return ret;
|
|
return ret;
|