From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 6/6] libceph: define and use ceph_crc32c_page()
Date: Sat, 09 Mar 2013 10:43:58 -0600 [thread overview]
Message-ID: <513B66CE.2000609@inktank.com> (raw)
In-Reply-To: <513B661F.4050203@inktank.com>
Factor out a common block of code that updates a CRC calculation
over a range of data in a page.
This and the preceding patches are related to:
http://tracker.ceph.com/issues/4403
Signed-off-by: Alex Elder <elder@inktank.com>
---
net/ceph/messenger.c | 47 ++++++++++++++++++++---------------------------
1 file changed, 20 insertions(+), 27 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 7df7941..e677fd3 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1085,6 +1085,19 @@ static void in_msg_pos_next(struct
ceph_connection *con, size_t len,
#endif /* CONFIG_BLOCK */
}
+static u32 ceph_crc32c_page(u32 crc, struct page *page,
+ unsigned int page_offset,
+ unsigned int length)
+{
+ char *kaddr;
+
+ kaddr = kmap(page);
+ BUG_ON(kaddr == NULL);
+ crc = crc32c(crc, kaddr + page_offset, length);
+ kunmap(page);
+
+ return crc;
+}
/*
* Write as much message data payload as we can. If we finish, queue
* up the footer.
@@ -1153,15 +1166,9 @@ static int write_partial_message_data(struct
ceph_connection *con)
page_offset = msg_pos->page_pos + bio_offset;
if (do_datacrc && !msg_pos->did_page_crc) {
- void *base;
u32 crc = le32_to_cpu(msg->footer.data_crc);
- char *kaddr;
- kaddr = kmap(page);
- BUG_ON(kaddr == NULL);
- base = kaddr + page_offset;
- crc = crc32c(crc, base, length);
- kunmap(page);
+ crc = ceph_crc32c_page(crc, page, page_offset, length);
msg->footer.data_crc = cpu_to_le32(crc);
msg_pos->did_page_crc = true;
}
@@ -1843,16 +1850,9 @@ static int read_partial_message_pages(struct
ceph_connection *con,
if (ret <= 0)
return ret;
- if (do_datacrc) {
- void *kaddr;
- void *base;
-
- kaddr = kmap(page);
- BUG_ON(!kaddr);
- base = kaddr + page_offset;
- con->in_data_crc = crc32c(con->in_data_crc, base, ret);
- kunmap(page);
- }
+ if (do_datacrc)
+ con->in_data_crc = ceph_crc32c_page(con->in_data_crc, page,
+ page_offset, ret);
in_msg_pos_next(con, length, ret);
@@ -1886,16 +1886,9 @@ static int read_partial_message_bio(struct
ceph_connection *con,
if (ret <= 0)
return ret;
- if (do_datacrc) {
- void *kaddr;
- void *base;
-
- kaddr = kmap(page);
- BUG_ON(!kaddr);
- base = kaddr + page_offset;
- con->in_data_crc = crc32c(con->in_data_crc, base, ret);
- kunmap(page);
- }
+ if (do_datacrc)
+ con->in_data_crc = ceph_crc32c_page(con->in_data_crc, page,
+ page_offset, ret);
in_msg_pos_next(con, length, ret);
--
1.7.9.5
next prev parent reply other threads:[~2013-03-09 16:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 16:41 [PATCH 0/6] libceph: refactor messenger for multiple data sources Alex Elder
2013-03-09 16:42 ` [PATCH 1/6] libceph: use local variables for message positions Alex Elder
2013-03-09 16:42 ` [PATCH 2/6] libceph: consolidate message prep code Alex Elder
2013-03-09 16:43 ` [PATCH 3/6] libceph: small write_partial_msg_pages() refactor Alex Elder
2013-03-09 16:43 ` [PATCH 4/6] libceph: encapsulate reading message data Alex Elder
2013-03-10 0:38 ` [PATCH 4/6, v2] " Alex Elder
2013-03-10 16:33 ` [PATCH 4/6, v3] " Alex Elder
2013-03-09 16:43 ` [PATCH 5/6] libceph: define and use ceph_tcp_recvpage() Alex Elder
2013-03-09 16:43 ` Alex Elder [this message]
2013-03-11 21:01 ` [PATCH 0/6] libceph: refactor messenger for multiple data sources 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=513B66CE.2000609@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.