All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 4/7] tabled: Fix buffer pointer confusion in object.c
@ 2009-11-14  6:33 Pete Zaitcev
  2009-11-14  8:38 ` Jeff Garzik
  0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-11-14  6:33 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Project Hail List

This bug leads to object's data corrupt whenever the write is partial.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

---
 server/object.c |    5 ++++-
 server/tabled.h |    1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/object.c b/server/object.c
index b329c0d..5c0f97f 100644
--- a/server/object.c
+++ b/server/object.c
@@ -547,7 +547,7 @@ static void object_put_event(struct open_chunk *ochunk)
 		return;
 	}
 
-	bytes = stor_put_buf(ochunk, cli->out_buf, cli->out_bcnt);
+	bytes = stor_put_buf(ochunk, ochunk->wbuf, ochunk->wcnt);
 	if (bytes < 0) {
 		if (debugging)
 			applog(LOG_DEBUG, "write(2) error: %s",
@@ -569,6 +569,7 @@ static void object_put_event(struct open_chunk *ochunk)
 		free(ochunk);
 		return;
 	}
+	ochunk->wbuf += bytes;
 	ochunk->wcnt -= bytes;
 
 	if (ochunk->wcnt == 0) {
@@ -592,6 +593,7 @@ static int object_put_buf(struct client *cli, struct open_chunk *ochunk,
 {
 	ssize_t bytes;
 
+	ochunk->wbuf = buf;
 	ochunk->wcnt = len;
 
 	bytes = stor_put_buf(ochunk, buf, len);
@@ -603,6 +605,7 @@ static int object_put_buf(struct client *cli, struct open_chunk *ochunk,
 		return -EIO;
 	}
 	ochunk->wcnt -= bytes;
+	ochunk->wbuf += bytes;
 
 	if (ochunk->wcnt != 0)
 		cli->out_nput++;
diff --git a/server/tabled.h b/server/tabled.h
index e4dbbd5..fd6142e 100644
--- a/server/tabled.h
+++ b/server/tabled.h
@@ -123,6 +123,7 @@ struct open_chunk {
 	int			wfd;
 	bool			w_armed;
 	struct event		wevt;
+	void			*wbuf;
 	size_t			wcnt;	/* in current buffer */
 
 	uint64_t		roff;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-14  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-14  6:33 [Patch 4/7] tabled: Fix buffer pointer confusion in object.c Pete Zaitcev
2009-11-14  8:38 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.