From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 3/3] libceph: do crc calculations outside loop
Date: Tue, 28 Feb 2012 20:50:55 -0800 [thread overview]
Message-ID: <4F4DAEAF.7020102@dreamhost.com> (raw)
In-Reply-To: <4F4DAE4E.4000903@dreamhost.com>
Move blocks of code out of loops in read_partial_message_section()
and read_partial_message(). They were only was getting called at
the end of the last iteration of the loop anyway.
Signed-off-by: Alex Elder <elder@dreamhost.com>
---
net/ceph/messenger.c | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 1df7e6f..693be64 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1541,10 +1541,9 @@ static int read_partial_message_section(struct
ceph_connection *con,
if (ret <= 0)
return ret;
section->iov_len += ret;
- if (section->iov_len == sec_len)
- *crc = crc32c(0, section->iov_base,
- section->iov_len);
}
+ if (section->iov_len == sec_len)
+ *crc = crc32c(0, section->iov_base, section->iov_len);
return 1;
}
@@ -1635,6 +1634,7 @@ static int read_partial_message(struct
ceph_connection *con)
bool do_datacrc = con->msgr->nocrc;
int skip;
u64 seq;
+ u32 crc;
dout("read_partial_message con %p msg %p\n", con, m);
@@ -1647,18 +1647,16 @@ static int read_partial_message(struct
ceph_connection *con)
if (ret <= 0)
return ret;
con->in_base_pos += ret;
- if (con->in_base_pos == sizeof(con->in_hdr)) {
- u32 crc = crc32c(0, &con->in_hdr,
- offsetof(struct ceph_msg_header, crc));
-
- if (cpu_to_le32(crc) != con->in_hdr.crc) {
- pr_err("read_partial_message bad hdr "
- " crc %u != expected %u\n",
- crc, con->in_hdr.crc);
- return -EBADMSG;
- }
- }
}
+
+ crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
+ if (cpu_to_le32(crc) != con->in_hdr.crc) {
+ pr_err("read_partial_message bad hdr "
+ " crc %u != expected %u\n",
+ crc, con->in_hdr.crc);
+ return -EBADMSG;
+ }
+
front_len = le32_to_cpu(con->in_hdr.front_len);
if (front_len > CEPH_MSG_MAX_FRONT_LEN)
return -EIO;
--
1.7.5.4
next prev parent reply other threads:[~2012-02-29 4:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 4:49 [PATCH 0/3] libceph: clean up some code involving CRCs Alex Elder
2012-02-29 4:50 ` [PATCH 1/3] libceph: use "do" in CRC-related Boolean variables Alex Elder
2012-02-29 4:50 ` [PATCH 2/3] libceph: separate CRC calculation from byte swapping Alex Elder
2012-02-29 4:50 ` Alex Elder [this message]
2012-03-02 21:47 ` [PATCH 0/3] libceph: clean up some code involving CRCs Sage Weil
2012-03-02 23:30 ` Alex Elder
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=4F4DAEAF.7020102@dreamhost.com \
--to=elder@dreamhost.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.