aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-02-15 08:43:54 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:51 -0400
commitbca064d236a2e3162a07c758855221bcbe3c475b (patch)
tree49fca3de9007fa6cc5304bd8d7851d28cbe33110 /net
parentcffaba15cd95d4a16eb5a6aa5c22a79f67d555ab (diff)
libceph: use "do" in CRC-related Boolean variables
Change the name (and type) of a few CRC-related Boolean local variables so they contain the word "do", to distingish their purpose from variables used for holding an actual CRC value. Note that in the process of doing this I identified a fairly serious logic error in write_partial_msg_pages(): the value of "do_crc" assigned appears to be the opposite of what it should be. No attempt to fix this is made here; this change preserves the erroneous behavior. The problem I found is documented here: http://tracker.newdream.net/issues/2064 Signed-off-by: Alex Elder <elder@dreamhost.com> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 44d8c77cabdd..204e229e6628 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -595,7 +595,7 @@ static void prepare_write_message(struct ceph_connection *con)
595 else 595 else
596 con->out_msg_pos.page_pos = 0; 596 con->out_msg_pos.page_pos = 0;
597 con->out_msg_pos.data_pos = 0; 597 con->out_msg_pos.data_pos = 0;
598 con->out_msg_pos.did_page_crc = 0; 598 con->out_msg_pos.did_page_crc = false;
599 con->out_more = 1; /* data + footer will follow */ 599 con->out_more = 1; /* data + footer will follow */
600 } else { 600 } else {
601 /* no, queue up footer too and be done */ 601 /* no, queue up footer too and be done */
@@ -805,7 +805,7 @@ static int write_partial_msg_pages(struct ceph_connection *con)
805 struct ceph_msg *msg = con->out_msg; 805 struct ceph_msg *msg = con->out_msg;
806 unsigned data_len = le32_to_cpu(msg->hdr.data_len); 806 unsigned data_len = le32_to_cpu(msg->hdr.data_len);
807 size_t len; 807 size_t len;
808 int crc = con->msgr->nocrc; 808 bool do_crc = con->msgr->nocrc;
809 int ret; 809 int ret;
810 int total_max_write; 810 int total_max_write;
811 int in_trail = 0; 811 int in_trail = 0;
@@ -843,17 +843,17 @@ static int write_partial_msg_pages(struct ceph_connection *con)
843 843
844 page = list_first_entry(&msg->trail->head, 844 page = list_first_entry(&msg->trail->head,
845 struct page, lru); 845 struct page, lru);
846 if (crc) 846 if (do_crc)
847 kaddr = kmap(page); 847 kaddr = kmap(page);
848 max_write = PAGE_SIZE; 848 max_write = PAGE_SIZE;
849 } else if (msg->pages) { 849 } else if (msg->pages) {
850 page = msg->pages[con->out_msg_pos.page]; 850 page = msg->pages[con->out_msg_pos.page];
851 if (crc) 851 if (do_crc)
852 kaddr = kmap(page); 852 kaddr = kmap(page);
853 } else if (msg->pagelist) { 853 } else if (msg->pagelist) {
854 page = list_first_entry(&msg->pagelist->head, 854 page = list_first_entry(&msg->pagelist->head,
855 struct page, lru); 855 struct page, lru);
856 if (crc) 856 if (do_crc)
857 kaddr = kmap(page); 857 kaddr = kmap(page);
858#ifdef CONFIG_BLOCK 858#ifdef CONFIG_BLOCK
859 } else if (msg->bio) { 859 } else if (msg->bio) {
@@ -862,26 +862,26 @@ static int write_partial_msg_pages(struct ceph_connection *con)
862 bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg); 862 bv = bio_iovec_idx(msg->bio_iter, msg->bio_seg);
863 page = bv->bv_page; 863 page = bv->bv_page;
864 page_shift = bv->bv_offset; 864 page_shift = bv->bv_offset;
865 if (crc) 865 if (do_crc)
866 kaddr = kmap(page) + page_shift; 866 kaddr = kmap(page) + page_shift;
867 max_write = bv->bv_len; 867 max_write = bv->bv_len;
868#endif 868#endif
869 } else { 869 } else {
870 page = zero_page; 870 page = zero_page;
871 if (crc) 871 if (do_crc)
872 kaddr = zero_page_address; 872 kaddr = zero_page_address;
873 } 873 }
874 len = min_t(int, max_write - con->out_msg_pos.page_pos, 874 len = min_t(int, max_write - con->out_msg_pos.page_pos,
875 total_max_write); 875 total_max_write);
876 876
877 if (crc && !con->out_msg_pos.did_page_crc) { 877 if (do_crc && !con->out_msg_pos.did_page_crc) {
878 void *base = kaddr + con->out_msg_pos.page_pos; 878 void *base = kaddr + con->out_msg_pos.page_pos;
879 u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc); 879 u32 tmpcrc = le32_to_cpu(con->out_msg->footer.data_crc);
880 880
881 BUG_ON(kaddr == NULL); 881 BUG_ON(kaddr == NULL);
882 con->out_msg->footer.data_crc = 882 con->out_msg->footer.data_crc =
883 cpu_to_le32(crc32c(tmpcrc, base, len)); 883 cpu_to_le32(crc32c(tmpcrc, base, len));
884 con->out_msg_pos.did_page_crc = 1; 884 con->out_msg_pos.did_page_crc = true;
885 } 885 }
886 ret = kernel_sendpage(con->sock, page, 886 ret = kernel_sendpage(con->sock, page,
887 con->out_msg_pos.page_pos + page_shift, 887 con->out_msg_pos.page_pos + page_shift,
@@ -889,7 +889,7 @@ static int write_partial_msg_pages(struct ceph_connection *con)
889 MSG_DONTWAIT | MSG_NOSIGNAL | 889 MSG_DONTWAIT | MSG_NOSIGNAL |
890 MSG_MORE); 890 MSG_MORE);
891 891
892 if (crc && 892 if (do_crc &&
893 (msg->pages || msg->pagelist || msg->bio || in_trail)) 893 (msg->pages || msg->pagelist || msg->bio || in_trail))
894 kunmap(page); 894 kunmap(page);
895 895
@@ -903,7 +903,7 @@ static int write_partial_msg_pages(struct ceph_connection *con)
903 if (ret == len) { 903 if (ret == len) {
904 con->out_msg_pos.page_pos = 0; 904 con->out_msg_pos.page_pos = 0;
905 con->out_msg_pos.page++; 905 con->out_msg_pos.page++;
906 con->out_msg_pos.did_page_crc = 0; 906 con->out_msg_pos.did_page_crc = false;
907 if (in_trail) 907 if (in_trail)
908 list_move_tail(&page->lru, 908 list_move_tail(&page->lru,
909 &msg->trail->head); 909 &msg->trail->head);
@@ -920,7 +920,7 @@ static int write_partial_msg_pages(struct ceph_connection *con)
920 dout("write_partial_msg_pages %p msg %p done\n", con, msg); 920 dout("write_partial_msg_pages %p msg %p done\n", con, msg);
921 921
922 /* prepare and queue up footer, too */ 922 /* prepare and queue up footer, too */
923 if (!crc) 923 if (!do_crc)
924 con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC; 924 con->out_msg->footer.flags |= CEPH_MSG_FOOTER_NOCRC;
925 ceph_con_out_kvec_reset(con); 925 ceph_con_out_kvec_reset(con);
926 prepare_write_message_footer(con); 926 prepare_write_message_footer(con);
@@ -1557,7 +1557,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
1557 1557
1558static int read_partial_message_pages(struct ceph_connection *con, 1558static int read_partial_message_pages(struct ceph_connection *con,
1559 struct page **pages, 1559 struct page **pages,
1560 unsigned data_len, int datacrc) 1560 unsigned data_len, bool do_datacrc)
1561{ 1561{
1562 void *p; 1562 void *p;
1563 int ret; 1563 int ret;
@@ -1570,7 +1570,7 @@ static int read_partial_message_pages(struct ceph_connection *con,
1570 p = kmap(pages[con->in_msg_pos.page]); 1570 p = kmap(pages[con->in_msg_pos.page]);
1571 ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos, 1571 ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos,
1572 left); 1572 left);
1573 if (ret > 0 && datacrc) 1573 if (ret > 0 && do_datacrc)
1574 con->in_data_crc = 1574 con->in_data_crc =
1575 crc32c(con->in_data_crc, 1575 crc32c(con->in_data_crc,
1576 p + con->in_msg_pos.page_pos, ret); 1576 p + con->in_msg_pos.page_pos, ret);
@@ -1590,7 +1590,7 @@ static int read_partial_message_pages(struct ceph_connection *con,
1590#ifdef CONFIG_BLOCK 1590#ifdef CONFIG_BLOCK
1591static int read_partial_message_bio(struct ceph_connection *con, 1591static int read_partial_message_bio(struct ceph_connection *con,
1592 struct bio **bio_iter, int *bio_seg, 1592 struct bio **bio_iter, int *bio_seg,
1593 unsigned data_len, int datacrc) 1593 unsigned data_len, bool do_datacrc)
1594{ 1594{
1595 struct bio_vec *bv = bio_iovec_idx(*bio_iter, *bio_seg); 1595 struct bio_vec *bv = bio_iovec_idx(*bio_iter, *bio_seg);
1596 void *p; 1596 void *p;
@@ -1606,7 +1606,7 @@ static int read_partial_message_bio(struct ceph_connection *con,
1606 1606
1607 ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos, 1607 ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos,
1608 left); 1608 left);
1609 if (ret > 0 && datacrc) 1609 if (ret > 0 && do_datacrc)
1610 con->in_data_crc = 1610 con->in_data_crc =
1611 crc32c(con->in_data_crc, 1611 crc32c(con->in_data_crc,
1612 p + con->in_msg_pos.page_pos, ret); 1612 p + con->in_msg_pos.page_pos, ret);
@@ -1633,7 +1633,7 @@ static int read_partial_message(struct ceph_connection *con)
1633 int ret; 1633 int ret;
1634 int to, left; 1634 int to, left;
1635 unsigned front_len, middle_len, data_len; 1635 unsigned front_len, middle_len, data_len;
1636 int datacrc = con->msgr->nocrc; 1636 bool do_datacrc = con->msgr->nocrc;
1637 int skip; 1637 int skip;
1638 u64 seq; 1638 u64 seq;
1639 1639
@@ -1744,7 +1744,7 @@ static int read_partial_message(struct ceph_connection *con)
1744 while (con->in_msg_pos.data_pos < data_len) { 1744 while (con->in_msg_pos.data_pos < data_len) {
1745 if (m->pages) { 1745 if (m->pages) {
1746 ret = read_partial_message_pages(con, m->pages, 1746 ret = read_partial_message_pages(con, m->pages,
1747 data_len, datacrc); 1747 data_len, do_datacrc);
1748 if (ret <= 0) 1748 if (ret <= 0)
1749 return ret; 1749 return ret;
1750#ifdef CONFIG_BLOCK 1750#ifdef CONFIG_BLOCK
@@ -1752,7 +1752,7 @@ static int read_partial_message(struct ceph_connection *con)
1752 1752
1753 ret = read_partial_message_bio(con, 1753 ret = read_partial_message_bio(con,
1754 &m->bio_iter, &m->bio_seg, 1754 &m->bio_iter, &m->bio_seg,
1755 data_len, datacrc); 1755 data_len, do_datacrc);
1756 if (ret <= 0) 1756 if (ret <= 0)
1757 return ret; 1757 return ret;
1758#endif 1758#endif
@@ -1787,7 +1787,7 @@ static int read_partial_message(struct ceph_connection *con)
1787 m, con->in_middle_crc, m->footer.middle_crc); 1787 m, con->in_middle_crc, m->footer.middle_crc);
1788 return -EBADMSG; 1788 return -EBADMSG;
1789 } 1789 }
1790 if (datacrc && 1790 if (do_datacrc &&
1791 (m->footer.flags & CEPH_MSG_FOOTER_NOCRC) == 0 && 1791 (m->footer.flags & CEPH_MSG_FOOTER_NOCRC) == 0 &&
1792 con->in_data_crc != le32_to_cpu(m->footer.data_crc)) { 1792 con->in_data_crc != le32_to_cpu(m->footer.data_crc)) {
1793 pr_err("read_partial_message %p data crc %u != exp. %u\n", m, 1793 pr_err("read_partial_message %p data crc %u != exp. %u\n", m,