aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 32a3a2a72580..4578e99bbef1 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -907,21 +907,23 @@ static void out_msg_pos_next(struct ceph_connection *con, struct page *page,
907 907
908 con->out_msg_pos.data_pos += sent; 908 con->out_msg_pos.data_pos += sent;
909 con->out_msg_pos.page_pos += sent; 909 con->out_msg_pos.page_pos += sent;
910 if (sent == len) { 910 if (sent < len)
911 con->out_msg_pos.page_pos = 0; 911 return;
912 con->out_msg_pos.page++; 912
913 con->out_msg_pos.did_page_crc = false; 913 BUG_ON(sent != len);
914 if (in_trail) 914 con->out_msg_pos.page_pos = 0;
915 list_move_tail(&page->lru, 915 con->out_msg_pos.page++;
916 &msg->trail->head); 916 con->out_msg_pos.did_page_crc = false;
917 else if (msg->pagelist) 917 if (in_trail)
918 list_move_tail(&page->lru, 918 list_move_tail(&page->lru,
919 &msg->pagelist->head); 919 &msg->trail->head);
920 else if (msg->pagelist)
921 list_move_tail(&page->lru,
922 &msg->pagelist->head);
920#ifdef CONFIG_BLOCK 923#ifdef CONFIG_BLOCK
921 else if (msg->bio) 924 else if (msg->bio)
922 iter_bio_next(&msg->bio_iter, &msg->bio_seg); 925 iter_bio_next(&msg->bio_iter, &msg->bio_seg);
923#endif 926#endif
924 }
925} 927}
926 928
927/* 929/*
@@ -940,30 +942,31 @@ static int write_partial_msg_pages(struct ceph_connection *con)
940 int ret; 942 int ret;
941 int total_max_write; 943 int total_max_write;
942 bool in_trail = false; 944 bool in_trail = false;
943 size_t trail_len = (msg->trail ? msg->trail->length : 0); 945 const size_t trail_len = (msg->trail ? msg->trail->length : 0);
946 const size_t trail_off = data_len - trail_len;
944 947
945 dout("write_partial_msg_pages %p msg %p page %d/%d offset %d\n", 948 dout("write_partial_msg_pages %p msg %p page %d/%d offset %d\n",
946 con, msg, con->out_msg_pos.page, msg->nr_pages, 949 con, msg, con->out_msg_pos.page, msg->nr_pages,
947 con->out_msg_pos.page_pos); 950 con->out_msg_pos.page_pos);
948 951
952 /*
953 * Iterate through each page that contains data to be
954 * written, and send as much as possible for each.
955 *
956 * If we are calculating the data crc (the default), we will
957 * need to map the page. If we have no pages, they have
958 * been revoked, so use the zero page.
959 */
949 while (data_len > con->out_msg_pos.data_pos) { 960 while (data_len > con->out_msg_pos.data_pos) {
950 struct page *page = NULL; 961 struct page *page = NULL;
951 int max_write = PAGE_SIZE; 962 int max_write = PAGE_SIZE;
952 int bio_offset = 0; 963 int bio_offset = 0;
953 964
954 total_max_write = data_len - trail_len - 965 in_trail = in_trail || con->out_msg_pos.data_pos >= trail_off;
955 con->out_msg_pos.data_pos; 966 if (!in_trail)
956 967 total_max_write = trail_off - con->out_msg_pos.data_pos;
957 /*
958 * if we are calculating the data crc (the default), we need
959 * to map the page. if our pages[] has been revoked, use the
960 * zero page.
961 */
962
963 /* have we reached the trail part of the data? */
964 if (con->out_msg_pos.data_pos >= data_len - trail_len) {
965 in_trail = true;
966 968
969 if (in_trail) {
967 total_max_write = data_len - con->out_msg_pos.data_pos; 970 total_max_write = data_len - con->out_msg_pos.data_pos;
968 971
969 page = list_first_entry(&msg->trail->head, 972 page = list_first_entry(&msg->trail->head,
@@ -990,14 +993,13 @@ static int write_partial_msg_pages(struct ceph_connection *con)
990 993
991 if (do_datacrc && !con->out_msg_pos.did_page_crc) { 994 if (do_datacrc && !con->out_msg_pos.did_page_crc) {
992 void *base; 995 void *base;
993 u32 crc; 996 u32 crc = le32_to_cpu(msg->footer.data_crc);
994 u32 tmpcrc = le32_to_cpu(msg->footer.data_crc);
995 char *kaddr; 997 char *kaddr;
996 998
997 kaddr = kmap(page); 999 kaddr = kmap(page);
998 BUG_ON(kaddr == NULL); 1000 BUG_ON(kaddr == NULL);
999 base = kaddr + con->out_msg_pos.page_pos + bio_offset; 1001 base = kaddr + con->out_msg_pos.page_pos + bio_offset;
1000 crc = crc32c(tmpcrc, base, len); 1002 crc = crc32c(crc, base, len);
1001 msg->footer.data_crc = cpu_to_le32(crc); 1003 msg->footer.data_crc = cpu_to_le32(crc);
1002 con->out_msg_pos.did_page_crc = true; 1004 con->out_msg_pos.did_page_crc = true;
1003 } 1005 }
@@ -1702,9 +1704,6 @@ static int read_partial_message_bio(struct ceph_connection *con,
1702 void *p; 1704 void *p;
1703 int ret, left; 1705 int ret, left;
1704 1706
1705 if (IS_ERR(bv))
1706 return PTR_ERR(bv);
1707
1708 left = min((int)(data_len - con->in_msg_pos.data_pos), 1707 left = min((int)(data_len - con->in_msg_pos.data_pos),
1709 (int)(bv->bv_len - con->in_msg_pos.page_pos)); 1708 (int)(bv->bv_len - con->in_msg_pos.page_pos));
1710 1709