aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-05-10 11:29:50 -0400
committerAlex Elder <elder@dreamhost.com>2012-05-14 13:16:42 -0400
commitfd51653f78cf40a0516e521b6de22f329c5bad8d (patch)
tree9645467cbb3a23bca4f3c7434f6ee93f212fa2ed
parente6cee71fac27c946a0bbad754dd076e66c4e9dbd (diff)
ceph: messenger: change read_partial() to take "end" arg
Make the second argument to read_partial() be the ending input byte position rather than the beginning offset it now represents. This amounts to moving the addition "to + size" into the caller. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
-rw-r--r--net/ceph/messenger.c60
1 files changed, 38 insertions, 22 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 37fd2aece232..a659b4de64aa 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -992,10 +992,8 @@ static int prepare_read_message(struct ceph_connection *con)
992 992
993 993
994static int read_partial(struct ceph_connection *con, 994static int read_partial(struct ceph_connection *con,
995 int to, int size, void *object) 995 int end, int size, void *object)
996{ 996{
997 int end = to + size;
998
999 while (con->in_base_pos < end) { 997 while (con->in_base_pos < end) {
1000 int left = end - con->in_base_pos; 998 int left = end - con->in_base_pos;
1001 int have = size - left; 999 int have = size - left;
@@ -1013,40 +1011,52 @@ static int read_partial(struct ceph_connection *con,
1013 */ 1011 */
1014static int read_partial_banner(struct ceph_connection *con) 1012static int read_partial_banner(struct ceph_connection *con)
1015{ 1013{
1016 int ret, to = 0; 1014 int size;
1015 int end;
1016 int ret;
1017 1017
1018 dout("read_partial_banner %p at %d\n", con, con->in_base_pos); 1018 dout("read_partial_banner %p at %d\n", con, con->in_base_pos);
1019 1019
1020 /* peer's banner */ 1020 /* peer's banner */
1021 ret = read_partial(con, to, strlen(CEPH_BANNER), con->in_banner); 1021 size = strlen(CEPH_BANNER);
1022 end = size;
1023 ret = read_partial(con, end, size, con->in_banner);
1022 if (ret <= 0) 1024 if (ret <= 0)
1023 goto out; 1025 goto out;
1024 to += strlen(CEPH_BANNER); 1026
1025 ret = read_partial(con, to, sizeof(con->actual_peer_addr), 1027 size = sizeof (con->actual_peer_addr);
1026 &con->actual_peer_addr); 1028 end += size;
1029 ret = read_partial(con, end, size, &con->actual_peer_addr);
1027 if (ret <= 0) 1030 if (ret <= 0)
1028 goto out; 1031 goto out;
1029 to += sizeof(con->actual_peer_addr); 1032
1030 ret = read_partial(con, to, sizeof(con->peer_addr_for_me), 1033 size = sizeof (con->peer_addr_for_me);
1031 &con->peer_addr_for_me); 1034 end += size;
1035 ret = read_partial(con, end, size, &con->peer_addr_for_me);
1032 if (ret <= 0) 1036 if (ret <= 0)
1033 goto out; 1037 goto out;
1038
1034out: 1039out:
1035 return ret; 1040 return ret;
1036} 1041}
1037 1042
1038static int read_partial_connect(struct ceph_connection *con) 1043static int read_partial_connect(struct ceph_connection *con)
1039{ 1044{
1040 int ret, to = 0; 1045 int size;
1046 int end;
1047 int ret;
1041 1048
1042 dout("read_partial_connect %p at %d\n", con, con->in_base_pos); 1049 dout("read_partial_connect %p at %d\n", con, con->in_base_pos);
1043 1050
1044 ret = read_partial(con, to, sizeof(con->in_reply), &con->in_reply); 1051 size = sizeof (con->in_reply);
1052 end = size;
1053 ret = read_partial(con, end, size, &con->in_reply);
1045 if (ret <= 0) 1054 if (ret <= 0)
1046 goto out; 1055 goto out;
1047 to += sizeof(con->in_reply); 1056
1048 ret = read_partial(con, to, le32_to_cpu(con->in_reply.authorizer_len), 1057 size = le32_to_cpu(con->in_reply.authorizer_len);
1049 con->auth_reply_buf); 1058 end += size;
1059 ret = read_partial(con, end, size, con->auth_reply_buf);
1050 if (ret <= 0) 1060 if (ret <= 0)
1051 goto out; 1061 goto out;
1052 1062
@@ -1495,8 +1505,10 @@ static int process_connect(struct ceph_connection *con)
1495 */ 1505 */
1496static int read_partial_ack(struct ceph_connection *con) 1506static int read_partial_ack(struct ceph_connection *con)
1497{ 1507{
1498 return read_partial(con, 0, sizeof(con->in_temp_ack), 1508 int size = sizeof (con->in_temp_ack);
1499 &con->in_temp_ack); 1509 int end = size;
1510
1511 return read_partial(con, end, size, &con->in_temp_ack);
1500} 1512}
1501 1513
1502 1514
@@ -1629,8 +1641,9 @@ static int read_partial_message_bio(struct ceph_connection *con,
1629static int read_partial_message(struct ceph_connection *con) 1641static int read_partial_message(struct ceph_connection *con)
1630{ 1642{
1631 struct ceph_msg *m = con->in_msg; 1643 struct ceph_msg *m = con->in_msg;
1644 int size;
1645 int end;
1632 int ret; 1646 int ret;
1633 int to;
1634 unsigned front_len, middle_len, data_len; 1647 unsigned front_len, middle_len, data_len;
1635 bool do_datacrc = !con->msgr->nocrc; 1648 bool do_datacrc = !con->msgr->nocrc;
1636 int skip; 1649 int skip;
@@ -1640,7 +1653,9 @@ static int read_partial_message(struct ceph_connection *con)
1640 dout("read_partial_message con %p msg %p\n", con, m); 1653 dout("read_partial_message con %p msg %p\n", con, m);
1641 1654
1642 /* header */ 1655 /* header */
1643 ret = read_partial(con, 0, sizeof (con->in_hdr), &con->in_hdr); 1656 size = sizeof (con->in_hdr);
1657 end = size;
1658 ret = read_partial(con, end, size, &con->in_hdr);
1644 if (ret <= 0) 1659 if (ret <= 0)
1645 return ret; 1660 return ret;
1646 1661
@@ -1755,8 +1770,9 @@ static int read_partial_message(struct ceph_connection *con)
1755 } 1770 }
1756 1771
1757 /* footer */ 1772 /* footer */
1758 to = sizeof (m->hdr); 1773 size = sizeof (m->footer);
1759 ret = read_partial(con, to, sizeof (m->footer), &m->footer); 1774 end += size;
1775 ret = read_partial(con, end, size, &m->footer);
1760 if (ret <= 0) 1776 if (ret <= 0)
1761 return ret; 1777 return ret;
1762 1778