Skip to contentSkip to conversation

Relay reset consumed

PATCH In review David Wilder 1 participant 1 message Sep 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Relay reset consumed

This patch allows relay channels to be reset i.e. unconsumed. Basically allows a 'rewind' function for flight-recorder tracing.

---
 Documentation/filesystems/relay.txt |   11 ++++++
 include/linux/relay.h               |    1 +
 kernel/relay.c                      |   58 ++++++++++++++++++++++++++++++++---
 3 files changed, 65 insertions(+), 5 deletions(-)
Documentation/filesystems/relay.txt +11 -0
index 18d23f9..d31113a 100644
@@ -161,6 +161,7 @@ TBD(curr. line MT:/API/)
     relay_close(chan)
     relay_flush(chan)
     relay_reset(chan)
+    relay_reset_consumed(chan)
 
   channel management typically called on instigation of userspace:
 
@@ -452,6 +453,16 @@ state without reallocating channel buffer memory or destroying
 existing mappings.  It should however only be called when it's safe to
 do so, i.e. when the channel isn't currently being written to.
 
+The read(2) implementation always 'consumes' the bytes read,
+i.e. those bytes won't be available again to subsequent reads.
+Certain applications may nonetheless wish to allow the 'consumed' data
+to be re-read; relay_reset_consumed() is provided for that purpose -
+it resets the internal consumed counters for all buffers in the
+channel.  For example, if a first set of reads 'drains' the channel,
+and then relay_reset_consumed() is called, a second set of reads will
+get the exact same data (assuming no new data was written between the
+first set of reads and the second).
+
 Finally, there are a couple of utility callbacks that can be used for
 different purposes.  buf_mapped() is called whenever a channel buffer
 is mmapped from user space and buf_unmapped() is called when it's
include/linux/relay.h +1 -0
index 6cd8c44..aca45fa 100644
@@ -175,6 +175,7 @@ extern void relay_subbufs_consumed(struct rchan *chan,
 				   unsigned int cpu,
 				   size_t consumed);
 extern void relay_reset(struct rchan *chan);
+extern void relay_reset_consumed(struct rchan *chan);
 extern int relay_buf_full(struct rchan_buf *buf);
 
 extern size_t relay_switch_subbuf(struct rchan_buf *buf,
kernel/relay.c +53 -5

70 lines not on this page · raw message