• Home
  • Raw
  • Download

Lines Matching +full:front +full:- +full:end

1 // SPDX-License-Identifier: GPL-2.0
24 * of cmon daemons use a modified version of the Paxos part-time parliament
42 struct ceph_monmap *ceph_monmap_decode(void *p, void *end) in ceph_monmap_decode() argument
45 int i, err = -EINVAL; in ceph_monmap_decode()
50 ceph_decode_32_safe(&p, end, len, bad); in ceph_monmap_decode()
51 ceph_decode_need(&p, end, len, bad); in ceph_monmap_decode()
53 dout("monmap_decode %p %p len %d\n", p, end, (int)(end-p)); in ceph_monmap_decode()
56 ceph_decode_need(&p, end, sizeof(fsid) + 2*sizeof(u32), bad); in ceph_monmap_decode()
61 ceph_decode_need(&p, end, num_mon*sizeof(m->mon_inst[0]), bad); in ceph_monmap_decode()
67 return ERR_PTR(-ENOMEM); in ceph_monmap_decode()
68 m->fsid = fsid; in ceph_monmap_decode()
69 m->epoch = epoch; in ceph_monmap_decode()
70 m->num_mon = num_mon; in ceph_monmap_decode()
71 ceph_decode_copy(&p, m->mon_inst, num_mon*sizeof(m->mon_inst[0])); in ceph_monmap_decode()
73 ceph_decode_addr(&m->mon_inst[i].addr); in ceph_monmap_decode()
75 dout("monmap_decode epoch %d, num_mon %d\n", m->epoch, in ceph_monmap_decode()
76 m->num_mon); in ceph_monmap_decode()
77 for (i = 0; i < m->num_mon; i++) in ceph_monmap_decode()
79 ceph_pr_addr(&m->mon_inst[i].addr.in_addr)); in ceph_monmap_decode()
95 for (i = 0; i < m->num_mon; i++) in ceph_monmap_contains()
96 if (memcmp(addr, &m->mon_inst[i].addr, sizeof(*addr)) == 0) in ceph_monmap_contains()
106 monc->pending_auth = 1; in __send_prepared_auth_request()
107 monc->m_auth->front.iov_len = len; in __send_prepared_auth_request()
108 monc->m_auth->hdr.front_len = cpu_to_le32(len); in __send_prepared_auth_request()
109 ceph_msg_revoke(monc->m_auth); in __send_prepared_auth_request()
110 ceph_msg_get(monc->m_auth); /* keep our ref */ in __send_prepared_auth_request()
111 ceph_con_send(&monc->con, monc->m_auth); in __send_prepared_auth_request()
119 dout("__close_session closing mon%d\n", monc->cur_mon); in __close_session()
120 ceph_msg_revoke(monc->m_auth); in __close_session()
121 ceph_msg_revoke_incoming(monc->m_auth_reply); in __close_session()
122 ceph_msg_revoke(monc->m_subscribe); in __close_session()
123 ceph_msg_revoke_incoming(monc->m_subscribe_ack); in __close_session()
124 ceph_con_close(&monc->con); in __close_session()
126 monc->pending_auth = 0; in __close_session()
127 ceph_auth_reset(monc->auth); in __close_session()
136 int old_mon = monc->cur_mon; in pick_new_mon()
138 BUG_ON(monc->monmap->num_mon < 1); in pick_new_mon()
140 if (monc->monmap->num_mon == 1) { in pick_new_mon()
141 monc->cur_mon = 0; in pick_new_mon()
143 int max = monc->monmap->num_mon; in pick_new_mon()
144 int o = -1; in pick_new_mon()
147 if (monc->cur_mon >= 0) { in pick_new_mon()
148 if (monc->cur_mon < monc->monmap->num_mon) in pick_new_mon()
149 o = monc->cur_mon; in pick_new_mon()
151 max--; in pick_new_mon()
158 monc->cur_mon = n; in pick_new_mon()
161 dout("%s mon%d -> mon%d out of %d mons\n", __func__, old_mon, in pick_new_mon()
162 monc->cur_mon, monc->monmap->num_mon); in pick_new_mon()
174 monc->hunting = true; in __open_session()
175 if (monc->had_a_connection) { in __open_session()
176 monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF; in __open_session()
177 if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT) in __open_session()
178 monc->hunt_mult = CEPH_MONC_HUNT_MAX_MULT; in __open_session()
181 monc->sub_renew_after = jiffies; /* i.e., expired */ in __open_session()
182 monc->sub_renew_sent = 0; in __open_session()
184 dout("%s opening mon%d\n", __func__, monc->cur_mon); in __open_session()
185 ceph_con_open(&monc->con, CEPH_ENTITY_TYPE_MON, monc->cur_mon, in __open_session()
186 &monc->monmap->mon_inst[monc->cur_mon].addr); in __open_session()
192 ceph_con_keepalive(&monc->con); in __open_session()
195 ret = ceph_auth_build_hello(monc->auth, in __open_session()
196 monc->m_auth->front.iov_base, in __open_session()
197 monc->m_auth->front_alloc_len); in __open_session()
204 if (!monc->hunting) in reopen_session()
206 monc->cur_mon, ceph_pr_addr(&monc->con.peer_addr.in_addr)); in reopen_session()
214 monc->hunt_mult /= 2; /* reduce by 50% */ in un_backoff()
215 if (monc->hunt_mult < 1) in un_backoff()
216 monc->hunt_mult = 1; in un_backoff()
217 dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult); in un_backoff()
227 if (monc->hunting) in __schedule_delayed()
228 delay = CEPH_MONC_HUNT_INTERVAL * monc->hunt_mult; in __schedule_delayed()
233 mod_delayed_work(system_wq, &monc->delayed_work, in __schedule_delayed()
246 * monc->subs.
250 struct ceph_msg *msg = monc->m_subscribe; in __send_subscribe()
251 void *p = msg->front.iov_base; in __send_subscribe()
252 void *const end = p + msg->front_alloc_len; in __send_subscribe() local
256 dout("%s sent %lu\n", __func__, monc->sub_renew_sent); in __send_subscribe()
258 BUG_ON(monc->cur_mon < 0); in __send_subscribe()
260 if (!monc->sub_renew_sent) in __send_subscribe()
261 monc->sub_renew_sent = jiffies | 1; /* never 0 */ in __send_subscribe()
263 msg->hdr.version = cpu_to_le16(2); in __send_subscribe()
265 for (i = 0; i < ARRAY_SIZE(monc->subs); i++) { in __send_subscribe()
266 if (monc->subs[i].want) in __send_subscribe()
271 for (i = 0; i < ARRAY_SIZE(monc->subs); i++) { in __send_subscribe()
275 if (!monc->subs[i].want) in __send_subscribe()
280 monc->fs_cluster_id != CEPH_FS_CLUSTER_ID_NONE) in __send_subscribe()
281 len += sprintf(buf + len, ".%d", monc->fs_cluster_id); in __send_subscribe()
284 le64_to_cpu(monc->subs[i].item.start), in __send_subscribe()
285 monc->subs[i].item.flags); in __send_subscribe()
286 ceph_encode_string(&p, end, buf, len); in __send_subscribe()
287 memcpy(p, &monc->subs[i].item, sizeof(monc->subs[i].item)); in __send_subscribe()
288 p += sizeof(monc->subs[i].item); in __send_subscribe()
291 BUG_ON(p > end); in __send_subscribe()
292 msg->front.iov_len = p - msg->front.iov_base; in __send_subscribe()
293 msg->hdr.front_len = cpu_to_le32(msg->front.iov_len); in __send_subscribe()
295 ceph_con_send(&monc->con, ceph_msg_get(msg)); in __send_subscribe()
302 struct ceph_mon_subscribe_ack *h = msg->front.iov_base; in handle_subscribe_ack()
304 if (msg->front.iov_len < sizeof(*h)) in handle_subscribe_ack()
306 seconds = le32_to_cpu(h->duration); in handle_subscribe_ack()
308 mutex_lock(&monc->mutex); in handle_subscribe_ack()
309 if (monc->sub_renew_sent) { in handle_subscribe_ack()
312 * MONs -- see delayed_work(). in handle_subscribe_ack()
314 monc->sub_renew_after = monc->sub_renew_sent + in handle_subscribe_ack()
315 (seconds >> 1) * HZ - 1; in handle_subscribe_ack()
317 monc->sub_renew_sent, seconds, monc->sub_renew_after); in handle_subscribe_ack()
318 monc->sub_renew_sent = 0; in handle_subscribe_ack()
321 monc->sub_renew_sent, monc->sub_renew_after); in handle_subscribe_ack()
323 mutex_unlock(&monc->mutex); in handle_subscribe_ack()
326 pr_err("got corrupt subscribe-ack msg\n"); in handle_subscribe_ack()
345 if (monc->subs[sub].want && in __ceph_monc_want_map()
346 monc->subs[sub].item.start == start && in __ceph_monc_want_map()
347 monc->subs[sub].item.flags == flags) in __ceph_monc_want_map()
350 monc->subs[sub].item.start = start; in __ceph_monc_want_map()
351 monc->subs[sub].item.flags = flags; in __ceph_monc_want_map()
352 monc->subs[sub].want = true; in __ceph_monc_want_map()
362 mutex_lock(&monc->mutex); in ceph_monc_want_map()
364 mutex_unlock(&monc->mutex); in ceph_monc_want_map()
380 if (monc->subs[sub].want) { in __ceph_monc_got_map()
381 if (monc->subs[sub].item.flags & CEPH_SUBSCRIBE_ONETIME) in __ceph_monc_got_map()
382 monc->subs[sub].want = false; in __ceph_monc_got_map()
384 monc->subs[sub].item.start = cpu_to_le64(epoch + 1); in __ceph_monc_got_map()
387 monc->subs[sub].have = epoch; in __ceph_monc_got_map()
392 mutex_lock(&monc->mutex); in ceph_monc_got_map()
394 mutex_unlock(&monc->mutex); in ceph_monc_got_map()
400 mutex_lock(&monc->mutex); in ceph_monc_renew_subs()
402 mutex_unlock(&monc->mutex); in ceph_monc_renew_subs()
418 mutex_lock(&monc->mutex); in ceph_monc_wait_osdmap()
419 while (monc->subs[CEPH_SUB_OSDMAP].have < epoch) { in ceph_monc_wait_osdmap()
420 mutex_unlock(&monc->mutex); in ceph_monc_wait_osdmap()
423 return -ETIMEDOUT; in ceph_monc_wait_osdmap()
425 ret = wait_event_interruptible_timeout(monc->client->auth_wq, in ceph_monc_wait_osdmap()
426 monc->subs[CEPH_SUB_OSDMAP].have >= epoch, in ceph_monc_wait_osdmap()
431 mutex_lock(&monc->mutex); in ceph_monc_wait_osdmap()
434 mutex_unlock(&monc->mutex); in ceph_monc_wait_osdmap()
445 mutex_lock(&monc->mutex); in ceph_monc_open_session()
450 mutex_unlock(&monc->mutex); in ceph_monc_open_session()
458 struct ceph_client *client = monc->client; in ceph_monc_handle_map()
459 struct ceph_monmap *monmap = NULL, *old = monc->monmap; in ceph_monc_handle_map()
460 void *p, *end; in ceph_monc_handle_map() local
462 mutex_lock(&monc->mutex); in ceph_monc_handle_map()
465 p = msg->front.iov_base; in ceph_monc_handle_map()
466 end = p + msg->front.iov_len; in ceph_monc_handle_map()
468 monmap = ceph_monmap_decode(p, end); in ceph_monc_handle_map()
475 if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) { in ceph_monc_handle_map()
480 client->monc.monmap = monmap; in ceph_monc_handle_map()
483 __ceph_monc_got_map(monc, CEPH_SUB_MONMAP, monc->monmap->epoch); in ceph_monc_handle_map()
484 client->have_fsid = true; in ceph_monc_handle_map()
487 mutex_unlock(&monc->mutex); in ceph_monc_handle_map()
488 wake_up_all(&client->auth_wq); in ceph_monc_handle_map()
501 dout("%s greq %p request %p reply %p\n", __func__, req, req->request, in DEFINE_RB_FUNCS()
502 req->reply); in DEFINE_RB_FUNCS()
503 WARN_ON(!RB_EMPTY_NODE(&req->node)); in DEFINE_RB_FUNCS()
505 if (req->reply) in DEFINE_RB_FUNCS()
506 ceph_msg_put(req->reply); in DEFINE_RB_FUNCS()
507 if (req->request) in DEFINE_RB_FUNCS()
508 ceph_msg_put(req->request); in DEFINE_RB_FUNCS()
516 kref_put(&req->kref, release_generic_request); in put_generic_request()
521 kref_get(&req->kref); in get_generic_request()
533 req->monc = monc; in alloc_generic_request()
534 kref_init(&req->kref); in alloc_generic_request()
535 RB_CLEAR_NODE(&req->node); in alloc_generic_request()
536 init_completion(&req->completion); in alloc_generic_request()
544 struct ceph_mon_client *monc = req->monc; in register_generic_request()
546 WARN_ON(req->tid); in register_generic_request()
549 req->tid = ++monc->last_tid; in register_generic_request()
550 insert_generic_request(&monc->generic_request_tree, req); in register_generic_request()
556 WARN_ON(!req->tid); in send_generic_request()
558 dout("%s greq %p tid %llu\n", __func__, req, req->tid); in send_generic_request()
559 req->request->hdr.tid = cpu_to_le64(req->tid); in send_generic_request()
560 ceph_con_send(&monc->con, ceph_msg_get(req->request)); in send_generic_request()
565 struct ceph_mon_client *monc = req->monc; in __finish_generic_request()
567 dout("%s greq %p tid %llu\n", __func__, req, req->tid); in __finish_generic_request()
568 erase_generic_request(&monc->generic_request_tree, req); in __finish_generic_request()
570 ceph_msg_revoke(req->request); in __finish_generic_request()
571 ceph_msg_revoke_incoming(req->reply); in __finish_generic_request()
582 if (req->complete_cb) in complete_generic_request()
583 req->complete_cb(req); in complete_generic_request()
585 complete_all(&req->completion); in complete_generic_request()
591 struct ceph_mon_client *monc = req->monc; in cancel_generic_request()
594 dout("%s greq %p tid %llu\n", __func__, req, req->tid); in cancel_generic_request()
596 mutex_lock(&monc->mutex); in cancel_generic_request()
597 lookup_req = lookup_generic_request(&monc->generic_request_tree, in cancel_generic_request()
598 req->tid); in cancel_generic_request()
604 mutex_unlock(&monc->mutex); in cancel_generic_request()
611 dout("%s greq %p tid %llu\n", __func__, req, req->tid); in wait_generic_request()
612 ret = wait_for_completion_interruptible(&req->completion); in wait_generic_request()
616 ret = req->result; /* completed */ in wait_generic_request()
625 struct ceph_mon_client *monc = con->private; in get_generic_reply()
627 u64 tid = le64_to_cpu(hdr->tid); in get_generic_reply()
630 mutex_lock(&monc->mutex); in get_generic_reply()
631 req = lookup_generic_request(&monc->generic_request_tree, tid); in get_generic_reply()
637 dout("get_generic_reply %lld got %p\n", tid, req->reply); in get_generic_reply()
639 m = ceph_msg_get(req->reply); in get_generic_reply()
646 mutex_unlock(&monc->mutex); in get_generic_reply()
657 struct ceph_mon_statfs_reply *reply = msg->front.iov_base; in handle_statfs_reply()
658 u64 tid = le64_to_cpu(msg->hdr.tid); in handle_statfs_reply()
662 if (msg->front.iov_len != sizeof(*reply)) in handle_statfs_reply()
665 mutex_lock(&monc->mutex); in handle_statfs_reply()
666 req = lookup_generic_request(&monc->generic_request_tree, tid); in handle_statfs_reply()
668 mutex_unlock(&monc->mutex); in handle_statfs_reply()
672 req->result = 0; in handle_statfs_reply()
673 *req->u.st = reply->st; /* struct */ in handle_statfs_reply()
675 mutex_unlock(&monc->mutex); in handle_statfs_reply()
693 int ret = -ENOMEM; in ceph_monc_do_statfs()
699 req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), GFP_NOFS, in ceph_monc_do_statfs()
701 if (!req->request) in ceph_monc_do_statfs()
704 req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 64, GFP_NOFS, true); in ceph_monc_do_statfs()
705 if (!req->reply) in ceph_monc_do_statfs()
708 req->u.st = buf; in ceph_monc_do_statfs()
709 req->request->hdr.version = cpu_to_le16(2); in ceph_monc_do_statfs()
711 mutex_lock(&monc->mutex); in ceph_monc_do_statfs()
714 h = req->request->front.iov_base; in ceph_monc_do_statfs()
715 h->monhdr.have_version = 0; in ceph_monc_do_statfs()
716 h->monhdr.session_mon = cpu_to_le16(-1); in ceph_monc_do_statfs()
717 h->monhdr.session_mon_tid = 0; in ceph_monc_do_statfs()
718 h->fsid = monc->monmap->fsid; in ceph_monc_do_statfs()
719 h->contains_data_pool = (data_pool != CEPH_NOPOOL); in ceph_monc_do_statfs()
720 h->data_pool = cpu_to_le64(data_pool); in ceph_monc_do_statfs()
722 mutex_unlock(&monc->mutex); in ceph_monc_do_statfs()
735 u64 tid = le64_to_cpu(msg->hdr.tid); in handle_get_version_reply()
736 void *p = msg->front.iov_base; in handle_get_version_reply()
737 void *end = p + msg->front_alloc_len; in handle_get_version_reply() local
742 ceph_decode_need(&p, end, 2*sizeof(u64), bad); in handle_get_version_reply()
747 mutex_lock(&monc->mutex); in handle_get_version_reply()
748 req = lookup_generic_request(&monc->generic_request_tree, handle); in handle_get_version_reply()
750 mutex_unlock(&monc->mutex); in handle_get_version_reply()
754 req->result = 0; in handle_get_version_reply()
755 req->u.newest = ceph_decode_64(&p); in handle_get_version_reply()
757 mutex_unlock(&monc->mutex); in handle_get_version_reply()
777 req->request = ceph_msg_new(CEPH_MSG_MON_GET_VERSION, in __ceph_monc_get_version()
780 if (!req->request) in __ceph_monc_get_version()
783 req->reply = ceph_msg_new(CEPH_MSG_MON_GET_VERSION_REPLY, 32, GFP_NOIO, in __ceph_monc_get_version()
785 if (!req->reply) in __ceph_monc_get_version()
788 req->complete_cb = cb; in __ceph_monc_get_version()
789 req->private_data = private_data; in __ceph_monc_get_version()
791 mutex_lock(&monc->mutex); in __ceph_monc_get_version()
794 void *p = req->request->front.iov_base; in __ceph_monc_get_version()
795 void *const end = p + req->request->front_alloc_len; in __ceph_monc_get_version() local
797 ceph_encode_64(&p, req->tid); /* handle */ in __ceph_monc_get_version()
798 ceph_encode_string(&p, end, what, strlen(what)); in __ceph_monc_get_version()
799 WARN_ON(p != end); in __ceph_monc_get_version()
802 mutex_unlock(&monc->mutex); in __ceph_monc_get_version()
808 return ERR_PTR(-ENOMEM); in __ceph_monc_get_version()
828 *newest = req->u.newest; in ceph_monc_get_version()
858 void *p = msg->front.iov_base; in handle_command_ack()
859 void *const end = p + msg->front_alloc_len; in handle_command_ack() local
860 u64 tid = le64_to_cpu(msg->hdr.tid); in handle_command_ack()
864 ceph_decode_need(&p, end, sizeof(struct ceph_mon_request_header) + in handle_command_ack()
868 mutex_lock(&monc->mutex); in handle_command_ack()
869 req = lookup_generic_request(&monc->generic_request_tree, tid); in handle_command_ack()
871 mutex_unlock(&monc->mutex); in handle_command_ack()
875 req->result = ceph_decode_32(&p); in handle_command_ack()
877 mutex_unlock(&monc->mutex); in handle_command_ack()
892 int ret = -ENOMEM; in ceph_monc_blacklist_add()
899 req->request = ceph_msg_new(CEPH_MSG_MON_COMMAND, 256, GFP_NOIO, true); in ceph_monc_blacklist_add()
900 if (!req->request) in ceph_monc_blacklist_add()
903 req->reply = ceph_msg_new(CEPH_MSG_MON_COMMAND_ACK, 512, GFP_NOIO, in ceph_monc_blacklist_add()
905 if (!req->reply) in ceph_monc_blacklist_add()
908 mutex_lock(&monc->mutex); in ceph_monc_blacklist_add()
910 h = req->request->front.iov_base; in ceph_monc_blacklist_add()
911 h->monhdr.have_version = 0; in ceph_monc_blacklist_add()
912 h->monhdr.session_mon = cpu_to_le16(-1); in ceph_monc_blacklist_add()
913 h->monhdr.session_mon_tid = 0; in ceph_monc_blacklist_add()
914 h->fsid = monc->monmap->fsid; in ceph_monc_blacklist_add()
915 h->num_strs = cpu_to_le32(1); in ceph_monc_blacklist_add()
916 len = sprintf(h->str, "{ \"prefix\": \"osd blacklist\", \ in ceph_monc_blacklist_add()
919 &client_addr->in_addr, le32_to_cpu(client_addr->nonce)); in ceph_monc_blacklist_add()
920 h->str_len = cpu_to_le32(len); in ceph_monc_blacklist_add()
922 mutex_unlock(&monc->mutex); in ceph_monc_blacklist_add()
932 ret = ceph_wait_for_latest_osdmap(monc->client, 0); in ceph_monc_blacklist_add()
948 for (p = rb_first(&monc->generic_request_tree); p; p = rb_next(p)) { in __resend_generic_request()
950 ceph_msg_revoke(req->request); in __resend_generic_request()
951 ceph_msg_revoke_incoming(req->reply); in __resend_generic_request()
952 ceph_con_send(&monc->con, ceph_msg_get(req->request)); in __resend_generic_request()
967 mutex_lock(&monc->mutex); in delayed_work()
968 if (monc->hunting) { in delayed_work()
972 int is_auth = ceph_auth_is_authenticated(monc->auth); in delayed_work()
973 if (ceph_con_keepalive_expired(&monc->con, in delayed_work()
980 if (!monc->hunting) { in delayed_work()
981 ceph_con_keepalive(&monc->con); in delayed_work()
987 !(monc->con.peer_features & CEPH_FEATURE_MON_STATEFUL_SUB)) { in delayed_work()
991 __func__, now, monc->sub_renew_after); in delayed_work()
992 if (time_after_eq(now, monc->sub_renew_after)) in delayed_work()
997 mutex_unlock(&monc->mutex); in delayed_work()
1006 struct ceph_options *opt = monc->client->options; in build_initial_monmap()
1007 struct ceph_entity_addr *mon_addr = opt->mon_addr; in build_initial_monmap()
1008 int num_mon = opt->num_mon; in build_initial_monmap()
1012 monc->monmap = kzalloc(struct_size(monc->monmap, mon_inst, num_mon), in build_initial_monmap()
1014 if (!monc->monmap) in build_initial_monmap()
1015 return -ENOMEM; in build_initial_monmap()
1017 monc->monmap->mon_inst[i].addr = mon_addr[i]; in build_initial_monmap()
1018 monc->monmap->mon_inst[i].addr.nonce = 0; in build_initial_monmap()
1019 monc->monmap->mon_inst[i].name.type = in build_initial_monmap()
1021 monc->monmap->mon_inst[i].name.num = cpu_to_le64(i); in build_initial_monmap()
1023 monc->monmap->num_mon = num_mon; in build_initial_monmap()
1033 monc->client = cl; in ceph_monc_init()
1034 monc->monmap = NULL; in ceph_monc_init()
1035 mutex_init(&monc->mutex); in ceph_monc_init()
1043 monc->auth = ceph_auth_init(cl->options->name, in ceph_monc_init()
1044 cl->options->key); in ceph_monc_init()
1045 if (IS_ERR(monc->auth)) { in ceph_monc_init()
1046 err = PTR_ERR(monc->auth); in ceph_monc_init()
1049 monc->auth->want_keys = in ceph_monc_init()
1054 err = -ENOMEM; in ceph_monc_init()
1055 monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK, in ceph_monc_init()
1058 if (!monc->m_subscribe_ack) in ceph_monc_init()
1061 monc->m_subscribe = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 128, in ceph_monc_init()
1063 if (!monc->m_subscribe) in ceph_monc_init()
1066 monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, in ceph_monc_init()
1068 if (!monc->m_auth_reply) in ceph_monc_init()
1071 monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, GFP_KERNEL, true); in ceph_monc_init()
1072 monc->pending_auth = 0; in ceph_monc_init()
1073 if (!monc->m_auth) in ceph_monc_init()
1076 ceph_con_init(&monc->con, monc, &mon_con_ops, in ceph_monc_init()
1077 &monc->client->msgr); in ceph_monc_init()
1079 monc->cur_mon = -1; in ceph_monc_init()
1080 monc->had_a_connection = false; in ceph_monc_init()
1081 monc->hunt_mult = 1; in ceph_monc_init()
1083 INIT_DELAYED_WORK(&monc->delayed_work, delayed_work); in ceph_monc_init()
1084 monc->generic_request_tree = RB_ROOT; in ceph_monc_init()
1085 monc->last_tid = 0; in ceph_monc_init()
1087 monc->fs_cluster_id = CEPH_FS_CLUSTER_ID_NONE; in ceph_monc_init()
1092 ceph_msg_put(monc->m_auth_reply); in ceph_monc_init()
1094 ceph_msg_put(monc->m_subscribe); in ceph_monc_init()
1096 ceph_msg_put(monc->m_subscribe_ack); in ceph_monc_init()
1098 ceph_auth_destroy(monc->auth); in ceph_monc_init()
1100 kfree(monc->monmap); in ceph_monc_init()
1109 cancel_delayed_work_sync(&monc->delayed_work); in ceph_monc_stop()
1111 mutex_lock(&monc->mutex); in ceph_monc_stop()
1113 monc->cur_mon = -1; in ceph_monc_stop()
1114 mutex_unlock(&monc->mutex); in ceph_monc_stop()
1118 * - any work that references our embedded con is finished. in ceph_monc_stop()
1119 * - any osd_client or other work that may reference an authorizer in ceph_monc_stop()
1124 ceph_auth_destroy(monc->auth); in ceph_monc_stop()
1126 WARN_ON(!RB_EMPTY_ROOT(&monc->generic_request_tree)); in ceph_monc_stop()
1128 ceph_msg_put(monc->m_auth); in ceph_monc_stop()
1129 ceph_msg_put(monc->m_auth_reply); in ceph_monc_stop()
1130 ceph_msg_put(monc->m_subscribe); in ceph_monc_stop()
1131 ceph_msg_put(monc->m_subscribe_ack); in ceph_monc_stop()
1133 kfree(monc->monmap); in ceph_monc_stop()
1139 if (monc->hunting) { in finish_hunting()
1140 dout("%s found mon%d\n", __func__, monc->cur_mon); in finish_hunting()
1141 monc->hunting = false; in finish_hunting()
1142 monc->had_a_connection = true; in finish_hunting()
1154 mutex_lock(&monc->mutex); in handle_auth_reply()
1155 was_auth = ceph_auth_is_authenticated(monc->auth); in handle_auth_reply()
1156 monc->pending_auth = 0; in handle_auth_reply()
1157 ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base, in handle_auth_reply()
1158 msg->front.iov_len, in handle_auth_reply()
1159 monc->m_auth->front.iov_base, in handle_auth_reply()
1160 monc->m_auth->front_alloc_len); in handle_auth_reply()
1169 monc->client->auth_err = ret; in handle_auth_reply()
1170 } else if (!was_auth && ceph_auth_is_authenticated(monc->auth)) { in handle_auth_reply()
1173 monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT; in handle_auth_reply()
1174 monc->client->msgr.inst.name.num = in handle_auth_reply()
1175 cpu_to_le64(monc->auth->global_id); in handle_auth_reply()
1180 pr_info("mon%d %s session established\n", monc->cur_mon, in handle_auth_reply()
1181 ceph_pr_addr(&monc->con.peer_addr.in_addr)); in handle_auth_reply()
1185 mutex_unlock(&monc->mutex); in handle_auth_reply()
1186 if (monc->client->auth_err < 0) in handle_auth_reply()
1187 wake_up_all(&monc->client->auth_wq); in handle_auth_reply()
1194 if (monc->pending_auth) in __validate_auth()
1197 ret = ceph_build_auth(monc->auth, monc->m_auth->front.iov_base, in __validate_auth()
1198 monc->m_auth->front_alloc_len); in __validate_auth()
1209 mutex_lock(&monc->mutex); in ceph_monc_validate_auth()
1211 mutex_unlock(&monc->mutex); in ceph_monc_validate_auth()
1221 struct ceph_mon_client *monc = con->private; in dispatch()
1222 int type = le16_to_cpu(msg->hdr.type); in dispatch()
1253 ceph_osdc_handle_map(&monc->client->osdc, msg); in dispatch()
1258 if (monc->client->extra_mon_dispatch && in dispatch()
1259 monc->client->extra_mon_dispatch(monc->client, msg) == 0) in dispatch()
1275 struct ceph_mon_client *monc = con->private; in mon_alloc_msg()
1276 int type = le16_to_cpu(hdr->type); in mon_alloc_msg()
1277 int front_len = le32_to_cpu(hdr->front_len); in mon_alloc_msg()
1284 m = ceph_msg_get(monc->m_subscribe_ack); in mon_alloc_msg()
1290 m = ceph_msg_get(monc->m_auth_reply); in mon_alloc_msg()
1293 if (le64_to_cpu(hdr->tid) != 0) in mon_alloc_msg()
1298 * request had a non-zero tid. Work around this weirdness in mon_alloc_msg()
1308 return NULL; /* ENOMEM--return skip == 0 */ in mon_alloc_msg()
1315 } else if (front_len > m->front_alloc_len) { in mon_alloc_msg()
1316 pr_warn("mon_alloc_msg front %d > prealloc %d (%u#%llu)\n", in mon_alloc_msg()
1317 front_len, m->front_alloc_len, in mon_alloc_msg()
1318 (unsigned int)con->peer_name.type, in mon_alloc_msg()
1319 le64_to_cpu(con->peer_name.num)); in mon_alloc_msg()
1333 struct ceph_mon_client *monc = con->private; in mon_fault()
1335 mutex_lock(&monc->mutex); in mon_fault()
1336 dout("%s mon%d\n", __func__, monc->cur_mon); in mon_fault()
1337 if (monc->cur_mon >= 0) { in mon_fault()
1338 if (!monc->hunting) { in mon_fault()
1346 mutex_unlock(&monc->mutex); in mon_fault()