Skip to content

Commit

Permalink
relayfs: fix overwrites
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Masami Hiramatsu authored and Linus Torvalds committed Jun 28, 2007
1 parent 8d62fde commit a66e356
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kernel/relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,10 @@ static void relay_file_read_consume(struct rchan_buf *buf,
}

buf->bytes_consumed += bytes_consumed;
read_subbuf = read_pos / buf->chan->subbuf_size;
if (!read_pos)
read_subbuf = buf->subbufs_consumed % n_subbufs;
else
read_subbuf = read_pos / buf->chan->subbuf_size;
if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) {
if ((read_subbuf == buf->subbufs_produced % n_subbufs) &&
(buf->offset == subbuf_size))
Expand Down Expand Up @@ -841,8 +844,9 @@ static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
}

if (unlikely(produced - consumed >= n_subbufs)) {
consumed = (produced / n_subbufs) * n_subbufs;
consumed = produced - n_subbufs + 1;
buf->subbufs_consumed = consumed;
buf->bytes_consumed = 0;
}

produced = (produced % n_subbufs) * subbuf_size + buf->offset;
Expand Down

0 comments on commit a66e356

Please sign in to comment.