From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 1/3] ceph: messenger: use read_partial() in read_partial_message()
Date: Thu, 10 May 2012 20:18:41 -0500 [thread overview]
Message-ID: <4FAC68F1.3070301@inktank.com> (raw)
In-Reply-To: <4FAC4799.3010903@inktank.com>
There are two blocks of code in read_partial_message()--those that
read the header and footer of the message--that can be replaced by a
call to read_partial(). Do that.
Signed-off-by: Alex Elder <elder@inktank.com>
---
net/ceph/messenger.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index f0993af..673133e 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1628,7 +1628,7 @@ static int read_partial_message(struct
ceph_connection *con)
{
struct ceph_msg *m = con->in_msg;
int ret;
- int to, left;
+ int to;
unsigned front_len, middle_len, data_len;
bool do_datacrc = !con->msgr->nocrc;
int skip;
@@ -1638,15 +1638,10 @@ static int read_partial_message(struct
ceph_connection *con)
dout("read_partial_message con %p msg %p\n", con, m);
/* header */
- while (con->in_base_pos < sizeof(con->in_hdr)) {
- left = sizeof(con->in_hdr) - con->in_base_pos;
- ret = ceph_tcp_recvmsg(con->sock,
- (char *)&con->in_hdr + con->in_base_pos,
- left);
- if (ret <= 0)
- return ret;
- con->in_base_pos += ret;
- }
+ to = 0;
+ ret = read_partial(con, &to, sizeof (con->in_hdr), &con->in_hdr);
+ if (ret <= 0)
+ return ret;
crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
if (cpu_to_le32(crc) != con->in_hdr.crc) {
@@ -1759,16 +1754,11 @@ static int read_partial_message(struct
ceph_connection *con)
}
/* footer */
- to = sizeof(m->hdr) + sizeof(m->footer);
- while (con->in_base_pos < to) {
- left = to - con->in_base_pos;
- ret = ceph_tcp_recvmsg(con->sock, (char *)&m->footer +
- (con->in_base_pos - sizeof(m->hdr)),
- left);
- if (ret <= 0)
- return ret;
- con->in_base_pos += ret;
- }
+ to = sizeof (m->hdr);
+ ret = read_partial(con, &to, sizeof (m->footer), &m->footer);
+ if (ret <= 0)
+ return ret;
+
dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n",
m, front_len, m->footer.front_crc, middle_len,
m->footer.middle_crc, data_len, m->footer.data_crc);
--
1.7.9.5
next prev parent reply other threads:[~2012-05-11 1:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-10 22:56 [PATCH 0/3] ceph: messenger: read_partial() cleanups Alex Elder
2012-05-11 1:18 ` Alex Elder [this message]
2012-05-12 23:54 ` [PATCH 1/3] ceph: messenger: use read_partial() in read_partial_message() Sage Weil
2012-05-11 1:18 ` [PATCH 2/3] ceph: messenger: update "to" in read_partial() caller Alex Elder
2012-05-12 23:55 ` Sage Weil
2012-05-11 1:18 ` [PATCH 3/3] ceph: messenger: change read_partial() to take "end" arg Alex Elder
2012-05-13 0:11 ` Sage Weil
2012-05-14 16:26 ` Alex Elder
2012-05-14 16:28 ` 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=4FAC68F1.3070301@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox