Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 188603
b: refs/heads/master
c: 63f2d21
h: refs/heads/master
i:
  188601: 9b7f75c
  188599: ca2a776
v: v3
  • Loading branch information
Sage Weil committed Nov 3, 2009
1 parent 4c4770b commit a34213f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 859e7b149362475672e2a996f29b8f45cbb34d82
refs/heads/master: 63f2d211954b790fea0a9caeae605c7956535af6
16 changes: 14 additions & 2 deletions trunk/fs/ceph/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,30 @@ static inline void ceph_decode_copy(void **p, void *pv, size_t n)
* struct ceph_timespec <-> struct timespec
*/
static inline void ceph_decode_timespec(struct timespec *ts,
struct ceph_timespec *tv)
const struct ceph_timespec *tv)
{
ts->tv_sec = le32_to_cpu(tv->tv_sec);
ts->tv_nsec = le32_to_cpu(tv->tv_nsec);
}
static inline void ceph_encode_timespec(struct ceph_timespec *tv,
struct timespec *ts)
const struct timespec *ts)
{
tv->tv_sec = cpu_to_le32(ts->tv_sec);
tv->tv_nsec = cpu_to_le32(ts->tv_nsec);
}

/*
* sockaddr_storage <-> ceph_sockaddr
*/
static inline void ceph_encode_addr(struct ceph_entity_addr *a)
{
a->in_addr.ss_family = htons(a->in_addr.ss_family);
}
static inline void ceph_decode_addr(struct ceph_entity_addr *a)
{
a->in_addr.ss_family = ntohs(a->in_addr.ss_family);
}

/*
* encoders
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ceph/mdsmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)

ceph_decode_need(p, end, sizeof(addr) + 1 + sizeof(u32), bad);
ceph_decode_copy(p, &addr, sizeof(addr));
ceph_decode_addr(&addr);
infoversion = ceph_decode_8(p);
namelen = ceph_decode_32(p); /* skip mds name */
*p += namelen;
Expand Down
23 changes: 18 additions & 5 deletions trunk/fs/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "super.h"
#include "messenger.h"
#include "decode.h"

/*
* Ceph uses the messenger to exchange ceph_msg messages with other
Expand Down Expand Up @@ -97,6 +98,12 @@ const char *pr_addr(const struct sockaddr_storage *ss)
return s;
}

static void encode_my_addr(struct ceph_messenger *msgr)
{
memcpy(&msgr->my_enc_addr, &msgr->inst.addr, sizeof(msgr->my_enc_addr));
ceph_encode_addr(&msgr->my_enc_addr);
}

/*
* work queue for all reading and writing to/from the socket.
*/
Expand Down Expand Up @@ -590,12 +597,12 @@ static void prepare_write_connect(struct ceph_messenger *msgr,

con->out_kvec[0].iov_base = CEPH_BANNER;
con->out_kvec[0].iov_len = len;
con->out_kvec[1].iov_base = &msgr->inst.addr;
con->out_kvec[1].iov_len = sizeof(msgr->inst.addr);
con->out_kvec[1].iov_base = &msgr->my_enc_addr;
con->out_kvec[1].iov_len = sizeof(msgr->my_enc_addr);
con->out_kvec[2].iov_base = &con->out_connect;
con->out_kvec[2].iov_len = sizeof(con->out_connect);
con->out_kvec_left = 3;
con->out_kvec_bytes = len + sizeof(msgr->inst.addr) +
con->out_kvec_bytes = len + sizeof(msgr->my_enc_addr) +
sizeof(con->out_connect);
con->out_kvec_cur = con->out_kvec;
con->out_more = 0;
Expand Down Expand Up @@ -976,6 +983,9 @@ static int process_connect(struct ceph_connection *con)
if (verify_hello(con) < 0)
return -1;

ceph_decode_addr(&con->actual_peer_addr);
ceph_decode_addr(&con->peer_addr_for_me);

/*
* Make sure the other end is who we wanted. note that the other
* end may not yet know their ip address, so if it's 0.0.0.0, give
Expand Down Expand Up @@ -1005,6 +1015,7 @@ static int process_connect(struct ceph_connection *con)
&con->peer_addr_for_me.in_addr,
sizeof(con->peer_addr_for_me.in_addr));
addr_set_port(&con->msgr->inst.addr.in_addr, port);
encode_my_addr(con->msgr);
dout("process_connect learned my addr is %s\n",
pr_addr(&con->msgr->inst.addr.in_addr));
}
Expand Down Expand Up @@ -1780,6 +1791,7 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr)
/* select a random nonce */
get_random_bytes(&msgr->inst.addr.nonce,
sizeof(msgr->inst.addr.nonce));
encode_my_addr(msgr);

dout("messenger_create %p\n", msgr);
return msgr;
Expand All @@ -1806,8 +1818,9 @@ void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg)
}

/* set src+dst */
msg->hdr.src = con->msgr->inst;
msg->hdr.orig_src = con->msgr->inst;
msg->hdr.src.name = con->msgr->inst.name;
msg->hdr.src.addr = con->msgr->my_enc_addr;
msg->hdr.orig_src = msg->hdr.src;
msg->hdr.dst_erank = con->peer_addr.erank;

/* queue */
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ceph/messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern const char *ceph_name_type_str(int t);

struct ceph_messenger {
struct ceph_entity_inst inst; /* my name+address */
struct ceph_entity_addr my_enc_addr;
struct page *zero_page; /* used in certain error cases */

bool nocrc;
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/ceph/mon_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
m->epoch = epoch;
m->num_mon = num_mon;
ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0]));
for (i = 0; i < num_mon; i++)
ceph_decode_addr(&m->mon_inst[i].addr);

dout("monmap_decode epoch %d, num_mon %d\n", m->epoch,
m->num_mon);
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/ceph/msgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* whenever the wire protocol changes. try to keep this string length
* constant.
*/
#define CEPH_BANNER "ceph v022"
#define CEPH_BANNER "ceph v023"
#define CEPH_BANNER_MAX_LEN 30


Expand Down
3 changes: 3 additions & 0 deletions trunk/fs/ceph/osdmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)

*p += 4; /* skip length field (should match max) */
ceph_decode_copy(p, map->osd_addr, map->max_osd*sizeof(*map->osd_addr));
for (i = 0; i < map->max_osd; i++)
ceph_decode_addr(&map->osd_addr[i]);

/* pg_temp */
ceph_decode_32_safe(p, end, len, bad);
Expand Down Expand Up @@ -619,6 +621,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
struct ceph_entity_addr addr;
ceph_decode_32_safe(p, end, osd, bad);
ceph_decode_copy_safe(p, end, &addr, sizeof(addr), bad);
ceph_decode_addr(&addr);
pr_info("osd%d up\n", osd);
BUG_ON(osd >= map->max_osd);
map->osd_state[osd] |= CEPH_OSD_UP;
Expand Down

0 comments on commit a34213f

Please sign in to comment.