aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
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
commite6cee71fac27c946a0bbad754dd076e66c4e9dbd (patch)
tree9c20b73601c5904376e4e986877c7ad75da0927f /net/ceph
parent57dac9d1620942608306d8c17c98a9d1568ffdf4 (diff)
ceph: messenger: update "to" in read_partial() caller
read_partial() always increases whatever "to" value is supplied by adding the requested size to it, and that's the only thing it does with that pointed-to value. Do that pointer advance in the caller (and then only when the updated value will be subsequently used), and change the "to" parameter to be an in-only and non-pointer value. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 673133ee3181..37fd2aece232 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -992,11 +992,12 @@ 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 to, int size, void *object)
996{ 996{
997 *to += size; 997 int end = to + size;
998 while (con->in_base_pos < *to) { 998
999 int left = *to - con->in_base_pos; 999 while (con->in_base_pos < end) {
1000 int left = end - con->in_base_pos;
1000 int have = size - left; 1001 int have = size - left;
1001 int ret = ceph_tcp_recvmsg(con->sock, object + have, left); 1002 int ret = ceph_tcp_recvmsg(con->sock, object + have, left);
1002 if (ret <= 0) 1003 if (ret <= 0)
@@ -1017,14 +1018,16 @@ static int read_partial_banner(struct ceph_connection *con)
1017 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);
1018 1019
1019 /* peer's banner */ 1020 /* peer's banner */
1020 ret = read_partial(con, &to, strlen(CEPH_BANNER), con->in_banner); 1021 ret = read_partial(con, to, strlen(CEPH_BANNER), con->in_banner);
1021 if (ret <= 0) 1022 if (ret <= 0)
1022 goto out; 1023 goto out;
1023 ret = read_partial(con, &to, sizeof(con->actual_peer_addr), 1024 to += strlen(CEPH_BANNER);
1025 ret = read_partial(con, to, sizeof(con->actual_peer_addr),
1024 &con->actual_peer_addr); 1026 &con->actual_peer_addr);
1025 if (ret <= 0) 1027 if (ret <= 0)
1026 goto out; 1028 goto out;
1027 ret = read_partial(con, &to, sizeof(con->peer_addr_for_me), 1029 to += sizeof(con->actual_peer_addr);
1030 ret = read_partial(con, to, sizeof(con->peer_addr_for_me),
1028 &con->peer_addr_for_me); 1031 &con->peer_addr_for_me);
1029 if (ret <= 0) 1032 if (ret <= 0)
1030 goto out; 1033 goto out;
@@ -1038,10 +1041,11 @@ static int read_partial_connect(struct ceph_connection *con)
1038 1041
1039 dout("read_partial_connect %p at %d\n", con, con->in_base_pos); 1042 dout("read_partial_connect %p at %d\n", con, con->in_base_pos);
1040 1043
1041 ret = read_partial(con, &to, sizeof(con->in_reply), &con->in_reply); 1044 ret = read_partial(con, to, sizeof(con->in_reply), &con->in_reply);
1042 if (ret <= 0) 1045 if (ret <= 0)
1043 goto out; 1046 goto out;
1044 ret = read_partial(con, &to, le32_to_cpu(con->in_reply.authorizer_len), 1047 to += sizeof(con->in_reply);
1048 ret = read_partial(con, to, le32_to_cpu(con->in_reply.authorizer_len),
1045 con->auth_reply_buf); 1049 con->auth_reply_buf);
1046 if (ret <= 0) 1050 if (ret <= 0)
1047 goto out; 1051 goto out;
@@ -1491,9 +1495,7 @@ static int process_connect(struct ceph_connection *con)
1491 */ 1495 */
1492static int read_partial_ack(struct ceph_connection *con) 1496static int read_partial_ack(struct ceph_connection *con)
1493{ 1497{
1494 int to = 0; 1498 return read_partial(con, 0, sizeof(con->in_temp_ack),
1495
1496 return read_partial(con, &to, sizeof(con->in_temp_ack),
1497 &con->in_temp_ack); 1499 &con->in_temp_ack);
1498} 1500}
1499 1501
@@ -1638,8 +1640,7 @@ static int read_partial_message(struct ceph_connection *con)
1638 dout("read_partial_message con %p msg %p\n", con, m); 1640 dout("read_partial_message con %p msg %p\n", con, m);
1639 1641
1640 /* header */ 1642 /* header */
1641 to = 0; 1643 ret = read_partial(con, 0, sizeof (con->in_hdr), &con->in_hdr);
1642 ret = read_partial(con, &to, sizeof (con->in_hdr), &con->in_hdr);
1643 if (ret <= 0) 1644 if (ret <= 0)
1644 return ret; 1645 return ret;
1645 1646
@@ -1755,7 +1756,7 @@ static int read_partial_message(struct ceph_connection *con)
1755 1756
1756 /* footer */ 1757 /* footer */
1757 to = sizeof (m->hdr); 1758 to = sizeof (m->hdr);
1758 ret = read_partial(con, &to, sizeof (m->footer), &m->footer); 1759 ret = read_partial(con, to, sizeof (m->footer), &m->footer);
1759 if (ret <= 0) 1760 if (ret <= 0)
1760 return ret; 1761 return ret;
1761 1762