All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libceph: fix inverted crc option logic
@ 2012-03-12 22:24 Alex Elder
  2012-03-13  5:39 ` Sage Weil
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2012-03-12 22:24 UTC (permalink / raw)
  To: ceph-devel

CRC's are computed for all messages between ceph entities.  The CRC
computation for the data portion of message can optionally be
disabled using the "nocrc" (common) ceph option.  The default is
for CRC computation for the data portion to be enabled.

Unfortunately, the code that implements this feature interprets the
feature flag wrong, meaning that by default the CRC's have *not*
been computed (or checked) for the data portion of messages unless
the "nocrc" option was supplied.

Fix this, in write_partial_msg_pages() and read_partial_message().
Also change the flag variable in write_partial_msg_pages() to be
"no_datacrc" to match the usage elsewhere in the file.

This fixes http://tracker.newdream.net/issues/2064

Signed-off-by: Alex Elder <elder@dreamhost.com>
---
  net/ceph/messenger.c |   20 ++++++++++----------
  1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 1a22975..589b768 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -812,7 +812,7 @@ static int write_partial_msg_pages(struct 
ceph_connection *con)
  	struct ceph_msg *msg = con->out_msg;
  	unsigned data_len = le32_to_cpu(msg->hdr.data_len);
  	size_t len;
-	bool do_crc = con->msgr->nocrc;
+	bool do_datacrc = !con->msgr->nocrc;
  	int ret;
  	int total_max_write;
  	int in_trail = 0;
@@ -850,17 +850,17 @@ static int write_partial_msg_pages(struct 
ceph_connection *con)

  			page = list_first_entry(&msg->trail->head,
  						struct page, lru);
-			if (do_crc)
+			if (do_datacrc)
  				kaddr = kmap(page);
  			max_write = PAGE_SIZE;
  		} else if (msg->pages) {
  			page = msg->pages[con->out_msg_pos.page];
-			if (do_crc)
+			if (do_datacrc)
  				kaddr = kmap(page);
  		} else if (msg->pagelist) {
  			page = list_first_entry(&msg->pagelist->head,
  						struct page, lru);
-			if (do_crc)
+			if (do_datacrc)
  				kaddr = kmap(page);
  #ifdef CONFIG_BLOCK
  		} else if (msg->bio) {
@@ -869,19 +869,19 @@ static int write_partial_msg_pages(struct 
ceph_connection *con)
  			bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
  			page = bv->bv_page;
  			page_shift = bv->bv_offset;
-			if (do_crc)
+			if (do_datacrc)
  				kaddr = kmap(page) + page_shift;
  			max_write = bv->bv_len;
  #endif
  		} else {
  			page = zero_page;
-			if (do_crc)
+			if (do_datacrc)
  				kaddr = zero_page_address;
  		}
  		len = min_t(int, max_write - con->out_msg_pos.page_pos,
  			    total_max_write);

-		if (do_crc && !con->out_msg_pos.did_page_crc) {
+		if (do_datacrc && !con->out_msg_pos.did_page_crc) {
  			u32 crc;
  			void *base = kaddr + con->out_msg_pos.page_pos;
  			u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc);
@@ -897,7 +897,7 @@ static int write_partial_msg_pages(struct 
ceph_connection *con)
  				      MSG_DONTWAIT | MSG_NOSIGNAL |
  				      MSG_MORE);

-		if (do_crc && kaddr != zero_page_address)
+		if (do_datacrc && kaddr != zero_page_address)
  			kunmap(page);

  		if (ret == -EAGAIN)
@@ -927,7 +927,7 @@ static int write_partial_msg_pages(struct 
ceph_connection *con)
  	dout("write_partial_msg_pages %p msg %p done\n", con, msg);

  	/* prepare and queue up footer, too */
-	if (!do_crc)
+	if (!do_datacrc)
  		con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC;
  	ceph_con_out_kvec_reset(con);
  	prepare_write_message_footer(con);
@@ -1639,7 +1639,7 @@ static int read_partial_message(struct 
ceph_connection *con)
  	int ret;
  	int to, left;
  	unsigned front_len, middle_len, data_len;
-	bool do_datacrc = con->msgr->nocrc;
+	bool do_datacrc = !con->msgr->nocrc;
  	int skip;
  	u64 seq;
  	u32 crc;
-- 
1.7.5.4


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

end of thread, other threads:[~2012-03-13  5:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-12 22:24 [PATCH] libceph: fix inverted crc option logic Alex Elder
2012-03-13  5:39 ` Sage Weil

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.