diff options
author | Alex Elder <elder@dreamhost.com> | 2012-03-07 12:40:08 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:51 -0400 |
commit | 37675b0f42a8f7699c3602350d1c3b2a1698a3d3 (patch) | |
tree | 17717f3bcd3eea065d0d08e49699af6dbec7c0ff /net | |
parent | 84495f496170a73ed79667b7fbf91947b7f47c87 (diff) |
libceph: fix inverted crc option logic
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>
Reviewed-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r-- | 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 1a22975945da..589b7689d31b 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) | |||
812 | struct ceph_msg *msg = con->out_msg; | 812 | struct ceph_msg *msg = con->out_msg; |
813 | unsigned data_len = le32_to_cpu(msg->hdr.data_len); | 813 | unsigned data_len = le32_to_cpu(msg->hdr.data_len); |
814 | size_t len; | 814 | size_t len; |
815 | bool do_crc = con->msgr->nocrc; | 815 | bool do_datacrc = !con->msgr->nocrc; |
816 | int ret; | 816 | int ret; |
817 | int total_max_write; | 817 | int total_max_write; |
818 | int in_trail = 0; | 818 | int in_trail = 0; |
@@ -850,17 +850,17 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
850 | 850 | ||
851 | page = list_first_entry(&msg->trail->head, | 851 | page = list_first_entry(&msg->trail->head, |
852 | struct page, lru); | 852 | struct page, lru); |
853 | if (do_crc) | 853 | if (do_datacrc) |
854 | kaddr = kmap(page); | 854 | kaddr = kmap(page); |
855 | max_write = PAGE_SIZE; | 855 | max_write = PAGE_SIZE; |
856 | } else if (msg->pages) { | 856 | } else if (msg->pages) { |
857 | page = msg->pages[con->out_msg_pos.page]; | 857 | page = msg->pages[con->out_msg_pos.page]; |
858 | if (do_crc) | 858 | if (do_datacrc) |
859 | kaddr = kmap(page); | 859 | kaddr = kmap(page); |
860 | } else if (msg->pagelist) { | 860 | } else if (msg->pagelist) { |
861 | page = list_first_entry(&msg->pagelist->head, | 861 | page = list_first_entry(&msg->pagelist->head, |
862 | struct page, lru); | 862 | struct page, lru); |
863 | if (do_crc) | 863 | if (do_datacrc) |
864 | kaddr = kmap(page); | 864 | kaddr = kmap(page); |
865 | #ifdef CONFIG_BLOCK | 865 | #ifdef CONFIG_BLOCK |
866 | } else if (msg->bio) { | 866 | } else if (msg->bio) { |
@@ -869,19 +869,19 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
869 | bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); | 869 | bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); |
870 | page = bv->bv_page; | 870 | page = bv->bv_page; |
871 | page_shift = bv->bv_offset; | 871 | page_shift = bv->bv_offset; |
872 | if (do_crc) | 872 | if (do_datacrc) |
873 | kaddr = kmap(page) + page_shift; | 873 | kaddr = kmap(page) + page_shift; |
874 | max_write = bv->bv_len; | 874 | max_write = bv->bv_len; |
875 | #endif | 875 | #endif |
876 | } else { | 876 | } else { |
877 | page = zero_page; | 877 | page = zero_page; |
878 | if (do_crc) | 878 | if (do_datacrc) |
879 | kaddr = zero_page_address; | 879 | kaddr = zero_page_address; |
880 | } | 880 | } |
881 | len = min_t(int, max_write - con->out_msg_pos.page_pos, | 881 | len = min_t(int, max_write - con->out_msg_pos.page_pos, |
882 | total_max_write); | 882 | total_max_write); |
883 | 883 | ||
884 | if (do_crc && !con->out_msg_pos.did_page_crc) { | 884 | if (do_datacrc && !con->out_msg_pos.did_page_crc) { |
885 | u32 crc; | 885 | u32 crc; |
886 | void *base = kaddr + con->out_msg_pos.page_pos; | 886 | void *base = kaddr + con->out_msg_pos.page_pos; |
887 | u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); | 887 | 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) | |||
897 | MSG_DONTWAIT | MSG_NOSIGNAL | | 897 | MSG_DONTWAIT | MSG_NOSIGNAL | |
898 | MSG_MORE); | 898 | MSG_MORE); |
899 | 899 | ||
900 | if (do_crc && kaddr != zero_page_address) | 900 | if (do_datacrc && kaddr != zero_page_address) |
901 | kunmap(page); | 901 | kunmap(page); |
902 | 902 | ||
903 | if (ret == -EAGAIN) | 903 | if (ret == -EAGAIN) |
@@ -927,7 +927,7 @@ static int write_partial_msg_pages(struct ceph_connection *con) | |||
927 | dout("write_partial_msg_pages %p msg %p done\n", con, msg); | 927 | dout("write_partial_msg_pages %p msg %p done\n", con, msg); |
928 | 928 | ||
929 | /* prepare and queue up footer, too */ | 929 | /* prepare and queue up footer, too */ |
930 | if (!do_crc) | 930 | if (!do_datacrc) |
931 | con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC; | 931 | con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC; |
932 | ceph_con_out_kvec_reset(con); | 932 | ceph_con_out_kvec_reset(con); |
933 | prepare_write_message_footer(con); | 933 | prepare_write_message_footer(con); |
@@ -1639,7 +1639,7 @@ static int read_partial_message(struct ceph_connection *con) | |||
1639 | int ret; | 1639 | int ret; |
1640 | int to, left; | 1640 | int to, left; |
1641 | unsigned front_len, middle_len, data_len; | 1641 | unsigned front_len, middle_len, data_len; |
1642 | bool do_datacrc = con->msgr->nocrc; | 1642 | bool do_datacrc = !con->msgr->nocrc; |
1643 | int skip; | 1643 | int skip; |
1644 | u64 seq; | 1644 | u64 seq; |
1645 | u32 crc; | 1645 | u32 crc; |