This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH] relay-file-read-start-pos-fix.patch
- From: Masami Hiramatsu <masami dot hiramatsu dot pt at hitachi dot com>
- To: David Wilder <dwilder at us dot ibm dot com>, Tom Zanussi <zanussi at us dot ibm dot com>
- Cc: linux-kernel at vger dot kernel dot org, systemtap at sources dot redhat dot com, Yumiko Sugita <yumiko dot sugita dot yf at hitachi dot com>, Satoshi Oshima <soshima at redhat dot com>, Hideo Aoki <haoki at redhat dot com>
- Date: Tue, 19 Jun 2007 12:43:37 +0900
- Subject: Re: [PATCH] relay-file-read-start-pos-fix.patch
- Organization: Systems Development Lab., Hitachi, Ltd., Japan
- References: <4676109F.8020202@us.ibm.com>
Hi David and Tom,
David Wilder wrote:
> This patch fixes a bug in the relay read interface causing the number
> of consumed bytes to be set incorrectly.
Thank you. Your patch fixes one of my concerns.
However there is another bug I found.
When I use relayfs with "overwrite" mode, read() still set incorrect
number of consumed bytes.
I tried to fix that. Please review it.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
kernel/relay.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: linux-2.6.22-rc4-mm2/kernel/relay.c
===================================================================
--- linux-2.6.22-rc4-mm2.orig/kernel/relay.c 2007-06-13 20:22:02.000000000 +0900
+++ linux-2.6.22-rc4-mm2/kernel/relay.c 2007-06-18 23:00:54.000000000 +0900
@@ -812,7 +812,10 @@
}
buf->bytes_consumed += bytes_consumed;
- read_subbuf = read_pos / buf->chan->subbuf_size;
+ if (!read_pos)
+ read_subbuf = buf->subbufs_consumed;
+ 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))
@@ -841,8 +844,9 @@
}
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;