aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-06-27 15:24:08 -0400
committerSage Weil <sage@inktank.com>2012-07-06 00:14:35 -0400
commitb7a9e5dd40f17a48a72f249b8bbc989b63bae5fd (patch)
treef4951e53776e2ec45f9b539b786be67c8a7f42a2 /net
parent261030215d970c62f799e6e508e3c68fc7ec2aa9 (diff)
libceph: set peer name on con_open, not init
The peer name may change on each open attempt, even when the connection is reused. Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net')
-rw-r--r--net/ceph/messenger.c12
-rw-r--r--net/ceph/mon_client.c4
-rw-r--r--net/ceph/osd_client.c10
3 files changed, 15 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index dcc50e4cd5cd..ae082d95fc72 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -523,12 +523,17 @@ EXPORT_SYMBOL(ceph_con_close);
523/* 523/*
524 * Reopen a closed connection, with a new peer address. 524 * Reopen a closed connection, with a new peer address.
525 */ 525 */
526void ceph_con_open(struct ceph_connection *con, struct ceph_entity_addr *addr) 526void ceph_con_open(struct ceph_connection *con,
527 __u8 entity_type, __u64 entity_num,
528 struct ceph_entity_addr *addr)
527{ 529{
528 dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr)); 530 dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
529 set_bit(OPENING, &con->state); 531 set_bit(OPENING, &con->state);
530 WARN_ON(!test_and_clear_bit(CLOSED, &con->state)); 532 WARN_ON(!test_and_clear_bit(CLOSED, &con->state));
531 533
534 con->peer_name.type = (__u8) entity_type;
535 con->peer_name.num = cpu_to_le64(entity_num);
536
532 memcpy(&con->peer_addr, addr, sizeof(*addr)); 537 memcpy(&con->peer_addr, addr, sizeof(*addr));
533 con->delay = 0; /* reset backoff memory */ 538 con->delay = 0; /* reset backoff memory */
534 queue_con(con); 539 queue_con(con);
@@ -548,7 +553,7 @@ bool ceph_con_opened(struct ceph_connection *con)
548 */ 553 */
549void ceph_con_init(struct ceph_connection *con, void *private, 554void ceph_con_init(struct ceph_connection *con, void *private,
550 const struct ceph_connection_operations *ops, 555 const struct ceph_connection_operations *ops,
551 struct ceph_messenger *msgr, __u8 entity_type, __u64 entity_num) 556 struct ceph_messenger *msgr)
552{ 557{
553 dout("con_init %p\n", con); 558 dout("con_init %p\n", con);
554 memset(con, 0, sizeof(*con)); 559 memset(con, 0, sizeof(*con));
@@ -558,9 +563,6 @@ void ceph_con_init(struct ceph_connection *con, void *private,
558 563
559 con_sock_state_init(con); 564 con_sock_state_init(con);
560 565
561 con->peer_name.type = (__u8) entity_type;
562 con->peer_name.num = cpu_to_le64(entity_num);
563
564 mutex_init(&con->mutex); 566 mutex_init(&con->mutex);
565 INIT_LIST_HEAD(&con->out_queue); 567 INIT_LIST_HEAD(&con->out_queue);
566 INIT_LIST_HEAD(&con->out_sent); 568 INIT_LIST_HEAD(&con->out_sent);
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index e9db3de20b2e..bcc80a0e2a98 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -143,11 +143,11 @@ static int __open_session(struct ceph_mon_client *monc)
143 monc->want_next_osdmap = !!monc->want_next_osdmap; 143 monc->want_next_osdmap = !!monc->want_next_osdmap;
144 144
145 ceph_con_init(&monc->con, monc, &mon_con_ops, 145 ceph_con_init(&monc->con, monc, &mon_con_ops,
146 &monc->client->msgr, 146 &monc->client->msgr);
147 CEPH_ENTITY_TYPE_MON, monc->cur_mon);
148 147
149 dout("open_session mon%d opening\n", monc->cur_mon); 148 dout("open_session mon%d opening\n", monc->cur_mon);
150 ceph_con_open(&monc->con, 149 ceph_con_open(&monc->con,
150 CEPH_ENTITY_TYPE_MON, monc->cur_mon,
151 &monc->monmap->mon_inst[monc->cur_mon].addr); 151 &monc->monmap->mon_inst[monc->cur_mon].addr);
152 152
153 /* initiatiate authentication handshake */ 153 /* initiatiate authentication handshake */
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index db2da54f7336..c2527113d2ae 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -639,8 +639,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
639 INIT_LIST_HEAD(&osd->o_osd_lru); 639 INIT_LIST_HEAD(&osd->o_osd_lru);
640 osd->o_incarnation = 1; 640 osd->o_incarnation = 1;
641 641
642 ceph_con_init(&osd->o_con, osd, &osd_con_ops, &osdc->client->msgr, 642 ceph_con_init(&osd->o_con, osd, &osd_con_ops, &osdc->client->msgr);
643 CEPH_ENTITY_TYPE_OSD, onum);
644 643
645 INIT_LIST_HEAD(&osd->o_keepalive_item); 644 INIT_LIST_HEAD(&osd->o_keepalive_item);
646 return osd; 645 return osd;
@@ -750,7 +749,8 @@ static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
750 ret = -EAGAIN; 749 ret = -EAGAIN;
751 } else { 750 } else {
752 ceph_con_close(&osd->o_con); 751 ceph_con_close(&osd->o_con);
753 ceph_con_open(&osd->o_con, &osdc->osdmap->osd_addr[osd->o_osd]); 752 ceph_con_open(&osd->o_con, CEPH_ENTITY_TYPE_OSD, osd->o_osd,
753 &osdc->osdmap->osd_addr[osd->o_osd]);
754 osd->o_incarnation++; 754 osd->o_incarnation++;
755 } 755 }
756 return ret; 756 return ret;
@@ -1005,7 +1005,9 @@ static int __map_request(struct ceph_osd_client *osdc,
1005 dout("map_request osd %p is osd%d\n", req->r_osd, o); 1005 dout("map_request osd %p is osd%d\n", req->r_osd, o);
1006 __insert_osd(osdc, req->r_osd); 1006 __insert_osd(osdc, req->r_osd);
1007 1007
1008 ceph_con_open(&req->r_osd->o_con, &osdc->osdmap->osd_addr[o]); 1008 ceph_con_open(&req->r_osd->o_con,
1009 CEPH_ENTITY_TYPE_OSD, o,
1010 &osdc->osdmap->osd_addr[o]);
1009 } 1011 }
1010 1012
1011 if (req->r_osd) { 1013 if (req->r_osd) {