Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Masami Hiramatsu and committed by
Linus Torvalds
a66e356c 8d62fdeb

+6 -2
+6 -2
kernel/relay.c
··· 812 812 } 813 813 814 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 819 if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) { 817 820 if ((read_subbuf == buf->subbufs_produced % n_subbufs) && 818 821 (buf->offset == subbuf_size)) ··· 844 841 } 845 842 846 843 if (unlikely(produced - consumed >= n_subbufs)) { 847 - consumed = (produced / n_subbufs) * n_subbufs; 844 + consumed = produced - n_subbufs + 1; 848 845 buf->subbufs_consumed = consumed; 846 + buf->bytes_consumed = 0; 849 847 } 850 848 851 849 produced = (produced % n_subbufs) * subbuf_size + buf->offset;