aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2007-06-27 17:10:04 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-28 14:38:18 -0400
commita66e356c04ece4a96f44b942b68234c3de8ec3f5 (patch)
tree16e79721d953bccd37e0a6b506fb2ca686076d18
parent8d62fdebdaf9b866c7e236a8f5cfe90e6dba5773 (diff)
relayfs: fix overwrites
When I use relayfs with "overwrite" mode, read() still sets incorrect number of consumed bytes. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Acked-by: Tom Zanussi <zanussi@us.ibm.com> Acked-by: David Wilder <dwilder@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/relay.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index e61156ea4e25..95db8c79fe8f 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -812,7 +812,10 @@ static void relay_file_read_consume(struct rchan_buf *buf,
812 } 812 }
813 813
814 buf->bytes_consumed += bytes_consumed; 814 buf->bytes_consumed += bytes_consumed;
815 read_subbuf = read_pos / buf->chan->subbuf_size; 815 if (!read_pos)
816 read_subbuf = buf->subbufs_consumed % n_subbufs;
817 else
818 read_subbuf = read_pos / buf->chan->subbuf_size;
816 if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) { 819 if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) {
817 if ((read_subbuf == buf->subbufs_produced % n_subbufs) && 820 if ((read_subbuf == buf->subbufs_produced % n_subbufs) &&
818 (buf->offset == subbuf_size)) 821 (buf->offset == subbuf_size))
@@ -841,8 +844,9 @@ static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
841 } 844 }
842 845
843 if (unlikely(produced - consumed >= n_subbufs)) { 846 if (unlikely(produced - consumed >= n_subbufs)) {
844 consumed = (produced / n_subbufs) * n_subbufs; 847 consumed = produced - n_subbufs + 1;
845 buf->subbufs_consumed = consumed; 848 buf->subbufs_consumed = consumed;
849 buf->bytes_consumed = 0;
846 } 850 }
847 851
848 produced = (produced % n_subbufs) * subbuf_size + buf->offset; 852 produced = (produced % n_subbufs) * subbuf_size + buf->offset;