Motr  M0
interface.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
38 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_HA
39 #include "lib/trace.h"
40 
41 #include "ha/halon/interface.h"
42 
43 #include <stdlib.h> /* calloc */
44 
45 #include "lib/types.h" /* m0_bcount_t */
46 #include "lib/misc.h" /* M0_IS0 */
47 #include "lib/memory.h" /* M0_ALLOC_PTR */
48 #include "lib/bob.h" /* M0_BOB_DEFINE */
49 #include "lib/errno.h" /* ENOSYS */
50 #include "lib/string.h" /* strcmp */
51 #include "lib/uuid.h" /* m0_node_uuid_string_set */
52 #include "lib/thread.h" /* m0_process */
53 
54 #include "net/net.h" /* M0_NET_TM_RECV_QUEUE_DEF_LEN */
55 #include "net/buffer_pool.h" /* m0_net_buffer_pool */
56 #include "fid/fid.h" /* m0_fid */
57 #include "module/instance.h" /* m0 */
58 #include "reqh/reqh.h" /* m0_reqh */
59 #include "reqh/reqh_service.h" /* m0_reqh_service_setup */
60 #include "rpc/rpc.h" /* m0_rpc_bufs_nr */
61 #include "rpc/rpc_machine.h" /* m0_rpc_machine */
62 #include "sm/sm.h" /* m0_sm */
63 #include "rm/rm_service.h" /* m0_rms_type */
64 #include "spiel/spiel.h" /* m0_spiel */
65 #include "cm/cm.h" /* m0_sns_cm_repair_trigger_fop_init */
66 #include "conf/ha.h" /* m0_conf_ha_service_event_post */
67 #include "conf/obj.h" /* M0_CONF_PROCESS_TYPE */
68 
69 #include "motr/init.h" /* m0_init */
70 #include "motr/magic.h" /* M0_HALON_INTERFACE_MAGIC */
71 #include "motr/version.h" /* m0_build_info_get */
72 
73 #include "ha/msg.h" /* m0_ha_msg_debug_print */
74 #include "ha/ha.h" /* m0_ha */
75 #include "ha/entrypoint_fops.h" /* m0_ha_entrypoint_req */
76 #include "ha/dispatcher.h" /* m0_ha_dispatcher */
77 #include "ha/note.h" /* M0_HA_NVEC_SET */
78 
79 
80 enum {
83 };
84 
86  const char *hic_build_git_rev_id;
95  const struct m0_uint128 *req_id,
96  const char *remote_rpc_endpoint,
97  const struct m0_fid *process_fid,
98  const char *git_rev_id,
99  uint64_t pid,
100  bool first_request);
101  void (*hic_msg_received_cb)
103  struct m0_ha_link *hl,
104  const struct m0_ha_msg *msg,
105  uint64_t tag);
108  struct m0_ha_link *hl,
109  uint64_t tag);
112  struct m0_ha_link *hl,
113  uint64_t tag);
114  void (*hic_link_connected_cb)
116  const struct m0_uint128 *req_id,
117  struct m0_ha_link *link);
118  void (*hic_link_reused_cb)
120  const struct m0_uint128 *req_id,
121  struct m0_ha_link *link);
122  void (*hic_link_absent_cb)
124  const struct m0_uint128 *req_id);
127  struct m0_ha_link *link);
130  struct m0_ha_link *link);
131 
132  uint32_t hic_tm_nr;
133  uint32_t hic_bufs_nr;
134  uint32_t hic_colour;
136  uint32_t hic_queue_len;
142 };
143 
162 };
163 
169 };
170 
173  struct m0 hii_instance;
180  struct m0_ha hii_ha;
183  struct m0_sm hii_sm;
184  uint64_t hii_magix;
188  uint64_t hii_nvec_size;
190 };
191 
192 static const struct m0_bob_type halon_interface_bob_type = {
193  .bt_name = "halon interface",
194  .bt_magix_offset = M0_MAGIX_OFFSET(struct m0_halon_interface_internal,
195  hii_magix),
196  .bt_magix = M0_HALON_INTERFACE_MAGIC,
197 };
199 
200 static bool
202  const char *build_git_rev_id,
203  const char *build_configure_opts,
204  bool disable_compat_check)
205 {
206  const struct m0_build_info *bi = m0_build_info_get();
207 
208  M0_ENTRY("build_git_rev_id=%s build_configure_opts=%s "
209  "disable_compat_check=%d", build_git_rev_id,
210  build_configure_opts, !!disable_compat_check);
211  if (disable_compat_check)
212  return true;
213  if (!m0_streq(bi->bi_git_rev_id, build_git_rev_id)) {
214  M0_LOG(M0_ERROR, "The loaded motr library (%s) "
215  "is not the expected one (%s)", bi->bi_git_rev_id,
216  build_git_rev_id);
217  return false;
218  }
219  if (!m0_streq(bi->bi_configure_opts, build_configure_opts)) {
220  M0_LOG(M0_ERROR, "The configuration options of the loaded "
221  "motr library (%s) do not match the expected ones (%s)",
222  bi->bi_configure_opts, build_configure_opts);
223  return false;
224  }
225  return true;
226 }
227 
228 static void
230  const char *debug_options)
231 {
232  struct m0_halon_interface_cfg *hi_cfg = &hi->hif_internal->hii_cfg;
233 
234  M0_ENTRY("hi=%p debug_options=%s", hi, debug_options);
235 
236  if (debug_options == NULL)
237  return;
238  hi_cfg->hic_log_entrypoint = strstr(debug_options, "log-entrypoint")
239  != NULL;
240  hi_cfg->hic_log_link = strstr(debug_options, "log-link") != NULL;
241  hi_cfg->hic_log_msg = strstr(debug_options, "log-msg") != NULL;
242 }
243 
244 static struct m0_halon_interface_internal *
246 {
247  struct m0_halon_interface_internal *hii;
248 
249  hii = bob_of(ha, struct m0_halon_interface_internal, hii_ha,
251  M0_ASSERT(m0_get() == &hii->hii_instance);
252  return hii;
253 }
254 
255 static void
257  struct m0_ha_msg *msg)
258 {
259  struct m0_ha_msg_nvec *nvec;
260  struct m0_ha_note *note;
261  uint64_t i;
262  uint64_t j;
263  bool just_added;
264 
266  return;
267  nvec = &msg->hm_data.u.hed_nvec;
268  if (nvec->hmnv_type != M0_HA_NVEC_SET)
269  return;
270  for (i = 0; i < nvec->hmnv_nr; ++i) {
271  note = &nvec->hmnv_arr.hmna_arr[i];
272  if (m0_fid_tget(&note->no_id) ==
274  /*
275  * XXX Detect HA state duplications here and ignore the
276  * note if HA state for the process doesn't change.
277  * This allows Hare to be simple and always send as many
278  * HA states as it wants without worrying about sending
279  * each state only once.
280  *
281  * The duplicate detection code has to be removed after
282  * Hare can send states in a proper way.
283  */
284  for (j = 0; j < hii->hii_nvec_size; ++j) {
285  if (m0_fid_eq(&note->no_id,
286  &hii->hii_nvec[j].no_id))
287  break;
288  }
289  just_added = false;
290  if (j == hii->hii_nvec_size) {
292  ARRAY_SIZE(hii->hii_nvec),
293  "Currently we don't support "
294  "more than %zu processes "
295  "connected to a single "
296  "m0_halon_interface.",
297  ARRAY_SIZE(hii->hii_nvec));
298  hii->hii_nvec[hii->hii_nvec_size] =
299  (struct m0_ha_note){
300  .no_id = note->no_id,
301  .no_state = M0_NC_UNKNOWN,
302  };
303  M0_LOG(M0_DEBUG, "hii_nvec[%" PRIu64 "] = "
304  "{.no_id = "FID_F", ...}",
305  hii->hii_nvec_size,
306  FID_P(&hii->hii_nvec[
307  hii->hii_nvec_size].no_id));
308  ++hii->hii_nvec_size;
309  just_added = true;
310  }
311  /*
312  * Ignore process state if it hasn't changed and the
313  * hmnv_ignore_same_state flag is set.
314  */
315  if (note->no_state == hii->hii_nvec[j].no_state &&
316  nvec->hmnv_ignore_same_state) {
317  M0_LOG(M0_DEBUG, "ignoring the same state for "
318  FID_F, FID_P(&note->no_id));
319  continue;
320  }
321  if (note->no_state == M0_NC_FAILED) {
322  if (just_added) {
324  "Ignoring M0_NC_FAILED as "
325  "it's the 1st notification "
326  "for no_id="FID_F,
327  FID_P(&note->no_id));
328  } else {
329  M0_LOG(M0_DEBUG, "no_id="FID_F,
330  FID_P(&note->no_id));
331  if (hii->hii_cfg.hic_log_link) {
332  M0_LOG(M0_WARN, "disconnecting "
333  "all links to "
334  "no_id="FID_F,
335  FID_P(&note->no_id));
336  }
338  &note->no_id);
339  }
340  }
341  hii->hii_nvec[j].no_state = note->no_state;
342  }
343  }
344 }
345 
346 static void
348  const struct m0_ha_entrypoint_req *req,
349  const struct m0_uint128 *req_id)
350 {
351  struct m0_halon_interface_internal *hii;
352 
353  hii = bob_of(ha, struct m0_halon_interface_internal, hii_ha,
355  M0_ENTRY("hi=%p req=%p req_id="U128X_F" remote_rpc_endpoint=%s "
356  "process_fid="FID_F,
357  hii->hii_hi, req, U128_P(req_id), req->heq_rpc_endpoint,
358  FID_P(&req->heq_process_fid));
359  M0_LOG(M0_DEBUG, "git_rev_id=%s generation=%" PRIu64 " pid=%"PRIu64,
360  req->heq_git_rev_id, req->heq_generation, req->heq_pid);
361  if (hii->hii_cfg.hic_log_entrypoint) {
362  M0_LOG(M0_WARN, "req_id="U128X_F" remote_rpc_endpoint=%s "
363  "process_fid="FID_F" git_rev_id=%s generation=%" PRIu64 " "
364  "pid=%"PRIu64, U128_P(req_id), req->heq_rpc_endpoint,
365  FID_P(&req->heq_process_fid), req->heq_git_rev_id,
366  req->heq_generation, req->heq_pid);
367  }
368  hii->hii_cfg.hic_entrypoint_request_cb(hii->hii_hi, req_id,
369  req->heq_rpc_endpoint,
370  &req->heq_process_fid,
371  req->heq_git_rev_id,
372  req->heq_pid,
373  req->heq_first_request);
374  M0_LEAVE();
375 }
376 
377 static void
379  struct m0_ha_entrypoint_rep *rep)
380 {
382 
383  M0_ENTRY("hii=%p ha=%p rep=%p", hii, ha, rep);
384  /*
385  * Nothing to do here for now.
386  * In the future some default handler should be called.
387  */
388  M0_LEAVE();
389 }
390 
391 static void halon_interface_msg_received_cb(struct m0_ha *ha,
392  struct m0_ha_link *hl,
393  struct m0_ha_msg *msg,
394  uint64_t tag)
395 {
398  const char *ep = &buf[0];
399 
401  M0_ENTRY("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%"PRIu64,
402  hii->hii_hi, &hii->hii_ha, hl, ep, msg, msg->hm_epoch, tag);
403  m0_ha_msg_debug_print(msg, __func__);
404  if (hl != hii->hii_outgoing_link) {
405  if (hii->hii_cfg.hic_log_msg) {
406  M0_LOG(M0_WARN, "hl=%p ep=%s epoch=%" PRIu64 " "
407  "tag=%" PRIu64 " type=%"PRIu64,
408  hl, ep, msg->hm_epoch, tag,
409  msg->hm_data.hed_type);
410  }
411  hii->hii_cfg.hic_msg_received_cb(hii->hii_hi, hl, msg, tag);
412  } else {
413  m0_ha_dispatcher_handle(&hii->hii_dispatcher, ha, hl, msg, tag);
415  m0_ha_delivered(ha, hl, msg);
416  }
417  M0_LEAVE("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%"PRIu64,
418  hii->hii_hi, &hii->hii_ha, hl, ep, msg, msg->hm_epoch, tag);
419 }
420 
422  struct m0_ha_link *hl,
423  uint64_t tag)
424 {
427  const char *ep = &buf[0];
428 
430  M0_ENTRY("hii=%p ha=%p hl=%p ep=%s tag=%"PRIu64, hii, ha, hl, ep, tag);
431  if (hl != hii->hii_outgoing_link) {
432  if (hii->hii_cfg.hic_log_msg)
433  M0_LOG(M0_WARN, "hl=%p ep=%s tag=%"PRIu64, hl, ep, tag);
434  hii->hii_cfg.hic_msg_is_delivered_cb(hii->hii_hi, hl, tag);
435  }
436  M0_LEAVE("hii=%p ha=%p hl=%p ep=%s tag=%"PRIu64, hii, ha, hl, ep, tag);
437 }
438 
440  struct m0_ha_link *hl,
441  uint64_t tag)
442 {
445  const char *ep = &buf[0];
446 
448  M0_ENTRY("hii=%p ha=%p hl=%p ep=%s tag=%"PRIu64, hii, ha, hl, ep, tag);
449  if (hl != hii->hii_outgoing_link) {
450  if (hii->hii_cfg.hic_log_msg)
451  M0_LOG(M0_WARN, "hl=%p ep=%s tag=%"PRIu64, hl, ep, tag);
453  }
454  M0_LEAVE("hii=%p ha=%p hl=%p ep=%s tag=%"PRIu64, hii, ha, hl, ep, tag);
455 }
456 
458  const struct m0_uint128 *req_id,
459  struct m0_ha_link *hl)
460 {
463  const char *ep = &buf[0];
464 
466  M0_ENTRY("hii=%p ha=%p req_id="U128X_F" hl=%p ep=%s", hii, ha,
467  U128_P(req_id), hl, ep);
468  if (hii->hii_cfg.hic_log_link) {
469  M0_LOG(M0_WARN, "req_id="U128X_F" hl=%p ep=%s",
470  U128_P(req_id), hl, ep);
471  }
472  hii->hii_cfg.hic_link_connected_cb(hii->hii_hi, req_id, hl);
473  M0_LEAVE("hii=%p ha=%p req_id="U128X_F" hl=%p ep=%s", hii, ha,
474  U128_P(req_id), hl, ep);
475 }
476 
477 static void halon_interface_link_reused_cb(struct m0_ha *ha,
478  const struct m0_uint128 *req_id,
479  struct m0_ha_link *hl)
480 {
483  const char *ep = &buf[0];
484 
486  M0_ENTRY("hii=%p ha=%p req_id="U128X_F" hl=%p ep=%s", hii, ha,
487  U128_P(req_id), hl, ep);
488  if (hii->hii_cfg.hic_log_link) {
489  M0_LOG(M0_WARN, "req_id="U128X_F" hl=%p ep=%s",
490  U128_P(req_id), hl, ep);
491  }
492  hii->hii_cfg.hic_link_reused_cb(hii->hii_hi, req_id, hl);
493  M0_LEAVE("hii=%p ha=%p req_id="U128X_F" hl=%p ep=%s", hii, ha,
494  U128_P(req_id), hl, ep);
495 }
496 
497 static void halon_interface_link_absent_cb(struct m0_ha *ha,
498  const struct m0_uint128 *req_id)
499 {
502  const char *ep = &buf[0];
503 
504  M0_ENTRY("hii=%p ha=%p req_id="U128X_F, hii, ha, U128_P(req_id));
505  if (hii->hii_cfg.hic_log_link) {
506  M0_LOG(M0_WARN, "req_id="U128X_F" ep=%s", U128_P(req_id), ep);
507  }
508  hii->hii_cfg.hic_link_absent_cb(hii->hii_hi, req_id);
509  M0_LEAVE("hii=%p ha=%p req_id="U128X_F, hii, ha, U128_P(req_id));
510 }
511 
513  struct m0_ha_link *hl)
514 {
517  const char *ep = &buf[0];
518 
520  M0_ENTRY("hii=%p ha=%p hl=%p ep=%s", hii, ha, hl, ep);
521  if (hii->hii_cfg.hic_log_link)
522  M0_LOG(M0_WARN, "hl=%p ep=%s", hl, ep);
524  M0_LEAVE("hii=%p ha=%p hl=%p ep=%s", hii, ha, hl, ep);
525 }
526 
528  struct m0_ha_link *hl)
529 {
532  const char *ep = &buf[0];
533 
535  M0_ENTRY("hii=%p ha=%p hl=%p ep=%s", hii, ha, hl, ep);
536  if (hii->hii_cfg.hic_log_link)
537  M0_LOG(M0_WARN, "hl=%p ep=%s", hl, ep);
538  hii->hii_cfg.hic_link_disconnected_cb(hii->hii_hi, hl);
539  M0_LEAVE("hii=%p ha=%p hl=%p ep=%s", hii, ha, hl, ep);
540 }
541 
542 static const struct m0_ha_ops halon_interface_ha_ops = {
544  .hao_entrypoint_replied = &halon_interface_entrypoint_replied_cb,
545  .hao_msg_received = &halon_interface_msg_received_cb,
546  .hao_msg_is_delivered = &halon_interface_msg_is_delivered_cb,
547  .hao_msg_is_not_delivered = &halon_interface_msg_is_not_delivered_cb,
548  .hao_link_connected = &halon_interface_link_connected_cb,
549  .hao_link_reused = &halon_interface_link_reused_cb,
550  .hao_link_absent = &halon_interface_link_absent_cb,
551  .hao_link_is_disconnecting = &halon_interface_link_is_disconnecting_cb,
552  .hao_link_disconnected = &halon_interface_link_disconnected_cb,
553 };
554 
558  .sd_name = "M0_HALON_INTERFACE_STATE_UNINITIALISED",
560  },
562  .sd_name = "M0_HALON_INTERFACE_STATE_INITIALISED",
565  },
567  .sd_name = "M0_HALON_INTERFACE_STATE_WORKING",
569  },
571  .sd_flags = M0_SDF_TERMINAL,
572  .sd_name = "M0_HALON_INTERFACE_STATE_FINALISED",
573  .sd_allowed = 0,
574  },
575 };
576 
578  .scf_name = "m0_halon_interface_internal::hii_sm",
579  .scf_nr_states = ARRAY_SIZE(halon_interface_states),
580  .scf_state = halon_interface_states,
581 };
582 
584  const char *build_git_rev_id,
585  const char *build_configure_opts,
586  const char *debug_options,
587  const char *node_uuid)
588 {
589  struct m0_halon_interface_internal *hii;
590  bool disable_compat_check;
591  int rc;
592 
593  disable_compat_check = debug_options != NULL &&
594  strstr(debug_options, "disable-compatibility-check") != NULL;
595  if (!halon_interface_is_compatible(NULL, build_git_rev_id,
596  build_configure_opts,
597  disable_compat_check))
598  return M0_ERR(-EINVAL);
599 
600  /* M0_ALLOC_PTR() can't be used before m0_init() */
601  *hi_out = calloc(1, sizeof **hi_out);
602  hii = calloc(1, sizeof *hii);
603  if (*hi_out == NULL || hii == NULL) {
604  free(*hi_out);
605  free(hii);
606  return M0_ERR(-ENOMEM);
607  }
608  (*hi_out)->hif_internal = hii;
609  (*hi_out)->hif_internal->hii_hi = *hi_out;
610  m0_halon_interface_internal_bob_init(hii);
612  rc = m0_init(&hii->hii_instance);
613  if (rc != 0) {
614  free(hii);
615  return M0_ERR(rc);
616  }
617  halon_interface_parse_debug_options(*hi_out, debug_options);
624  return M0_RC(0);
625 }
626 
628 {
629  struct m0_halon_interface_internal *hii;
630 
631  M0_ENTRY("hi=%p", hi);
632 
633  hii = hi->hif_internal;
636  m0_sm_fini(&hii->hii_sm);
639  m0_fini();
640  m0_halon_interface_internal_bob_fini(hii);
641  free(hii);
642  M0_LEAVE();
643 }
644 
645 static void
647  enum m0_conf_ha_process_event event)
648 {
650  &hii->hii_cfg.hic_process_fid,
651  m0_process(), event,
653 }
654 
655 static void
657  enum m0_conf_ha_service_event event)
658 {
660  &hii->hii_cfg.hic_process_fid,
663  m0_process(),
664  event, M0_CST_HA);
665 }
666 
667 static const struct m0_modlev halon_interface_levels[];
668 
669 static int halon_interface_level_enter(struct m0_module *module)
670 {
671  struct m0_halon_interface_internal *hii;
672  enum m0_halon_interface_level level = module->m_cur + 1;
673 
674  hii = bob_of(module, struct m0_halon_interface_internal, hii_module,
676  M0_ENTRY("hii=%p level=%d %s", hii, level,
677  halon_interface_levels[level].ml_name);
678  switch (level) {
680  /*
681  * Zero all data structures initialised later to allow
682  * m0_halon_interface_start() after m0_halon_interface_stop().
683  */
684  M0_SET0(&hii->hii_net_domain);
686  M0_SET0(&hii->hii_reqh);
687  M0_SET0(&hii->hii_rpc_machine);
688  M0_SET0(&hii->hii_ha);
689  M0_SET0(&hii->hii_dispatcher);
690  hii->hii_outgoing_link = NULL;
691  hii->hii_rm_service = NULL;
692  M0_SET0(&hii->hii_spiel);
693  hii->hii_nvec_size = 0;
694 
695  hii->hii_cfg.hic_tm_nr = 1;
696  hii->hii_cfg.hic_bufs_nr = 100;
698  hii->hii_cfg.hic_max_msg_size = 1UL << 17;
699  hii->hii_cfg.hic_queue_len = 100;
700  hii->hii_cfg.hic_ha_cfg = (struct m0_ha_cfg){
702  .hcf_rpc_machine = &hii->hii_rpc_machine,
703  .hcf_addr = hii->hii_cfg.hic_local_rpc_endpoint,
704  .hcf_reqh = &hii->hii_reqh,
705  .hcf_process_fid = hii->hii_cfg.hic_process_fid,
706  };
708  .hdc_enable_note = true,
709  .hdc_enable_keepalive = true,
710  .hdc_enable_fvec = true,
711  };
712  return M0_RC(0);
718  &hii->hii_net_domain, &hii->hii_net_buffer_pool,
719  hii->hii_cfg.hic_bufs_nr,
720  hii->hii_cfg.hic_tm_nr));
722  return M0_RC(M0_REQH_INIT(&hii->hii_reqh,
723  .rhia_dtm = (void*)1,
724  .rhia_mdstore = (void*)1,
725  .rhia_fid =
726  &hii->hii_cfg.hic_process_fid));
728  m0_reqh_start(&hii->hii_reqh);
729  return M0_RC(0);
731  return M0_RC(m0_rpc_machine_init(
732  &hii->hii_rpc_machine, &hii->hii_net_domain,
734  &hii->hii_reqh, &hii->hii_net_buffer_pool,
735  hii->hii_cfg.hic_colour,
737  hii->hii_cfg.hic_queue_len));
739  return M0_RC(m0_ha_init(&hii->hii_ha,
740  &hii->hii_cfg.hic_ha_cfg));
743  &hii->hii_cfg.hic_dispatcher_cfg));
745  return M0_RC(m0_ha_start(&hii->hii_ha));
747  hii->hii_outgoing_link = m0_ha_connect(&hii->hii_ha);
748  M0_LOG(M0_DEBUG, "hii_outgoing_link=%p",
749  hii->hii_outgoing_link);
750  return hii->hii_outgoing_link == NULL ? M0_ERR(-EINVAL) :
751  M0_RC(0);
753  M0_ASSERT(m0_get()->i_ha == NULL);
754  M0_ASSERT(m0_get()->i_ha_link == NULL);
755  m0_get()->i_ha = &hii->hii_ha;
757  return M0_RC(0);
762  return M0_RC(0);
765  &m0_rms_type,
766  &hii->hii_reqh, NULL,
767  &hii->hii_cfg.hic_rm_service_fid));
769  return M0_RC(m0_spiel_init(&hii->hii_spiel, &hii->hii_reqh));
773  return M0_RC(0);
776  /*
777  For HAX daemon, M0_NC_DTM_RECOVERING state is transient,
778  sending M0_CONF_HA_PROCESS_DTM_RECOVERED just after
779  M0_CONF_HA_PROCESS_STARTED.
780 
781  halon_interface_process_event(hii,
782  M0_CONF_HA_PROCESS_DTM_RECOVERED);
783  */
784  return M0_RC(0);
786  return M0_ERR(-ENOSYS);
787  }
788  return M0_ERR(-ENOSYS);
789 }
790 
791 static void halon_interface_level_leave(struct m0_module *module)
792 {
793  struct m0_halon_interface_internal *hii;
794  enum m0_halon_interface_level level = module->m_cur;
795 
796  hii = bob_of(module, struct m0_halon_interface_internal, hii_module,
798  M0_ENTRY("hii=%p level=%d", hii, level);
799  switch (level) {
801  break;
804  break;
807  break;
809  m0_reqh_fini(&hii->hii_reqh);
810  break;
813  break;
817  break;
819  m0_ha_fini(&hii->hii_ha);
820  break;
823  break;
825  m0_ha_stop(&hii->hii_ha);
826  break;
829  m0_ha_disconnect(&hii->hii_ha);
830  break;
832  M0_ASSERT(m0_get()->i_ha == &hii->hii_ha);
833  M0_ASSERT(m0_get()->i_ha_link == hii->hii_outgoing_link);
834  m0_get()->i_ha = NULL;
835  m0_get()->i_ha_link = NULL;
836  break;
841  break;
844  break;
846  m0_spiel_fini(&hii->hii_spiel);
847  break;
851  break;
854  break;
856  M0_IMPOSSIBLE("can't be here");
857  break;
858  }
859  M0_LEAVE();
860 }
861 
862 static const struct m0_modlev halon_interface_levels[] = {
864  .ml_name = "M0_HALON_INTERFACE_LEVEL_ASSIGNS",
865  .ml_enter = halon_interface_level_enter,
866  .ml_leave = halon_interface_level_leave,
867  },
869  .ml_name = "M0_HALON_INTERFACE_LEVEL_NET_DOMAIN",
870  .ml_enter = halon_interface_level_enter,
871  .ml_leave = halon_interface_level_leave,
872  },
874  .ml_name = "M0_HALON_INTERFACE_LEVEL_NET_BUFFER_POOL",
875  .ml_enter = halon_interface_level_enter,
876  .ml_leave = halon_interface_level_leave,
877  },
879  .ml_name = "M0_HALON_INTERFACE_LEVEL_REQH_INIT",
880  .ml_enter = halon_interface_level_enter,
881  .ml_leave = halon_interface_level_leave,
882  },
884  .ml_name = "M0_HALON_INTERFACE_LEVEL_REQH_START",
885  .ml_enter = halon_interface_level_enter,
886  .ml_leave = halon_interface_level_leave,
887  },
889  .ml_name = "M0_HALON_INTERFACE_LEVEL_RPC_MACHINE",
890  .ml_enter = halon_interface_level_enter,
891  .ml_leave = halon_interface_level_leave,
892  },
894  .ml_name = "M0_HALON_INTERFACE_LEVEL_HA_INIT",
895  .ml_enter = halon_interface_level_enter,
896  .ml_leave = halon_interface_level_leave,
897  },
899  .ml_name = "M0_HALON_INTERFACE_LEVEL_DISPATCHER",
900  .ml_enter = halon_interface_level_enter,
901  .ml_leave = halon_interface_level_leave,
902  },
904  .ml_name = "M0_HALON_INTERFACE_LEVEL_HA_START",
905  .ml_enter = halon_interface_level_enter,
906  .ml_leave = halon_interface_level_leave,
907  },
909  .ml_name = "M0_HALON_INTERFACE_LEVEL_HA_CONNECT",
910  .ml_enter = halon_interface_level_enter,
911  .ml_leave = halon_interface_level_leave,
912  },
914  .ml_name = "M0_HALON_INTERFACE_LEVEL_INSTANCE_SET",
915  .ml_enter = halon_interface_level_enter,
916  .ml_leave = halon_interface_level_leave,
917  },
919  .ml_name = "M0_HALON_INTERFACE_LEVEL_EVENTS_STARTING",
920  .ml_enter = halon_interface_level_enter,
921  .ml_leave = halon_interface_level_leave,
922  },
924  .ml_name = "M0_HALON_INTERFACE_LEVEL_RM_SETUP",
925  .ml_enter = halon_interface_level_enter,
926  .ml_leave = halon_interface_level_leave,
927  },
929  .ml_name = "M0_HALON_INTERFACE_LEVEL_SPIEL_INIT",
930  .ml_enter = halon_interface_level_enter,
931  .ml_leave = halon_interface_level_leave,
932  },
934  .ml_name = "M0_HALON_INTERFACE_LEVEL_SNS_CM_TRIGGER_FOPS",
935  .ml_enter = halon_interface_level_enter,
936  .ml_leave = halon_interface_level_leave,
937  },
939  .ml_name = "M0_HALON_INTERFACE_LEVEL_EVENTS_STARTED",
940  .ml_enter = halon_interface_level_enter,
941  .ml_leave = halon_interface_level_leave,
942  },
944  .ml_name = "M0_HALON_INTERFACE_LEVEL_STARTED",
945  },
946 };
947 
949  const char *local_rpc_endpoint,
950  const struct m0_fid *process_fid,
951  const struct m0_fid *ha_service_fid,
952  const struct m0_fid *rm_service_fid,
953  void (*entrypoint_request_cb)
954  (struct m0_halon_interface *hi,
955  const struct m0_uint128 *req_id,
956  const char *remote_rpc_endpoint,
957  const struct m0_fid *process_fid,
958  const char *git_rev_id,
959  uint64_t pid,
960  bool first_request),
961  void (*msg_received_cb)
962  (struct m0_halon_interface *hi,
963  struct m0_ha_link *hl,
964  const struct m0_ha_msg *msg,
965  uint64_t tag),
966  void (*msg_is_delivered_cb)
967  (struct m0_halon_interface *hi,
968  struct m0_ha_link *hl,
969  uint64_t tag),
970  void (*msg_is_not_delivered_cb)
971  (struct m0_halon_interface *hi,
972  struct m0_ha_link *hl,
973  uint64_t tag),
974  void (*link_connected_cb)
975  (struct m0_halon_interface *hi,
976  const struct m0_uint128 *req_id,
977  struct m0_ha_link *link),
978  void (*link_reused_cb)
979  (struct m0_halon_interface *hi,
980  const struct m0_uint128 *req_id,
981  struct m0_ha_link *link),
982  void (*link_absent_cb)
983  (struct m0_halon_interface *hi,
984  const struct m0_uint128 *req_id),
985  void (*link_is_disconnecting_cb)
986  (struct m0_halon_interface *hi,
987  struct m0_ha_link *link),
988  void (*link_disconnected_cb)
989  (struct m0_halon_interface *hi,
990  struct m0_ha_link *link))
991 {
992  struct m0_halon_interface_internal *hii = hi->hif_internal;
993  char *ep;
994  int rc;
995 
996  M0_PRE(m0_halon_interface_internal_bob_check(hii));
997  M0_PRE(m0_get() == &hii->hii_instance);
998  M0_PRE(process_fid != NULL);
999  M0_PRE(rm_service_fid != NULL);
1000 
1001  M0_ENTRY("hi=%p local_rpc_endpoint=%s process_fid="FID_F,
1002  hi, local_rpc_endpoint, FID_P(process_fid));
1003  M0_LOG(M0_DEBUG, "hi=%p ha_service_fid="FID_F" rm_service_fid="FID_F,
1004  hi, FID_P(ha_service_fid), FID_P(rm_service_fid));
1005 
1006  ep = m0_strdup(local_rpc_endpoint);
1007  if (ep == NULL)
1008  return M0_ERR(-ENOMEM);
1009 
1012  hii->hii_cfg.hic_ha_service_fid = *ha_service_fid;
1013  hii->hii_cfg.hic_rm_service_fid = *rm_service_fid;
1014  hii->hii_cfg.hic_entrypoint_request_cb = entrypoint_request_cb;
1015  hii->hii_cfg.hic_msg_received_cb = msg_received_cb;
1016  hii->hii_cfg.hic_msg_is_delivered_cb = msg_is_delivered_cb;
1017  hii->hii_cfg.hic_msg_is_not_delivered_cb = msg_is_not_delivered_cb;
1018  hii->hii_cfg.hic_link_connected_cb = link_connected_cb;
1019  hii->hii_cfg.hic_link_reused_cb = link_reused_cb;
1020  hii->hii_cfg.hic_link_absent_cb = link_absent_cb;
1021  hii->hii_cfg.hic_link_is_disconnecting_cb = link_is_disconnecting_cb;
1022  hii->hii_cfg.hic_link_disconnected_cb = link_disconnected_cb;
1023 
1024  m0_module_setup(&hii->hii_module, "m0_halon_interface",
1027  &hii->hii_instance);
1029  if (rc != 0) {
1031  m0_free(ep);
1032  return M0_ERR(rc);
1033  }
1037  return M0_RC(rc);
1038 }
1039 
1041 {
1042  struct m0_halon_interface_internal *hii = hi->hif_internal;
1043 
1044  M0_ASSERT(m0_halon_interface_internal_bob_check(hii));
1045  M0_ASSERT(m0_get() == &hii->hii_instance);
1046 
1047  M0_ENTRY("hi=%p", hi);
1048 
1052 
1055 
1056  M0_LEAVE();
1057 }
1058 
1060  struct m0_halon_interface *hi,
1061  const struct m0_uint128 *req_id,
1062  int rc,
1063  uint32_t confd_nr,
1064  const struct m0_fid *confd_fid_data,
1065  const char **confd_eps_data,
1066  uint32_t confd_quorum,
1067  const struct m0_fid *rm_fid,
1068  const char *rm_eps)
1069 {
1070  struct m0_ha_entrypoint_rep rep;
1071 
1072  M0_ENTRY("hi=%p req_id="U128X_F" rc=%d confd_nr=%"PRIu32" "
1073  "confd_quorum=%"PRIu32" rm_fid="FID_F" rm_eps=%s",
1074  hi, U128_P(req_id), rc, confd_nr, confd_quorum,
1075  FID_P(rm_fid == NULL ? &M0_FID0 : rm_fid), rm_eps);
1076 
1077  if (hi->hif_internal->hii_cfg.hic_log_entrypoint) {
1078  M0_LOG(M0_WARN, "req_id="U128X_F" rc=%d confd_nr=%"PRIu32" "
1079  "confd_quorum=%"PRIu32" rm_fid="FID_F" rm_eps=%s",
1080  U128_P(req_id), rc, confd_nr, confd_quorum,
1081  FID_P(rm_fid == NULL ? &M0_FID0 : rm_fid), rm_eps);
1082  }
1083  rep = (struct m0_ha_entrypoint_rep){
1084  .hae_quorum = confd_quorum,
1085  .hae_confd_fids = {
1086  .af_count = confd_nr,
1087  .af_elems = (struct m0_fid *)confd_fid_data,
1088  },
1089  .hae_confd_eps = confd_eps_data,
1090  .hae_active_rm_fid = rm_fid == NULL ? M0_FID0 : *rm_fid,
1091  .hae_active_rm_ep = (char *)rm_eps,
1094  };
1095  m0_ha_entrypoint_reply(&hi->hif_internal->hii_ha, req_id, &rep, NULL);
1096  M0_LEAVE();
1097 }
1098 
1100  struct m0_ha_link *hl,
1101  const struct m0_ha_msg *msg,
1102  uint64_t *tag)
1103 {
1104  struct m0_halon_interface_internal *hii = hi->hif_internal;
1106  const char *ep = &buf[0];
1107 
1108  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1109  M0_PRE(m0_get() == &hii->hii_instance);
1110 
1111  m0_ha_rpc_endpoint(&hii->hii_ha, hl, buf, ARRAY_SIZE(buf));
1112  M0_ENTRY("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%p",
1113  hi, &hii->hii_ha, hl, ep, msg, msg->hm_epoch, tag);
1114  m0_ha_msg_debug_print(msg, __func__);
1115  m0_ha_send(&hii->hii_ha, hl, msg, tag);
1116  if (hii->hii_cfg.hic_log_msg) {
1117  M0_LOG(M0_WARN, "hl=%p ep=%s epoch=%" PRIu64 " tag=%" PRIu64 " "
1118  "type=%"PRIu64,
1119  hl, ep, msg->hm_epoch, *tag, msg->hm_data.hed_type);
1120  }
1121  M0_LEAVE("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%"PRIu64,
1122  hi, &hii->hii_ha, hl, ep, msg, msg->hm_epoch, *tag);
1123 }
1124 
1126  struct m0_ha_link *hl,
1127  const struct m0_ha_msg *msg)
1128 {
1129  struct m0_halon_interface_internal *hii = hi->hif_internal;
1131  const char *ep = &buf[0];
1132 
1133  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1134  M0_PRE(m0_get() == &hii->hii_instance);
1135 
1136  m0_ha_rpc_endpoint(&hii->hii_ha, hl, buf, ARRAY_SIZE(buf));
1137  M0_ENTRY("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%"PRIu64,
1138  hi, &hii->hii_ha, hl, ep,
1139  msg, msg->hm_epoch, m0_ha_msg_tag(msg));
1140  if (hii->hii_cfg.hic_log_msg) {
1141  M0_LOG(M0_WARN, "hl=%p ep=%s epoch=%" PRIu64 " tag=%" PRIu64 " "
1142  "type=%"PRIu64, hl, ep, msg->hm_epoch, m0_ha_msg_tag(msg),
1143  msg->hm_data.hed_type);
1144  }
1145  /*
1146  * Remove 'const' here.
1147  *
1148  * 'msg' should be the message passed to hic_msg_received_cb().
1149  * halon_interface_msg_received_cb() has non-const msg, the function
1150  * makes the message const. If the 'const' is removed here then no
1151  * harm should be done.
1152  */
1153  m0_ha_delivered(&hii->hii_ha, hl, (struct m0_ha_msg *)msg);
1154  M0_LEAVE("hi=%p ha=%p hl=%p ep=%s msg=%p epoch=%" PRIu64 " tag=%"PRIu64,
1155  hi, &hii->hii_ha, hl, ep,
1156  msg, msg->hm_epoch, m0_ha_msg_tag(msg));
1157 }
1158 
1160  struct m0_ha_link *hl)
1161 {
1162  struct m0_halon_interface_internal *hii = hi->hif_internal;
1164  const char *ep = &buf[0];
1165 
1166  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1167  M0_PRE(m0_get() == &hii->hii_instance);
1168 
1169  m0_ha_rpc_endpoint(&hii->hii_ha, hl, buf, ARRAY_SIZE(buf));
1170  M0_ENTRY("hi=%p ha=%p hl=%p ep=%s", hi, &hii->hii_ha, hl, ep);
1171  if (hii->hii_cfg.hic_log_link)
1172  M0_LOG(M0_WARN, "hl=%p ep=%s", hl, ep);
1173  m0_ha_disconnect_incoming(&hii->hii_ha, hl);
1174  M0_LEAVE("hi=%p ha=%p hl=%p ep=%s", hi, &hii->hii_ha, hl, ep);
1175 }
1176 
1178 {
1179  bool working;
1180 
1184  return working;
1185 }
1186 
1187 struct m0_rpc_machine *
1189 {
1190  struct m0_halon_interface_internal *hii = hi->hif_internal;
1191  struct m0_rpc_machine *rpc_machine;
1192  bool working;
1193 
1194  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1195  M0_PRE(m0_get() == &hii->hii_instance);
1196 
1197  rpc_machine = &hii->hii_rpc_machine;
1198  working = halon_interface_is_working(hii);
1199  M0_LOG(M0_DEBUG, "hi=%p hii=%p rpc_machine=%p working=%d",
1200  hi, hii, rpc_machine, !!working);
1201  return working ? rpc_machine : NULL;
1202 }
1203 
1205 {
1206  struct m0_halon_interface_internal *hii = hi->hif_internal;
1207  struct m0_reqh *reqh;
1208  bool working;
1209 
1210  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1211  M0_PRE(m0_get() == &hii->hii_instance);
1212 
1213  reqh = &hii->hii_reqh;
1214  working = halon_interface_is_working(hii);
1215  M0_LOG(M0_DEBUG, "hi=%p hii=%p reqh=%p working=%d",
1216  hi, hii, reqh, !!working);
1217  return working ? reqh : NULL;
1218 }
1219 
1221 {
1222  struct m0_halon_interface_internal *hii = hi->hif_internal;
1223  struct m0_spiel *spiel;
1224  bool working;
1225 
1226  M0_PRE(m0_halon_interface_internal_bob_check(hii));
1227  M0_PRE(m0_get() == &hii->hii_instance);
1228 
1229  spiel = &hii->hii_spiel;
1230  working = halon_interface_is_working(hii);
1231  M0_LOG(M0_DEBUG, "hi=%p hii=%p spiel=%p working=%d",
1232  hi, hii, spiel, !!working);
1233  return working ? spiel : NULL;
1234 }
1235 
1237  struct m0_thread *thread)
1238 {
1239  struct m0 *motr;
1240  int rc;
1241 
1242  M0_PRE(m0_halon_interface_internal_bob_check(hi->hif_internal));
1243 
1244  motr = &hi->hif_internal->hii_instance;
1246 
1247  return M0_RC(rc);
1248 }
1249 
1250 M0_INTERNAL void m0_halon_interface_thread_shun(void)
1251 {
1252  m0_thread_shun();
1253 }
1254 
1255 #undef M0_TRACE_SUBSYSTEM
1256 
1259 /*
1260  * Local variables:
1261  * c-indentation-style: "K&R"
1262  * c-basic-offset: 8
1263  * tab-width: 8
1264  * fill-column: 80
1265  * scroll-step: 1
1266  * End:
1267  */
1268 /*
1269  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
1270  */
M0_INTERNAL uint64_t m0_process(void)
Definition: kthread.c:295
struct m0_ha_dispatcher_cfg hic_dispatcher_cfg
Definition: interface.c:138
uint64_t hed_type
Definition: msg.h:88
struct m0_fid hic_process_fid
Definition: interface.c:90
struct m0_ha_dispatcher hii_dispatcher
Definition: interface.c:181
#define M0_PRE(cond)
void m0_rpc_machine_fini(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:233
m0_halon_interface_state
Definition: interface.c:164
struct m0_spiel hii_spiel
Definition: interface.c:187
uint64_t hmnv_type
Definition: note.h:226
M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
Definition: reqh.c:675
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
void m0_halon_interface_stop(struct m0_halon_interface *hi)
Definition: interface.c:1040
#define m0_strdup(s)
Definition: string.h:43
m0_conf_ha_process_event
Definition: ha.h:49
#define NULL
Definition: misc.h:38
M0_INTERNAL struct m0_ha_link * m0_ha_connect(struct m0_ha *ha)
Definition: ha.c:687
M0_INTERNAL void m0_conf_ha_service_event_post(struct m0_ha *ha, struct m0_ha_link *hl, const struct m0_fid *source_process_fid, const struct m0_fid *source_service_fid, const struct m0_fid *service_fid, uint64_t pid, enum m0_conf_ha_service_event event, enum m0_conf_service_type service_type)
Definition: ha.c:80
struct m0_ha_msg_nvec_array hmnv_arr
Definition: note.h:265
M0_INTERNAL enum m0_ha_msg_type m0_ha_msg_type_get(const struct m0_ha_msg *msg)
Definition: msg.c:41
static const struct m0_ha_ops halon_interface_ha_ops
Definition: interface.c:542
struct m0_ha_cfg hic_ha_cfg
Definition: interface.c:137
M0_INTERNAL void m0_ha_fini(struct m0_ha *ha)
Definition: ha.c:679
void m0_fini(void)
Definition: init.c:318
struct m0_halon_interface_cfg hii_cfg
Definition: interface.c:174
int m0_halon_interface_start(struct m0_halon_interface *hi, const char *local_rpc_endpoint, const struct m0_fid *process_fid, const struct m0_fid *ha_service_fid, const struct m0_fid *rm_service_fid, void(*entrypoint_request_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, const char *remote_rpc_endpoint, const struct m0_fid *process_fid, const char *git_rev_id, uint64_t pid, bool first_request), void(*msg_received_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t tag), void(*msg_is_delivered_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, uint64_t tag), void(*msg_is_not_delivered_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, uint64_t tag), void(*link_connected_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, struct m0_ha_link *link), void(*link_reused_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, struct m0_ha_link *link), void(*link_absent_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id), void(*link_is_disconnecting_cb)(struct m0_halon_interface *hi, struct m0_ha_link *link), void(*link_disconnected_cb)(struct m0_halon_interface *hi, struct m0_ha_link *link))
Definition: interface.c:948
int m0_halon_interface_init(struct m0_halon_interface **hi_out, const char *build_git_rev_id, const char *build_configure_opts, const char *debug_options, const char *node_uuid)
Definition: interface.c:583
#define M0_REQH_INIT(reqh,...)
Definition: reqh.h:262
Definition: sm.h:350
M0_INTERNAL void m0_ha_rpc_endpoint(struct m0_ha *ha, struct m0_ha_link *hl, char *buf, m0_bcount_t buf_len)
Definition: ha.c:1024
m0_conf_ha_service_event
Definition: ha.h:119
struct m0_rpc_machine hii_rpc_machine
Definition: interface.c:179
static struct io_request req
Definition: file.c:100
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
void(* hic_msg_received_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t tag)
Definition: interface.c:102
enum m0_trace_level level
Definition: trace.c:111
uint8_t ft_id
Definition: fid.h:101
M0_INTERNAL void m0_sns_cm_rebalance_trigger_fop_init(void)
Definition: trigger_fop.c:54
void m0_halon_interface_disconnect(struct m0_halon_interface *hi, struct m0_ha_link *hl)
Definition: interface.c:1159
void(* hic_msg_is_not_delivered_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, uint64_t tag)
Definition: interface.c:111
void m0_halon_interface_delivered(struct m0_halon_interface *hi, struct m0_ha_link *hl, const struct m0_ha_msg *msg)
Definition: interface.c:1125
M0_INTERNAL int m0_ha_start(struct m0_ha *ha)
Definition: ha.c:659
struct m0_reqh_service * hii_rm_service
Definition: interface.c:186
void m0_spiel_fini(struct m0_spiel *spiel)
Definition: spiel.c:59
struct m0_ha * i_ha
Definition: instance.h:108
M0_INTERNAL struct m0_ha_link * m0_ha_outgoing_link(struct m0_ha *ha)
Definition: ha.c:1006
static void halon_interface_parse_debug_options(struct m0_halon_interface *hi, const char *debug_options)
Definition: interface.c:229
M0_INTERNAL void m0_ha_send(struct m0_ha *ha, struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t *tag)
Definition: ha.c:862
struct m0_net_buffer_pool hii_net_buffer_pool
Definition: interface.c:177
struct m0_ha_msg_data hm_data
Definition: msg.h:122
M0_INTERNAL uint8_t m0_fid_tget(const struct m0_fid *fid)
Definition: fid.c:133
struct m0_ha_note hmna_arr[M0_HA_STATE_UPDATE_LIMIT]
Definition: note.h:221
const char * ml_name
Definition: module.h:114
static const struct m0_bob_type halon_interface_bob_type
Definition: interface.c:192
static struct m0_sm_state_descr halon_interface_states[]
Definition: interface.c:555
#define M0_BITS(...)
Definition: misc.h:236
const char * hic_build_configure_opts
Definition: interface.c:87
uint64_t m0_bcount_t
Definition: types.h:77
static void halon_interface_service_event(struct m0_halon_interface_internal *hii, enum m0_conf_ha_service_event event)
Definition: interface.c:656
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
struct m0_ha_ops hcf_ops
Definition: ha.h:273
M0_INTERNAL int m0_thread_adopt(struct m0_thread *thread, struct m0 *instance)
Definition: thread.c:127
int m0_init(struct m0 *instance)
Definition: init.c:310
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
static struct m0_halon_interface_internal * halon_interface_ha2hii(struct m0_ha *ha)
Definition: interface.c:245
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
const char * bt_name
Definition: bob.h:73
Definition: sock.c:887
static void halon_interface_link_connected_cb(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: interface.c:457
static void halon_interface_link_is_disconnecting_cb(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: interface.c:512
M0_INTERNAL void m0_ha_dispatcher_handle(struct m0_ha_dispatcher *hd, struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
Definition: dispatcher.c:231
void(* hao_entrypoint_request)(struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
Definition: ha.h:241
struct m0_fid hic_rm_service_fid
Definition: interface.c:92
M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh)
Definition: reqh.c:647
return M0_RC(rc)
M0_INTERNAL void m0_ha_disconnect(struct m0_ha *ha)
Definition: ha.c:707
M0_INTERNAL void m0_sns_cm_repair_trigger_fop_init(void)
Definition: trigger_fop.c:55
Definition: sock.c:754
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
M0_INTERNAL void m0_halon_interface_thread_shun(void)
Definition: interface.c:1250
int i
Definition: dir.c:1033
#define PRIu64
Definition: types.h:58
const char * bi_configure_opts
Definition: version.h:49
struct m0_rpc_machine * m0_halon_interface_rpc_machine(struct m0_halon_interface *hi)
Definition: interface.c:1188
return M0_ERR(-EOPNOTSUPP)
const struct m0_build_info * m0_build_info_get(void)
Definition: version.c:61
M0_INTERNAL void m0_ha_flush(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ha.c:966
M0_INTERNAL void m0_ha_stop(struct m0_ha *ha)
Definition: ha.c:672
static char * node_uuid
Definition: kuuid.c:36
uint64_t hm_epoch
Definition: msg.h:121
M0_INTERNAL void m0_ha_process_failed(struct m0_ha *ha, const struct m0_fid *process_fid)
Definition: ha.c:972
M0_INTERNAL void m0_ha_delivered(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg)
Definition: ha.c:870
static void halon_interface_msg_is_delivered_cb(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: interface.c:421
const struct m0_fid_type cot_ftype
Definition: obj.h:314
#define M0_ASSERT(cond)
const char * scf_name
Definition: sm.h:352
M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc)
Definition: reqh_service.c:588
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
#define U128_P(x)
Definition: types.h:45
M0_INTERNAL int m0_rpc_net_buffer_pool_setup(struct m0_net_domain *ndom, struct m0_net_buffer_pool *app_pool, uint32_t bufs_nr, uint32_t tm_nr)
Definition: rpc.c:229
void m0_halon_interface_send(struct m0_halon_interface *hi, struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t *tag)
Definition: interface.c:1099
void m0_sm_state_set(struct m0_sm *mach, int state)
Definition: sm.c:478
void(* hic_link_is_disconnecting_cb)(struct m0_halon_interface *hi, struct m0_ha_link *link)
Definition: interface.c:126
struct m0_thread thread
Definition: note.c:104
void(* hic_msg_is_delivered_cb)(struct m0_halon_interface *hi, struct m0_ha_link *hl, uint64_t tag)
Definition: interface.c:107
void m0_node_uuid_string_set(const char *uuid)
Definition: uuuid.c:64
static bool halon_interface_is_working(struct m0_halon_interface_internal *hii)
Definition: interface.c:1177
#define bob_of(ptr, type, field, bt)
Definition: bob.h:140
void m0_halon_interface_entrypoint_reply(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, int rc, uint32_t confd_nr, const struct m0_fid *confd_fid_data, const char **confd_eps_data, uint32_t confd_quorum, const struct m0_fid *rm_fid, const char *rm_eps)
Definition: interface.c:1059
#define m0_streq(a, b)
Definition: string.h:34
struct m0_ha_note hii_nvec[HALON_INTERFACE_NVEC_SIZE_MAX]
Definition: interface.c:189
M0_BOB_DEFINE(static, &halon_interface_bob_type, m0_halon_interface_internal)
M0_INTERNAL void m0_module_setup(struct m0_module *module, const char *name, const struct m0_modlev *level, int level_nr, struct m0 *instance)
Definition: module.c:193
static void halon_interface_entrypoint_replied_cb(struct m0_ha *ha, struct m0_ha_entrypoint_rep *rep)
Definition: interface.c:378
Definition: instance.h:80
M0_INTERNAL int m0_rpc_machine_init(struct m0_rpc_machine *machine, struct m0_net_domain *net_dom, const char *ep_addr, struct m0_reqh *reqh, struct m0_net_buffer_pool *receive_pool, uint32_t colour, m0_bcount_t msg_size, uint32_t queue_len)
Definition: rpc_machine.c:123
struct m0_sm_group hii_sm_group
Definition: interface.c:182
uint64_t hmnv_ignore_same_state
Definition: note.h:263
struct m0_net_xprt * m0_net_xprt_default_get(void)
Definition: net.c:151
static void halon_interface_link_disconnected_cb(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: interface.c:527
struct m0_spiel * m0_halon_interface_spiel(struct m0_halon_interface *hi)
Definition: interface.c:1220
const char * bi_git_rev_id
Definition: version.h:34
Definition: msg.h:115
static void halon_interface_link_reused_cb(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: interface.c:477
Definition: reqh.h:94
M0_INTERNAL void m0_ha_dispatcher_fini(struct m0_ha_dispatcher *hd)
Definition: dispatcher.c:212
void(* hic_link_absent_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id)
Definition: interface.c:123
M0_INTERNAL uint64_t m0_ha_msg_tag(const struct m0_ha_msg *msg)
Definition: msg.c:36
M0_INTERNAL int m0_reqh_service_setup(struct m0_reqh_service **out, struct m0_reqh_service_type *stype, struct m0_reqh *reqh, struct m0_reqh_context *rctx, const struct m0_fid *fid)
Definition: reqh_service.c:565
#define FID_P(f)
Definition: fid.h:77
static void halon_interface_msg_is_not_delivered_cb(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: interface.c:439
M0_INTERNAL void m0_ha_disconnect_incoming(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ha.c:714
struct m0_fid no_id
Definition: note.h:180
M0_INTERNAL void m0_thread_shun(void)
Definition: thread.c:134
const char * hic_build_git_rev_id
Definition: interface.c:86
static struct m0_sm_conf halon_interface_sm_conf
Definition: interface.c:577
enum m0_ha_entrypoint_control hae_control
Definition: ha.h:289
static void halon_interface_process_event(struct m0_halon_interface_internal *hii, enum m0_conf_ha_process_event event)
Definition: interface.c:646
M0_INTERNAL int m0_ha_dispatcher_init(struct m0_ha_dispatcher *hd, struct m0_ha_dispatcher_cfg *hd_cfg)
Definition: dispatcher.c:192
#define U128X_F
Definition: types.h:42
struct m0_ha_link * i_ha_link
Definition: instance.h:110
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
uint32_t sd_flags
Definition: sm.h:378
void(* hic_link_connected_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, struct m0_ha_link *link)
Definition: interface.c:115
struct m0_reqh_service_type m0_rms_type
Definition: rm_service.c:69
#define PRIu32
Definition: types.h:66
M0_INTERNAL int m0_halon_interface_thread_adopt(struct m0_halon_interface *hi, struct m0_thread *thread)
Definition: interface.c:1236
M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
Definition: reqh.c:711
M0_INTERNAL void m0_sns_cm_rebalance_trigger_fop_fini(void)
Definition: trigger_fop.c:42
static void halon_interface_process_failure_check(struct m0_halon_interface_internal *hii, struct m0_ha_msg *msg)
Definition: interface.c:256
struct m0_reqh reqh
Definition: rm_foms.c:48
#define M0_MAGIX_OFFSET(type, field)
Definition: misc.h:356
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
char * ep
Definition: sw.h:132
union m0_ha_msg_data::@212 u
Definition: fid.h:38
static const struct m0_modlev halon_interface_levels[]
Definition: interface.c:667
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
Definition: sm.c:313
M0_INTERNAL int m0_ha_init(struct m0_ha *ha, struct m0_ha_cfg *ha_cfg)
Definition: ha.c:641
struct m0_motr motr
M0_INTERNAL void m0_conf_ha_process_event_post(struct m0_ha *ha, struct m0_ha_link *hl, const struct m0_fid *process_fid, uint64_t pid, enum m0_conf_ha_process_event event, enum m0_conf_ha_process_type type)
Definition: ha.c:45
struct m0_spiel spiel
Definition: spiel_conf_ut.c:42
struct m0_fid hic_ha_service_fid
Definition: interface.c:91
void(* hic_link_reused_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, struct m0_ha_link *link)
Definition: interface.c:119
void(* hic_link_disconnected_cb)(struct m0_halon_interface *hi, struct m0_ha_link *link)
Definition: interface.c:129
int m_cur
Definition: module.h:160
Definition: sm.h:301
Definition: ha.h:272
Definition: ha.h:239
void(* hic_entrypoint_request_cb)(struct m0_halon_interface *hi, const struct m0_uint128 *req_id, const char *remote_rpc_endpoint, const struct m0_fid *process_fid, const char *git_rev_id, uint64_t pid, bool first_request)
Definition: interface.c:94
struct m0_reqh * m0_halon_interface_reqh(struct m0_halon_interface *hi)
Definition: interface.c:1204
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
struct m0_ha_link * hii_outgoing_link
Definition: interface.c:185
uint64_t hmnv_nr
Definition: note.h:264
struct m0_halon_interface * hii_hi
Definition: interface.c:172
#define M0_ASSERT_INFO(cond, fmt,...)
struct m0_net_domain hii_net_domain
Definition: interface.c:176
void m0_ha_entrypoint_reply(struct m0_ha *ha, const struct m0_uint128 *req_id, const struct m0_ha_entrypoint_rep *rep, struct m0_ha_link **hl_ptr)
Definition: ha.c:844
static void halon_interface_msg_received_cb(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
Definition: interface.c:391
const struct m0_conf_obj_type M0_CONF_PROCESS_TYPE
Definition: process.c:161
static void halon_interface_level_leave(struct m0_module *module)
Definition: interface.c:791
struct m0_module hii_module
Definition: interface.c:175
m0_halon_interface_level
Definition: interface.c:144
M0_INTERNAL void m0_ha_msg_debug_print(const struct m0_ha_msg *msg, const char *prefix)
Definition: msg.c:63
static void halon_interface_link_absent_cb(struct m0_ha *ha, const struct m0_uint128 *req_id)
Definition: interface.c:497
#define M0_FID0
Definition: fid.h:93
void m0_rpc_net_buffer_pool_cleanup(struct m0_net_buffer_pool *app_pool)
Definition: rpc.c:264
char * hic_local_rpc_endpoint
Definition: interface.c:89
m0_bcount_t hic_max_msg_size
Definition: interface.c:135
void m0_free(void *data)
Definition: memory.c:146
uint32_t sm_state
Definition: sm.h:307
static bool halon_interface_is_compatible(struct m0_halon_interface *hi, const char *build_git_rev_id, const char *build_configure_opts, bool disable_compat_check)
Definition: interface.c:201
M0_INTERNAL void m0_sns_cm_repair_trigger_fop_fini(void)
Definition: trigger_fop.c:43
static struct m0_rpc_machine rpc_machine
Definition: service_ut.c:63
int32_t rc
Definition: trigger_fop.h:47
static void hi(void)
Definition: nucleus.c:93
#define ARRAY_SIZE(a)
Definition: misc.h:45
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
Definition: module.c:142
static void halon_interface_entrypoint_request_cb(struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
Definition: interface.c:347
static const char * process_fid
Definition: idx_dix.c:73
int m0_spiel_init(struct m0_spiel *spiel, struct m0_reqh *reqh)
Definition: spiel.c:44
#define FID_F
Definition: fid.h:75
void m0_halon_interface_fini(struct m0_halon_interface *hi)
Definition: interface.c:627
Definition: trace.h:478
static int halon_interface_level_enter(struct m0_module *module)
Definition: interface.c:669
struct m0_reqh hii_reqh
Definition: interface.c:178
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131
#define M0_IMPOSSIBLE(fmt,...)
uint32_t no_state
Definition: note.h:182
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)
Definition: sm.c:331