Skip to content

Commit

Permalink
libceph: fix inverted crc option logic
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Alex Elder committed Mar 22, 2012
1 parent 84495f4 commit 37675b0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 37675b0

Please sign in to comment.