From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 4/4] libceph: more cleanup of write_partial_msg_pages()
Date: Sun, 10 Mar 2013 15:36:55 -0500 [thread overview]
Message-ID: <513CEEE7.2090809@inktank.com> (raw)
In-Reply-To: <513CEE83.4040900@inktank.com>
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>
---
net/ceph/messenger.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index b7ddf2b..6c88db4 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1466,7 +1466,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);
@@ -1480,36 +1479,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);
+ unsigned int end;
+ last_piece = data_len <= PAGE_SIZE;
page_offset = msg_pos->page_pos;
+ end = last_piece ? data_len : PAGE_SIZE;
+ length = end - page_offset;
+ page = zero_page;
}
if (do_datacrc && !msg_pos->did_page_crc) {
u32 crc = le32_to_cpu(msg->footer.data_crc);
--
1.7.9.5
next prev parent reply other threads:[~2013-03-10 20:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-10 20:35 [PATCH 0/4] libceph: kill the "trail" portion of message data Alex Elder
2013-03-10 20:36 ` [PATCH 1/4] libceph: have osd requests support pagelist data Alex Elder
2013-03-10 20:36 ` [PATCH 2/4] libceph: kill osd request r_trail Alex Elder
2013-03-10 20:36 ` [PATCH 3/4] libceph: kill message trail Alex Elder
2013-03-10 20:36 ` Alex Elder [this message]
2013-03-11 5:08 ` [PATCH 4/4, v2] libceph: more cleanup of write_partial_msg_pages() Alex Elder
2013-03-11 22:44 ` [PATCH 0/4] libceph: kill the "trail" portion of message data Josh Durgin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=513CEEE7.2090809@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.