aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/mon_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ceph/mon_client.c')
-rw-r--r--net/ceph/mon_client.c79
1 files changed, 43 insertions, 36 deletions
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index cbe31fa45508..0b62deae42bd 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -116,14 +116,12 @@ static void __send_prepared_auth_request(struct ceph_mon_client *monc, int len)
116 */ 116 */
117static void __close_session(struct ceph_mon_client *monc) 117static void __close_session(struct ceph_mon_client *monc)
118{ 118{
119 if (monc->con) { 119 dout("__close_session closing mon%d\n", monc->cur_mon);
120 dout("__close_session closing mon%d\n", monc->cur_mon); 120 ceph_con_revoke(monc->con, monc->m_auth);
121 ceph_con_revoke(monc->con, monc->m_auth); 121 ceph_con_close(monc->con);
122 ceph_con_close(monc->con); 122 monc->cur_mon = -1;
123 monc->cur_mon = -1; 123 monc->pending_auth = 0;
124 monc->pending_auth = 0; 124 ceph_auth_reset(monc->auth);
125 ceph_auth_reset(monc->auth);
126 }
127} 125}
128 126
129/* 127/*
@@ -302,15 +300,6 @@ void ceph_monc_request_next_osdmap(struct ceph_mon_client *monc)
302 */ 300 */
303int ceph_monc_open_session(struct ceph_mon_client *monc) 301int ceph_monc_open_session(struct ceph_mon_client *monc)
304{ 302{
305 if (!monc->con) {
306 monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL);
307 if (!monc->con)
308 return -ENOMEM;
309 ceph_con_init(monc->client->msgr, monc->con);
310 monc->con->private = monc;
311 monc->con->ops = &mon_con_ops;
312 }
313
314 mutex_lock(&monc->mutex); 303 mutex_lock(&monc->mutex);
315 __open_session(monc); 304 __open_session(monc);
316 __schedule_delayed(monc); 305 __schedule_delayed(monc);
@@ -528,10 +517,12 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
528 init_completion(&req->completion); 517 init_completion(&req->completion);
529 518
530 err = -ENOMEM; 519 err = -ENOMEM;
531 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS); 520 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS,
521 true);
532 if (!req->request) 522 if (!req->request)
533 goto out; 523 goto out;
534 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, GFP_NOFS); 524 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, GFP_NOFS,
525 true);
535 if (!req->reply) 526 if (!req->reply)
536 goto out; 527 goto out;
537 528
@@ -626,10 +617,12 @@ int ceph_monc_do_poolop(struct ceph_mon_client *monc, u32 op,
626 init_completion(&req->completion); 617 init_completion(&req->completion);
627 618
628 err = -ENOMEM; 619 err = -ENOMEM;
629 req->request = ceph_msg_new(CEPH_MSG_POOLOP, sizeof(*h), GFP_NOFS); 620 req->request = ceph_msg_new(CEPH_MSG_POOLOP, sizeof(*h), GFP_NOFS,
621 true);
630 if (!req->request) 622 if (!req->request)
631 goto out; 623 goto out;
632 req->reply = ceph_msg_new(CEPH_MSG_POOLOP_REPLY, 1024, GFP_NOFS); 624 req->reply = ceph_msg_new(CEPH_MSG_POOLOP_REPLY, 1024, GFP_NOFS,
625 true);
633 if (!req->reply) 626 if (!req->reply)
634 goto out; 627 goto out;
635 628
@@ -755,13 +748,21 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
755 if (err) 748 if (err)
756 goto out; 749 goto out;
757 750
758 monc->con = NULL; 751 /* connection */
752 monc->con = kmalloc(sizeof(*monc->con), GFP_KERNEL);
753 if (!monc->con)
754 goto out_monmap;
755 ceph_con_init(monc->client->msgr, monc->con);
756 monc->con->private = monc;
757 monc->con->ops = &mon_con_ops;
759 758
760 /* authentication */ 759 /* authentication */
761 monc->auth = ceph_auth_init(cl->options->name, 760 monc->auth = ceph_auth_init(cl->options->name,
762 cl->options->key); 761 cl->options->key);
763 if (IS_ERR(monc->auth)) 762 if (IS_ERR(monc->auth)) {
764 return PTR_ERR(monc->auth); 763 err = PTR_ERR(monc->auth);
764 goto out_con;
765 }
765 monc->auth->want_keys = 766 monc->auth->want_keys =
766 CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON | 767 CEPH_ENTITY_TYPE_AUTH | CEPH_ENTITY_TYPE_MON |
767 CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS; 768 CEPH_ENTITY_TYPE_OSD | CEPH_ENTITY_TYPE_MDS;
@@ -770,19 +771,21 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
770 err = -ENOMEM; 771 err = -ENOMEM;
771 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, 772 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
772 sizeof(struct ceph_mon_subscribe_ack), 773 sizeof(struct ceph_mon_subscribe_ack),
773 GFP_NOFS); 774 GFP_NOFS, true);
774 if (!monc->m_subscribe_ack) 775 if (!monc->m_subscribe_ack)
775 goto out_monmap; 776 goto out_auth;
776 777
777 monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS); 778 monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, GFP_NOFS,
779 true);
778 if (!monc->m_subscribe) 780 if (!monc->m_subscribe)
779 goto out_subscribe_ack; 781 goto out_subscribe_ack;
780 782
781 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS); 783 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, GFP_NOFS,
784 true);
782 if (!monc->m_auth_reply) 785 if (!monc->m_auth_reply)
783 goto out_subscribe; 786 goto out_subscribe;
784 787
785 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS); 788 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_NOFS, true);
786 monc->pending_auth = 0; 789 monc->pending_auth = 0;
787 if (!monc->m_auth) 790 if (!monc->m_auth)
788 goto out_auth_reply; 791 goto out_auth_reply;
@@ -808,6 +811,10 @@ out_subscribe:
808 ceph_msg_put(monc->m_subscribe); 811 ceph_msg_put(monc->m_subscribe);
809out_subscribe_ack: 812out_subscribe_ack:
810 ceph_msg_put(monc->m_subscribe_ack); 813 ceph_msg_put(monc->m_subscribe_ack);
814out_auth:
815 ceph_auth_destroy(monc->auth);
816out_con:
817 monc->con->ops->put(monc->con);
811out_monmap: 818out_monmap:
812 kfree(monc->monmap); 819 kfree(monc->monmap);
813out: 820out:
@@ -822,11 +829,11 @@ void ceph_monc_stop(struct ceph_mon_client *monc)
822 829
823 mutex_lock(&monc->mutex); 830 mutex_lock(&monc->mutex);
824 __close_session(monc); 831 __close_session(monc);
825 if (monc->con) { 832
826 monc->con->private = NULL; 833 monc->con->private = NULL;
827 monc->con->ops->put(monc->con); 834 monc->con->ops->put(monc->con);
828 monc->con = NULL; 835 monc->con = NULL;
829 } 836
830 mutex_unlock(&monc->mutex); 837 mutex_unlock(&monc->mutex);
831 838
832 ceph_auth_destroy(monc->auth); 839 ceph_auth_destroy(monc->auth);
@@ -973,7 +980,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
973 case CEPH_MSG_MON_MAP: 980 case CEPH_MSG_MON_MAP:
974 case CEPH_MSG_MDS_MAP: 981 case CEPH_MSG_MDS_MAP:
975 case CEPH_MSG_OSD_MAP: 982 case CEPH_MSG_OSD_MAP:
976 m = ceph_msg_new(type, front_len, GFP_NOFS); 983 m = ceph_msg_new(type, front_len, GFP_NOFS, false);
977 break; 984 break;
978 } 985 }
979 986
@@ -1000,7 +1007,7 @@ static void mon_fault(struct ceph_connection *con)
1000 if (!con->private) 1007 if (!con->private)
1001 goto out; 1008 goto out;
1002 1009
1003 if (monc->con && !monc->hunting) 1010 if (!monc->hunting)
1004 pr_info("mon%d %s session lost, " 1011 pr_info("mon%d %s session lost, "
1005 "hunting for new mon\n", monc->cur_mon, 1012 "hunting for new mon\n", monc->cur_mon,
1006 ceph_pr_addr(&monc->con->peer_addr.in_addr)); 1013 ceph_pr_addr(&monc->con->peer_addr.in_addr));