summaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-02-15 07:43:54 -0600
committerAlex Elder <elder@dreamhost.com>2012-03-22 10:47:51 -0500
commitfe3ad593e2c34457ffa6233014ab19f4d36f85f2 (patch)
treeeed6ceddbca3021e7492a1baaf658922e2aa8a6c /net/ceph
parenta9a0c51af4e7c825c014b40694571456a75ebbc4 (diff)
libceph: do crc calculations outside loop
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> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 7ec6a228b66..575511a29eb 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1544,10 +1544,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;
}
@@ -1638,6 +1637,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);
@@ -1650,18 +1650,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;