diff options
author | Alex Elder <elder@inktank.com> | 2013-03-08 13:35:36 -0600 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-01 21:17:06 -0700 |
commit | 8a166d05369f6a0369bb194a795e6e3928ac6e34 (patch) | |
tree | 3ab95714e5d1533d10fbc5558704a59b85022088 /net | |
parent | 9d2a06c2750177dca5f8d0e89884c1d409d64bbc (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.c | 21 |
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) unsigned int data_len = le32_to_cpu(msg->hdr.data_len); bool do_datacrc = !con->msgr->nocrc; int ret; - int total_max_write; dout("%s %p msg %p page %d offset %d\n", __func__, con, msg, msg_pos->page, msg_pos->page_pos); @@ -1490,36 +1489,30 @@ static int write_partial_message_data(struct ceph_connection *con) * been revoked, so use the zero page. */ while (data_len > msg_pos->data_pos) { - struct page *page = NULL; + struct page *page; size_t page_offset; size_t length; - bool use_cursor = false; - bool last_piece = true; /* preserve existing behavior */ - - total_max_write = data_len - msg_pos->data_pos; + bool last_piece; if (ceph_msg_has_pages(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->p, &page_offset, &length, &last_piece); } else if (ceph_msg_has_pagelist(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->l, &page_offset, &length, &last_piece); #ifdef CONFIG_BLOCK } else if (ceph_msg_has_bio(msg)) { - use_cursor = true; page = ceph_msg_data_next(&msg->b, &page_offset, &length, &last_piece); #endif } else { - page = zero_page; - } - if (!use_cursor) { - length = min_t(int, PAGE_SIZE - msg_pos->page_pos, - total_max_write); + size_t resid = data_len - msg_pos->data_pos; + page = zero_page; page_offset = msg_pos->page_pos; + length = PAGE_SIZE - page_offset; + length = min(resid, length); + last_piece = length == resid; } if (do_datacrc && !msg_pos->did_page_crc) { u32 crc = le32_to_cpu(msg->footer.data_crc); |