aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-08 14:35:36 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:17:06 -0400
commit8a166d05369f6a0369bb194a795e6e3928ac6e34 (patch)
tree3ab95714e5d1533d10fbc5558704a59b85022088 /net
parent9d2a06c2750177dca5f8d0e89884c1d409d64bbc (diff)
libceph: more cleanup of write_partial_msg_pages()
Basically all cases in write_partial_msg_pages() use the cursor, and as a result we can simplify that function quite a bit. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index ff58d3182754..997daccf973a 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1476,7 +1476,6 @@ static int write_partial_message_data(struct ceph_connection *con)
1476 unsigned int data_len = le32_to_cpu(msg->hdr.data_len); 1476 unsigned int data_len = le32_to_cpu(msg->hdr.data_len);
1477 bool do_datacrc = !con->msgr->nocrc; 1477 bool do_datacrc = !con->msgr->nocrc;
1478 int ret; 1478 int ret;
1479 int total_max_write;
1480 1479
1481 dout("%s %p msg %p page %d offset %d\n", __func__, 1480 dout("%s %p msg %p page %d offset %d\n", __func__,
1482 con, msg, msg_pos->page, msg_pos->page_pos); 1481 con, msg, msg_pos->page, msg_pos->page_pos);
@@ -1490,36 +1489,30 @@ static int write_partial_message_data(struct ceph_connection *con)
1490 * been revoked, so use the zero page. 1489 * been revoked, so use the zero page.
1491 */ 1490 */
1492 while (data_len > msg_pos->data_pos) { 1491 while (data_len > msg_pos->data_pos) {
1493 struct page *page = NULL; 1492 struct page *page;
1494 size_t page_offset; 1493 size_t page_offset;
1495 size_t length; 1494 size_t length;
1496 bool use_cursor = false; 1495 bool last_piece;
1497 bool last_piece = true; /* preserve existing behavior */
1498
1499 total_max_write = data_len - msg_pos->data_pos;
1500 1496
1501 if (ceph_msg_has_pages(msg)) { 1497 if (ceph_msg_has_pages(msg)) {
1502 use_cursor = true;
1503 page = ceph_msg_data_next(&msg->p, &page_offset, 1498 page = ceph_msg_data_next(&msg->p, &page_offset,
1504 &length, &last_piece); 1499 &length, &last_piece);
1505 } else if (ceph_msg_has_pagelist(msg)) { 1500 } else if (ceph_msg_has_pagelist(msg)) {
1506 use_cursor = true;
1507 page = ceph_msg_data_next(&msg->l, &page_offset, 1501 page = ceph_msg_data_next(&msg->l, &page_offset,
1508 &length, &last_piece); 1502 &length, &last_piece);
1509#ifdef CONFIG_BLOCK 1503#ifdef CONFIG_BLOCK
1510 } else if (ceph_msg_has_bio(msg)) { 1504 } else if (ceph_msg_has_bio(msg)) {
1511 use_cursor = true;
1512 page = ceph_msg_data_next(&msg->b, &page_offset, 1505 page = ceph_msg_data_next(&msg->b, &page_offset,
1513 &length, &last_piece); 1506 &length, &last_piece);
1514#endif 1507#endif
1515 } else { 1508 } else {
1516 page = zero_page; 1509 size_t resid = data_len - msg_pos->data_pos;
1517 }
1518 if (!use_cursor) {
1519 length = min_t(int, PAGE_SIZE - msg_pos->page_pos,
1520 total_max_write);
1521 1510
1511 page = zero_page;
1522 page_offset = msg_pos->page_pos; 1512 page_offset = msg_pos->page_pos;
1513 length = PAGE_SIZE - page_offset;
1514 length = min(resid, length);
1515 last_piece = length == resid;
1523 } 1516 }
1524 if (do_datacrc && !msg_pos->did_page_crc) { 1517 if (do_datacrc && !msg_pos->did_page_crc) {
1525 u32 crc = le32_to_cpu(msg->footer.data_crc); 1518 u32 crc = le32_to_cpu(msg->footer.data_crc);