All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 4/7] tabled: Fix buffer pointer confusion in object.c
Date: Fri, 13 Nov 2009 23:33:02 -0700	[thread overview]
Message-ID: <20091113233302.40d4708c@redhat.com> (raw)

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;

             reply	other threads:[~2009-11-14  6:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-14  6:33 Pete Zaitcev [this message]
2009-11-14  8:38 ` [Patch 4/7] tabled: Fix buffer pointer confusion in object.c Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091113233302.40d4708c@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.