aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/mon_client.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-05-27 00:26:43 -0400
committerAlex Elder <elder@dreamhost.com>2012-06-06 10:23:54 -0400
commit67130934fb579fdf0f2f6d745960264378b57dc8 (patch)
tree5b0f5eaa9d3fd24ba30368911c3a157acd2b9e33 /net/ceph/mon_client.c
parent0d47766f14211a73eaf54cab234db134ece79f49 (diff)
libceph: embed ceph connection structure in mon_client
A monitor client has a pointer to a ceph connection structure in it. This is the only one of the three ceph client types that do it this way; the OSD and MDS clients embed the connection into their main structures. There is always exactly one ceph connection for a monitor client, so there is no need to allocate it separate from the monitor client structure. So switch the ceph_mon_client structure to embed its ceph_connection structure. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph/mon_client.c')
-rw-r--r--net/ceph/mon_client.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index 704dc95dc620..ac4d6b100730 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -106,9 +106,9 @@ static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
106 monc->pending_auth = 1; 106 monc->pending_auth = 1;
107 monc->m_auth->front.iov_len = len; 107 monc->m_auth->front.iov_len = len;
108 monc->m_auth->hdr.front_len = cpu_to_le32(len); 108 monc->m_auth->hdr.front_len = cpu_to_le32(len);
109 ceph_con_revoke(monc->con, monc->m_auth); 109 ceph_con_revoke(&monc->con, monc->m_auth);
110 ceph_msg_get(monc->m_auth); /* keep our ref */ 110 ceph_msg_get(monc->m_auth); /* keep our ref */
111 ceph_con_send(monc->con, monc->m_auth); 111 ceph_con_send(&monc->con, monc->m_auth);
112} 112}
113 113
114/* 114/*
@@ -117,8 +117,8 @@ static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
117static void __close_session(struct ceph_mon_client *monc) 117static void __close_session(struct ceph_mon_client *monc)
118{ 118{
119 dout("__close_session closing mon%d\n", monc->cur_mon); 119 dout("__close_session closing mon%d\n", monc->cur_mon);
120 ceph_con_revoke(monc->con, monc->m_auth); 120 ceph_con_revoke(&monc->con, monc->m_auth);
121 ceph_con_close(monc->con); 121 ceph_con_close(&monc->con);
122 monc->cur_mon = -1; 122 monc->cur_mon = -1;
123 monc->pending_auth = 0; 123 monc->pending_auth = 0;
124 ceph_auth_reset(monc->auth); 124 ceph_auth_reset(monc->auth);
@@ -142,9 +142,9 @@ static int __open_session(struct ceph_mon_client *monc)
142 monc->want_next_osdmap = !!monc->want_next_osdmap; 142 monc->want_next_osdmap = !!monc->want_next_osdmap;
143 143
144 dout("open_session mon%d opening\n", monc->cur_mon); 144 dout("open_session mon%d opening\n", monc->cur_mon);
145 monc->con->peer_name.type = CEPH_ENTITY_TYPE_MON; 145 monc->con.peer_name.type = CEPH_ENTITY_TYPE_MON;
146 monc->con->peer_name.num = cpu_to_le64(monc->cur_mon); 146 monc->con.peer_name.num = cpu_to_le64(monc->cur_mon);
147 ceph_con_open(monc->con, 147 ceph_con_open(&monc->con,
148 &monc->monmap->mon_inst[monc->cur_mon].addr); 148 &monc->monmap->mon_inst[monc->cur_mon].addr);
149 149
150 /* initiatiate authentication handshake */ 150 /* initiatiate authentication handshake */
@@ -226,8 +226,8 @@ static void __send_subscribe(struct ceph_mon_client *monc)
226 226
227 msg->front.iov_len = p - msg->front.iov_base; 227 msg->front.iov_len = p - msg->front.iov_base;
228 msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); 228 msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
229 ceph_con_revoke(monc->con, msg); 229 ceph_con_revoke(&monc->con, msg);
230 ceph_con_send(monc->con, ceph_msg_get(msg)); 230 ceph_con_send(&monc->con, ceph_msg_get(msg));
231 231
232 monc->sub_sent = jiffies | 1; /* never 0 */ 232 monc->sub_sent = jiffies | 1; /* never 0 */
233 } 233 }
@@ -247,7 +247,7 @@ static void handle_subscribe_ack(struct ceph_mon_client *monc,
247 if (monc->hunting) { 247 if (monc->hunting) {
248 pr_info("mon%d %s session established\n", 248 pr_info("mon%d %s session established\n",
249 monc->cur_mon, 249 monc->cur_mon,
250 ceph_pr_addr(&monc->con->peer_addr.in_addr)); 250 ceph_pr_addr(&monc->con.peer_addr.in_addr));
251 monc->hunting = false; 251 monc->hunting = false;
252 } 252 }
253 dout("handle_subscribe_ack after %d seconds\n", seconds); 253 dout("handle_subscribe_ack after %d seconds\n", seconds);
@@ -461,7 +461,7 @@ static int do_generic_request(struct ceph_mon_client *monc,
461 req->request->hdr.tid = cpu_to_le64(req->tid); 461 req->request->hdr.tid = cpu_to_le64(req->tid);
462 __insert_generic_request(monc, req); 462 __insert_generic_request(monc, req);
463 monc->num_generic_requests++; 463 monc->num_generic_requests++;
464 ceph_con_send(monc->con, ceph_msg_get(req->request)); 464 ceph_con_send(&monc->con, ceph_msg_get(req->request));
465 mutex_unlock(&monc->mutex); 465 mutex_unlock(&monc->mutex);
466 466
467 err = wait_for_completion_interruptible(&req->completion); 467 err = wait_for_completion_interruptible(&req->completion);
@@ -684,8 +684,8 @@ static void __resend_generic_request(struct ceph_mon_client *monc)
684 684
685 for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) { 685 for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) {
686 req = rb_entry(p, struct ceph_mon_generic_request, node); 686 req = rb_entry(p, struct ceph_mon_generic_request, node);
687 ceph_con_revoke(monc->con, req->request); 687 ceph_con_revoke(&monc->con, req->request);
688 ceph_con_send(monc->con, ceph_msg_get(req->request)); 688 ceph_con_send(&monc->con, ceph_msg_get(req->request));
689 } 689 }
690} 690}
691 691
@@ -705,7 +705,7 @@ static void delayed_work(struct work_struct *work)
705 __close_session(monc); 705 __close_session(monc);
706 __open_session(monc); /* continue hunting */ 706 __open_session(monc); /* continue hunting */
707 } else { 707 } else {
708 ceph_con_keepalive(monc->con); 708 ceph_con_keepalive(&monc->con);
709 709
710 __validate_auth(monc); 710 __validate_auth(monc);
711 711
@@ -760,19 +760,16 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
760 goto out; 760 goto out;
761 761
762 /* connection */ 762 /* connection */
763 monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL); 763 ceph_con_init(&monc->client->msgr, &monc->con);
764 if (!monc->con) 764 monc->con.private = monc;
765 goto out_monmap; 765 monc->con.ops = &mon_con_ops;
766 ceph_con_init(&monc->client->msgr, monc->con);
767 monc->con->private = monc;
768 monc->con->ops = &mon_con_ops;
769 766
770 /* authentication */ 767 /* authentication */
771 monc->auth = ceph_auth_init(cl->options->name, 768 monc->auth = ceph_auth_init(cl->options->name,
772 cl->options->key); 769 cl->options->key);
773 if (IS_ERR(monc->auth)) { 770 if (IS_ERR(monc->auth)) {
774 err = PTR_ERR(monc->auth); 771 err = PTR_ERR(monc->auth);
775 goto out_con; 772 goto out_monmap;
776 } 773 }
777 monc->auth->want_keys = 774 monc->auth->want_keys =
778 CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON | 775 CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
@@ -824,8 +821,6 @@ out_subscribe_ack:
824 ceph_msg_put(monc->m_subscribe_ack); 821 ceph_msg_put(monc->m_subscribe_ack);
825out_auth: 822out_auth:
826 ceph_auth_destroy(monc->auth); 823 ceph_auth_destroy(monc->auth);
827out_con:
828 monc->con->ops->put(monc->con);
829out_monmap: 824out_monmap:
830 kfree(monc->monmap); 825 kfree(monc->monmap);
831out: 826out:
@@ -841,9 +836,7 @@ void ceph_monc_stop(struct ceph_mon_client *monc)
841 mutex_lock(&monc->mutex); 836 mutex_lock(&monc->mutex);
842 __close_session(monc); 837 __close_session(monc);
843 838
844 monc->con->private = NULL; 839 monc->con.private = NULL;
845 monc->con->ops->put(monc->con);
846 monc->con = NULL;
847 840
848 mutex_unlock(&monc->mutex); 841 mutex_unlock(&monc->mutex);
849 842
@@ -1021,7 +1014,7 @@ static void mon_fault(struct ceph_connection *con)
1021 if (!monc->hunting) 1014 if (!monc->hunting)
1022 pr_info("mon%d %s session lost, " 1015 pr_info("mon%d %s session lost, "
1023 "hunting for new mon\n", monc->cur_mon, 1016 "hunting for new mon\n", monc->cur_mon,
1024 ceph_pr_addr(&monc->con->peer_addr.in_addr)); 1017 ceph_pr_addr(&monc->con.peer_addr.in_addr));
1025 1018
1026 __close_session(monc); 1019 __close_session(monc);
1027 if (!monc->hunting) { 1020 if (!monc->hunting) {