Skip to content

Commit

Permalink
libceph: don't add to crc unless data sent
Browse files Browse the repository at this point in the history
In write_partial_message_data() we aggregate the crc for the data
portion of the message as each new piece of the data item is
encountered.  Because it was computed *before* sending the data, if
an attempt to send a new piece resulted in 0 bytes being sent, the
crc crc across that piece would erroneously get computed again and
added to the aggregate result.  This would occasionally happen in
the evnet of a connection failure.

The crc value isn't really needed until the complete value is known
after sending all data, so there's no need to compute it before
sending.

So don't calculate the crc for a piece until *after* we know at
least one byte of it has been sent.  That will avoid this problem.

This resolves:
    http://tracker.ceph.com/issues/4450

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent f5db90b commit 143334f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,8 +1467,6 @@ static int write_partial_message_data(struct ceph_connection *con)

page = ceph_msg_data_next(&msg->data, &page_offset, &length,
&last_piece);
if (do_datacrc && cursor->need_crc)
crc = ceph_crc32c_page(crc, page, page_offset, length);
ret = ceph_tcp_sendpage(con->sock, page, page_offset,
length, last_piece);
if (ret <= 0) {
Expand All @@ -1477,6 +1475,8 @@ static int write_partial_message_data(struct ceph_connection *con)

return ret;
}
if (do_datacrc && cursor->need_crc)
crc = ceph_crc32c_page(crc, page, page_offset, length);
out_msg_pos_next(con, page, length, (size_t) ret);
}

Expand Down

0 comments on commit 143334f

Please sign in to comment.