aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/decode.h16
-rw-r--r--fs/ceph/mdsmap.c1
-rw-r--r--fs/ceph/messenger.c23
-rw-r--r--fs/ceph/messenger.h1
-rw-r--r--fs/ceph/mon_client.c2
-rw-r--r--fs/ceph/msgr.h2
-rw-r--r--fs/ceph/osdmap.c3
7 files changed, 40 insertions, 8 deletions
diff --git a/fs/ceph/decode.h b/fs/ceph/decode.h
index 91179fb2cc3f..a382aecc55bb 100644
--- a/fs/ceph/decode.h
+++ b/fs/ceph/decode.h
@@ -76,19 +76,31 @@ static inline void ceph_decode_copy(void **p, void *pv, size_t n)
76 * struct ceph_timespec <-> struct timespec 76 * struct ceph_timespec <-> struct timespec
77 */ 77 */
78static inline void ceph_decode_timespec(struct timespec *ts, 78static inline void ceph_decode_timespec(struct timespec *ts,
79 struct ceph_timespec *tv) 79 const struct ceph_timespec *tv)
80{ 80{
81 ts->tv_sec = le32_to_cpu(tv->tv_sec); 81 ts->tv_sec = le32_to_cpu(tv->tv_sec);
82 ts->tv_nsec = le32_to_cpu(tv->tv_nsec); 82 ts->tv_nsec = le32_to_cpu(tv->tv_nsec);
83} 83}
84static inline void ceph_encode_timespec(struct ceph_timespec *tv, 84static inline void ceph_encode_timespec(struct ceph_timespec *tv,
85 struct timespec *ts) 85 const struct timespec *ts)
86{ 86{
87 tv->tv_sec = cpu_to_le32(ts->tv_sec); 87 tv->tv_sec = cpu_to_le32(ts->tv_sec);
88 tv->tv_nsec = cpu_to_le32(ts->tv_nsec); 88 tv->tv_nsec = cpu_to_le32(ts->tv_nsec);
89} 89}
90 90
91/* 91/*
92 * sockaddr_storage <-> ceph_sockaddr
93 */
94static inline void ceph_encode_addr(struct ceph_entity_addr *a)
95{
96 a->in_addr.ss_family = htons(a->in_addr.ss_family);
97}
98static inline void ceph_decode_addr(struct ceph_entity_addr *a)
99{
100 a->in_addr.ss_family = ntohs(a->in_addr.ss_family);
101}
102
103/*
92 * encoders 104 * encoders
93 */ 105 */
94static inline void ceph_encode_64(void **p, u64 v) 106static inline void ceph_encode_64(void **p, u64 v)
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c
index 80daea064470..4226c810ce22 100644
--- a/fs/ceph/mdsmap.c
+++ b/fs/ceph/mdsmap.c
@@ -86,6 +86,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
86 86
87 ceph_decode_need(p, end, sizeof(addr) + 1 + sizeof(u32), bad); 87 ceph_decode_need(p, end, sizeof(addr) + 1 + sizeof(u32), bad);
88 ceph_decode_copy(p, &addr, sizeof(addr)); 88 ceph_decode_copy(p, &addr, sizeof(addr));
89 ceph_decode_addr(&addr);
89 infoversion = ceph_decode_8(p); 90 infoversion = ceph_decode_8(p);
90 namelen = ceph_decode_32(p); /* skip mds name */ 91 namelen = ceph_decode_32(p); /* skip mds name */
91 *p += namelen; 92 *p += namelen;
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
index b48abc0b3be7..6ff44bbddf67 100644
--- a/fs/ceph/messenger.c
+++ b/fs/ceph/messenger.c
@@ -12,6 +12,7 @@
12 12
13#include "super.h" 13#include "super.h"
14#include "messenger.h" 14#include "messenger.h"
15#include "decode.h"
15 16
16/* 17/*
17 * Ceph uses the messenger to exchange ceph_msg messages with other 18 * Ceph uses the messenger to exchange ceph_msg messages with other
@@ -97,6 +98,12 @@ const char *pr_addr(const struct sockaddr_storage *ss)
97 return s; 98 return s;
98} 99}
99 100
101static void encode_my_addr(struct ceph_messenger *msgr)
102{
103 memcpy(&msgr->my_enc_addr, &msgr->inst.addr, sizeof(msgr->my_enc_addr));
104 ceph_encode_addr(&msgr->my_enc_addr);
105}
106
100/* 107/*
101 * work queue for all reading and writing to/from the socket. 108 * work queue for all reading and writing to/from the socket.
102 */ 109 */
@@ -590,12 +597,12 @@ static void prepare_write_connect(struct ceph_messenger *msgr,
590 597
591 con->out_kvec[0].iov_base = CEPH_BANNER; 598 con->out_kvec[0].iov_base = CEPH_BANNER;
592 con->out_kvec[0].iov_len = len; 599 con->out_kvec[0].iov_len = len;
593 con->out_kvec[1].iov_base = &msgr->inst.addr; 600 con->out_kvec[1].iov_base = &msgr->my_enc_addr;
594 con->out_kvec[1].iov_len = sizeof(msgr->inst.addr); 601 con->out_kvec[1].iov_len = sizeof(msgr->my_enc_addr);
595 con->out_kvec[2].iov_base = &con->out_connect; 602 con->out_kvec[2].iov_base = &con->out_connect;
596 con->out_kvec[2].iov_len = sizeof(con->out_connect); 603 con->out_kvec[2].iov_len = sizeof(con->out_connect);
597 con->out_kvec_left = 3; 604 con->out_kvec_left = 3;
598 con->out_kvec_bytes = len + sizeof(msgr->inst.addr) + 605 con->out_kvec_bytes = len + sizeof(msgr->my_enc_addr) +
599 sizeof(con->out_connect); 606 sizeof(con->out_connect);
600 con->out_kvec_cur = con->out_kvec; 607 con->out_kvec_cur = con->out_kvec;
601 con->out_more = 0; 608 con->out_more = 0;
@@ -976,6 +983,9 @@ static int process_connect(struct ceph_connection *con)
976 if (verify_hello(con) < 0) 983 if (verify_hello(con) < 0)
977 return -1; 984 return -1;
978 985
986 ceph_decode_addr(&con->actual_peer_addr);
987 ceph_decode_addr(&con->peer_addr_for_me);
988
979 /* 989 /*
980 * Make sure the other end is who we wanted. note that the other 990 * Make sure the other end is who we wanted. note that the other
981 * end may not yet know their ip address, so if it's 0.0.0.0, give 991 * end may not yet know their ip address, so if it's 0.0.0.0, give
@@ -1005,6 +1015,7 @@ static int process_connect(struct ceph_connection *con)
1005 &con->peer_addr_for_me.in_addr, 1015 &con->peer_addr_for_me.in_addr,
1006 sizeof(con->peer_addr_for_me.in_addr)); 1016 sizeof(con->peer_addr_for_me.in_addr));
1007 addr_set_port(&con->msgr->inst.addr.in_addr, port); 1017 addr_set_port(&con->msgr->inst.addr.in_addr, port);
1018 encode_my_addr(con->msgr);
1008 dout("process_connect learned my addr is %s\n", 1019 dout("process_connect learned my addr is %s\n",
1009 pr_addr(&con->msgr->inst.addr.in_addr)); 1020 pr_addr(&con->msgr->inst.addr.in_addr));
1010 } 1021 }
@@ -1780,6 +1791,7 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr)
1780 /* select a random nonce */ 1791 /* select a random nonce */
1781 get_random_bytes(&msgr->inst.addr.nonce, 1792 get_random_bytes(&msgr->inst.addr.nonce,
1782 sizeof(msgr->inst.addr.nonce)); 1793 sizeof(msgr->inst.addr.nonce));
1794 encode_my_addr(msgr);
1783 1795
1784 dout("messenger_create %p\n", msgr); 1796 dout("messenger_create %p\n", msgr);
1785 return msgr; 1797 return msgr;
@@ -1806,8 +1818,9 @@ void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
1806 } 1818 }
1807 1819
1808 /* set src+dst */ 1820 /* set src+dst */
1809 msg->hdr.src = con->msgr->inst; 1821 msg->hdr.src.name = con->msgr->inst.name;
1810 msg->hdr.orig_src = con->msgr->inst; 1822 msg->hdr.src.addr = con->msgr->my_enc_addr;
1823 msg->hdr.orig_src = msg->hdr.src;
1811 msg->hdr.dst_erank = con->peer_addr.erank; 1824 msg->hdr.dst_erank = con->peer_addr.erank;
1812 1825
1813 /* queue */ 1826 /* queue */
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h
index dcd98b64dca9..e016fa7cf970 100644
--- a/fs/ceph/messenger.h
+++ b/fs/ceph/messenger.h
@@ -53,6 +53,7 @@ extern const char *ceph_name_type_str(int t);
53 53
54struct ceph_messenger { 54struct ceph_messenger {
55 struct ceph_entity_inst inst; /* my name+address */ 55 struct ceph_entity_inst inst; /* my name+address */
56 struct ceph_entity_addr my_enc_addr;
56 struct page *zero_page; /* used in certain error cases */ 57 struct page *zero_page; /* used in certain error cases */
57 58
58 bool nocrc; 59 bool nocrc;
diff --git a/fs/ceph/mon_client.c b/fs/ceph/mon_client.c
index 61263c99c6a8..95b76e761e18 100644
--- a/fs/ceph/mon_client.c
+++ b/fs/ceph/mon_client.c
@@ -59,6 +59,8 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
59 m->epoch = epoch; 59 m->epoch = epoch;
60 m->num_mon = num_mon; 60 m->num_mon = num_mon;
61 ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0])); 61 ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0]));
62 for (i = 0; i < num_mon; i++)
63 ceph_decode_addr(&m->mon_inst[i].addr);
62 64
63 dout("monmap_decode epoch %d, num_mon %d\n", m->epoch, 65 dout("monmap_decode epoch %d, num_mon %d\n", m->epoch,
64 m->num_mon); 66 m->num_mon);
diff --git a/fs/ceph/msgr.h b/fs/ceph/msgr.h
index 9abc879e25b1..8e3ea2eb1bf5 100644
--- a/fs/ceph/msgr.h
+++ b/fs/ceph/msgr.h
@@ -21,7 +21,7 @@
21 * whenever the wire protocol changes. try to keep this string length 21 * whenever the wire protocol changes. try to keep this string length
22 * constant. 22 * constant.
23 */ 23 */
24#define CEPH_BANNER "ceph v022" 24#define CEPH_BANNER "ceph v023"
25#define CEPH_BANNER_MAX_LEN 30 25#define CEPH_BANNER_MAX_LEN 30
26 26
27 27
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
index d62e111b8a34..cd7bb265d789 100644
--- a/fs/ceph/osdmap.c
+++ b/fs/ceph/osdmap.c
@@ -460,6 +460,8 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
460 460
461 *p += 4; /* skip length field (should match max) */ 461 *p += 4; /* skip length field (should match max) */
462 ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr)); 462 ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr));
463 for (i = 0; i < map->max_osd; i++)
464 ceph_decode_addr(&map->osd_addr[i]);
463 465
464 /* pg_temp */ 466 /* pg_temp */
465 ceph_decode_32_safe(p, end, len, bad); 467 ceph_decode_32_safe(p, end, len, bad);
@@ -619,6 +621,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
619 struct ceph_entity_addr addr; 621 struct ceph_entity_addr addr;
620 ceph_decode_32_safe(p, end, osd, bad); 622 ceph_decode_32_safe(p, end, osd, bad);
621 ceph_decode_copy_safe(p, end, &addr, sizeof(addr), bad); 623 ceph_decode_copy_safe(p, end, &addr, sizeof(addr), bad);
624 ceph_decode_addr(&addr);
622 pr_info("osd%d up\n", osd); 625 pr_info("osd%d up\n", osd);
623 BUG_ON(osd >= map->max_osd); 626 BUG_ON(osd >= map->max_osd);
624 map->osd_state[osd] |= CEPH_OSD_UP; 627 map->osd_state[osd] |= CEPH_OSD_UP;