diff options
author | Alex Elder <elder@inktank.com> | 2012-05-10 11:29:50 -0400 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-05-14 13:16:41 -0400 |
commit | 57dac9d1620942608306d8c17c98a9d1568ffdf4 (patch) | |
tree | 89a3359e888aae5ac5ccdacaa30d7ddadd2314b8 /net/ceph/messenger.c | |
parent | b7f6519e6bc7a0c5a9e3eadc8a2c79c0d4556050 (diff) |
ceph: messenger: use read_partial() in read_partial_message()
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>
Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r-- | net/ceph/messenger.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index f0993af2ae4d..673133ee3181 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -1628,7 +1628,7 @@ static int read_partial_message(struct ceph_connection *con) | |||
1628 | { | 1628 | { |
1629 | struct ceph_msg *m = con->in_msg; | 1629 | struct ceph_msg *m = con->in_msg; |
1630 | int ret; | 1630 | int ret; |
1631 | int to, left; | 1631 | int to; |
1632 | unsigned front_len, middle_len, data_len; | 1632 | unsigned front_len, middle_len, data_len; |
1633 | bool do_datacrc = !con->msgr->nocrc; | 1633 | bool do_datacrc = !con->msgr->nocrc; |
1634 | int skip; | 1634 | int skip; |
@@ -1638,15 +1638,10 @@ static int read_partial_message(struct ceph_connection *con) | |||
1638 | dout("read_partial_message con %p msg %p\n", con, m); | 1638 | dout("read_partial_message con %p msg %p\n", con, m); |
1639 | 1639 | ||
1640 | /* header */ | 1640 | /* header */ |
1641 | while (con->in_base_pos < sizeof(con->in_hdr)) { | 1641 | to = 0; |
1642 | left = sizeof(con->in_hdr) - con->in_base_pos; | 1642 | ret = read_partial(con, &to, sizeof (con->in_hdr), &con->in_hdr); |
1643 | ret = ceph_tcp_recvmsg(con->sock, | 1643 | if (ret <= 0) |
1644 | (char *)&con->in_hdr + con->in_base_pos, | 1644 | return ret; |
1645 | left); | ||
1646 | if (ret <= 0) | ||
1647 | return ret; | ||
1648 | con->in_base_pos += ret; | ||
1649 | } | ||
1650 | 1645 | ||
1651 | crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc)); | 1646 | crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc)); |
1652 | if (cpu_to_le32(crc) != con->in_hdr.crc) { | 1647 | if (cpu_to_le32(crc) != con->in_hdr.crc) { |
@@ -1759,16 +1754,11 @@ static int read_partial_message(struct ceph_connection *con) | |||
1759 | } | 1754 | } |
1760 | 1755 | ||
1761 | /* footer */ | 1756 | /* footer */ |
1762 | to = sizeof(m->hdr) + sizeof(m->footer); | 1757 | to = sizeof (m->hdr); |
1763 | while (con->in_base_pos < to) { | 1758 | ret = read_partial(con, &to, sizeof (m->footer), &m->footer); |
1764 | left = to - con->in_base_pos; | 1759 | if (ret <= 0) |
1765 | ret = ceph_tcp_recvmsg(con->sock, (char *)&m->footer + | 1760 | return ret; |
1766 | (con->in_base_pos - sizeof(m->hdr)), | 1761 | |
1767 | left); | ||
1768 | if (ret <= 0) | ||
1769 | return ret; | ||
1770 | con->in_base_pos += ret; | ||
1771 | } | ||
1772 | dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n", | 1762 | dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n", |
1773 | m, front_len, m->footer.front_crc, middle_len, | 1763 | m, front_len, m->footer.front_crc, middle_len, |
1774 | m->footer.middle_crc, data_len, m->footer.data_crc); | 1764 | m->footer.middle_crc, data_len, m->footer.data_crc); |