aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-29 12:44:10 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:17:35 -0400
commit143334ff446d634fcd3145919b5cddcc9148a74a (patch)
tree18c2a0f8be6ddff6abdb10f49b189c6048aabd2b /net
parentf5db90bcf2c69d099f9d828a8104796f41de6bc5 (diff)
libceph: don't add to crc unless data sent
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>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index eee7a878dbfb..cb8b571ce79a 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1467,8 +1467,6 @@ static int write_partial_message_data(struct ceph_connection *con)
1467 1467
1468 page = ceph_msg_data_next(&msg->data, &page_offset, &length, 1468 page = ceph_msg_data_next(&msg->data, &page_offset, &length,
1469 &last_piece); 1469 &last_piece);
1470 if (do_datacrc && cursor->need_crc)
1471 crc = ceph_crc32c_page(crc, page, page_offset, length);
1472 ret = ceph_tcp_sendpage(con->sock, page, page_offset, 1470 ret = ceph_tcp_sendpage(con->sock, page, page_offset,
1473 length, last_piece); 1471 length, last_piece);
1474 if (ret <= 0) { 1472 if (ret <= 0) {
@@ -1477,6 +1475,8 @@ static int write_partial_message_data(struct ceph_connection *con)
1477 1475
1478 return ret; 1476 return ret;
1479 } 1477 }
1478 if (do_datacrc && cursor->need_crc)
1479 crc = ceph_crc32c_page(crc, page, page_offset, length);
1480 out_msg_pos_next(con, page, length, (size_t) ret); 1480 out_msg_pos_next(con, page, length, (size_t) ret);
1481 } 1481 }
1482 1482