diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 204e229e6628..7ec6a228b667 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -521,6 +521,7 @@ static void prepare_write_message_footer(struct ceph_connection *con) | |||
521 | static void prepare_write_message(struct ceph_connection *con) | 521 | static void prepare_write_message(struct ceph_connection *con) |
522 | { | 522 | { |
523 | struct ceph_msg *m; | 523 | struct ceph_msg *m; |
524 | u32 crc; | ||
524 | 525 | ||
525 | ceph_con_out_kvec_reset(con); | 526 | ceph_con_out_kvec_reset(con); |
526 | con->out_kvec_is_msg = true; | 527 | con->out_kvec_is_msg = true; |
@@ -569,17 +570,17 @@ static void prepare_write_message(struct ceph_connection *con) | |||
569 | m->middle->vec.iov_base); | 570 | m->middle->vec.iov_base); |
570 | 571 | ||
571 | /* fill in crc (except data pages), footer */ | 572 | /* fill in crc (except data pages), footer */ |
572 | con->out_msg->hdr.crc = | 573 | crc = crc32c(0, &m->hdr, offsetof(struct ceph_msg_header, crc)); |
573 | cpu_to_le32(crc32c(0, &m->hdr, | 574 | con->out_msg->hdr.crc = cpu_to_le32(crc); |
574 | sizeof(m->hdr) - sizeof(m->hdr.crc))); | ||
575 | con->out_msg->footer.flags = CEPH_MSG_FOOTER_COMPLETE; | 575 | con->out_msg->footer.flags = CEPH_MSG_FOOTER_COMPLETE; |
576 | con->out_msg->footer.front_crc = | 576 | |
577 | cpu_to_le32(crc32c(0, m->front.iov_base, m->front.iov_len)); | 577 | crc = crc32c(0, m->front.iov_base, m->front.iov_len); |
578 | if (m->middle) | 578 | con->out_msg->footer.front_crc = cpu_to_le32(crc); |
579 | con->out_msg->footer.middle_crc = | 579 | if (m->middle) { |
580 | cpu_to_le32(crc32c(0, m->middle->vec.iov_base, | 580 | crc = crc32c(0, m->middle->vec.iov_base, |
581 | m->middle->vec.iov_len)); | 581 | m->middle->vec.iov_len); |
582 | else | 582 | con->out_msg->footer.middle_crc = cpu_to_le32(crc); |
583 | } else | ||
583 | con->out_msg->footer.middle_crc = 0; | 584 | con->out_msg->footer.middle_crc = 0; |
584 | con->out_msg->footer.data_crc = 0; | 585 | con->out_msg->footer.data_crc = 0; |
585 | dout("prepare_write_message front_crc %u data_crc %u\n", | 586 | dout("prepare_write_message front_crc %u data_crc %u\n", |
@@ -875,12 +876,13 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
875 | total_max_write); | 876 | total_max_write); |
876 | 877 | ||
877 | if (do_crc && !con->out_msg_pos.did_page_crc) { | 878 | if (do_crc && !con->out_msg_pos.did_page_crc) { |
879 | u32 crc; | ||
878 | void *base = kaddr + con->out_msg_pos.page_pos; | 880 | void *base = kaddr + con->out_msg_pos.page_pos; |
879 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); | 881 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); |
880 | 882 | ||
881 | BUG_ON(kaddr == NULL); | 883 | BUG_ON(kaddr == NULL); |
882 | con->out_msg->footer.data_crc = | 884 | crc = crc32c(tmpcrc, base, len); |
883 | cpu_to_le32(crc32c(tmpcrc, base, len)); | 885 | con->out_msg->footer.data_crc = cpu_to_le32(crc); |
884 | con->out_msg_pos.did_page_crc = true; | 886 | con->out_msg_pos.did_page_crc = true; |
885 | } | 887 | } |
886 | ret = kernel_sendpage(con->sock, page, | 888 | ret = kernel_sendpage(con->sock, page, |
@@ -1650,8 +1652,9 @@ static int read_partial_message(struct ceph_connection *con) | |||
1650 | con->in_base_pos += ret; | 1652 | con->in_base_pos += ret; |
1651 | if (con->in_base_pos == sizeof(con->in_hdr)) { | 1653 | if (con->in_base_pos == sizeof(con->in_hdr)) { |
1652 | u32 crc = crc32c(0, &con->in_hdr, | 1654 | u32 crc = crc32c(0, &con->in_hdr, |
1653 | sizeof(con->in_hdr) - sizeof(con->in_hdr.crc)); | 1655 | offsetof(struct ceph_msg_header, crc)); |
1654 | if (crc != le32_to_cpu(con->in_hdr.crc)) { | 1656 | |
1657 | if (cpu_to_le32(crc) != con->in_hdr.crc) { | ||
1655 | pr_err("read_partial_message bad hdr " | 1658 | pr_err("read_partial_message bad hdr " |
1656 | " crc %u != expected %u\n", | 1659 | " crc %u != expected %u\n", |
1657 | crc, con->in_hdr.crc); | 1660 | crc, con->in_hdr.crc); |