42 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_HA 112 M0_ENTRY(
"hlx=%p hl=%p ha=%p state=%d state_name=%s",
146 hao_link_is_disconnecting(ha, &hlx->
hlx_link);
170 m0_uint128_eq(&hlx->hlx_link.hln_conn_cfg.hlcc_params.hlp_id_local,
172 m0_uint128_eq(&hlx->hlx_link.hln_conn_cfg.hlcc_params.hlp_id_remote,
195 M0_ENTRY(
"ha=%p hlx=%p hlx_type=%d", ha, hlx, hlx_type);
217 ha_links_tlink_init_at_tail(hlx, hlx_type ==
HLX_INCOMING ?
233 ha_links_tlink_del_fini(hlx);
267 const char *rpc_endpoint)
271 .hlcc_rpc_endpoint = rpc_endpoint,
290 bool consumed =
true;
305 "HA has already decided that this process has " 306 "failed. There is no good reason to continue " 307 "doing something, and there is no code yet " 308 "to handle graceful shutdown in this case. " 309 "Let's just terminate the process and let HA " 315 &
rep->hae_cookie_actual)));
320 if (
req->heq_first_request) {
324 req->heq_first_request =
false;
326 if (
rep->hae_link_do_reconnect) {
350 if (!
req->heq_first_request) {
352 &
req->heq_link_params);
516 hlx = ha_links_tlist_head(
list);
571 .
ml_name =
"M0_HA_LEVEL_ASSIGNS",
576 .ml_name =
"M0_HA_LEVEL_ADDR_STRDUP",
581 .ml_name =
"M0_HA_LEVEL_LINK_SERVICE",
586 .ml_name =
"M0_HA_LEVEL_ENTRYPOINT_SERVER_INIT",
591 .ml_name =
"M0_HA_LEVEL_ENTRYPOINT_CLIENT_INIT",
596 .ml_name =
"M0_HA_LEVEL_INIT",
599 .ml_name =
"M0_HA_LEVEL_ENTRYPOINT_SERVER_START",
604 .ml_name =
"M0_HA_LEVEL_INCOMING_LINKS",
609 .ml_name =
"M0_HA_LEVEL_START",
612 .ml_name =
"M0_HA_LEVEL_LINK_CTX_ALLOC",
617 .ml_name =
"M0_HA_LEVEL_LINK_CTX_INIT",
622 .ml_name =
"M0_HA_LEVEL_ENTRYPOINT_CLIENT_START",
627 .ml_name =
"M0_HA_LEVEL_ENTRYPOINT_CLIENT_WAIT",
632 .ml_name =
"M0_HA_LEVEL_LINK_ASSIGN",
637 .ml_name =
"M0_HA_LEVEL_CONNECT",
645 M0_ENTRY(
"ha=%p hcf_rpc_machine=%p hcf_reqh=%p",
781 rep->hae_link_do_reconnect =
false;
782 rep->hae_disconnected_previously =
false;
789 if (
req->heq_first_request) {
793 .hlp_id_local = id_local,
794 .hlp_id_remote = id_remote,
804 &
req->heq_cookie_expected)) {
806 "previously, a new one shouldn't be created");
807 rep->hae_disconnected_previously =
true;
808 add_new_link =
false;
812 &
rep->hae_link_params,
814 &id_remote, &id_local,
816 rep->hae_link_do_reconnect =
true;
828 if (
req->heq_first_request) {
830 "Link should already be disconnected.");
840 M0_LEAVE(
"ha=%p heq_rpc_endpoint=%s hl=%p",
942 .
ml_name =
"M0_HA_MOD_LEVEL_ASSIGNS",
947 .ml_name =
"M0_HA_MOD_LEVEL_LINK_SERVICE",
952 .ml_name =
"M0_HA_MOD_LEVEL_LINK",
957 .ml_name =
"M0_HA_MOD_LEVEL_ENTRYPOINT",
962 .ml_name =
"M0_HA_MOD_LEVEL_STARTED",
1038 if (ha_module ==
NULL)
1062 #undef M0_TRACE_SUBSYSTEM
struct m0_tl h_links_outgoing
struct m0_ha_link_params heq_link_params
uint64_t h_link_id_counter
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
struct m0_ha_entrypoint_client h_entrypoint_client
M0_INTERNAL const struct m0_ha_entrypoint_req * m0_ha_entrypoint_server_request_find(struct m0_ha_entrypoint_server *hes, const struct m0_uint128 *req_id)
static const struct m0_modlev ha_mod_levels[]
static void ha_level_leave(struct m0_module *module)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
static struct m0_list list
static bool ha_entrypoint_state_cb(struct m0_clink *clink)
M0_INTERNAL struct m0_ha_link * m0_ha_connect(struct m0_ha *ha)
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
M0_INTERNAL void m0_ha_link_stop(struct m0_ha_link *hl, struct m0_clink *clink)
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
M0_INTERNAL void m0_ha_fini(struct m0_ha *ha)
struct m0_ha_entrypoint_server_cfg hcf_entrypoint_server_cfg
static uint64_t ha_generation_next(struct m0_ha *ha)
const m0_time_t M0_TIME_NEVER
M0_INTERNAL void m0_ha_rpc_endpoint(struct m0_ha *ha, struct m0_ha_link *hl, char *buf, m0_bcount_t buf_len)
static struct io_request req
M0_INTERNAL bool m0_uint128_eq(const struct m0_uint128 *u0, const struct m0_uint128 *u1)
static uint64_t tag(uint8_t code, uint64_t id)
struct m0_reqh_service * h_hl_service
#define M0_LOG(level,...)
M0_INTERNAL struct m0_ha_msg * m0_ha_link_recv(struct m0_ha_link *hl, uint64_t *tag)
uint64_t h_generation_counter
enum m0_trace_level level
void(* hao_link_disconnected)(struct m0_ha *ha, struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_entrypoint_server_start(struct m0_ha_entrypoint_server *hes)
M0_INTERNAL int m0_ha_start(struct m0_ha *ha)
M0_INTERNAL struct m0_ha_link * m0_ha_outgoing_link(struct m0_ha *ha)
M0_INTERNAL void m0_ha_entrypoint_mod_fini(void)
M0_INTERNAL const char * m0_ha_link_state_name(enum m0_ha_link_state state)
M0_INTERNAL void m0_ha_entrypoint_client_stop(struct m0_ha_entrypoint_client *ecl)
void(* hao_link_connected)(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_send(struct m0_ha *ha, struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t *tag)
void(* hao_link_absent)(struct m0_ha *ha, const struct m0_uint128 *req_id)
M0_INTERNAL enum m0_ha_entrypoint_client_state m0_ha_entrypoint_client_state_get(struct m0_ha_entrypoint_client *ecl)
M0_INTERNAL struct m0 * m0_get(void)
struct m0_uint128 hlp_id_remote
struct m0_semaphore hlx_stop_sem
M0_INTERNAL void m0_ha_cookie_init(struct m0_ha_cookie *hc)
#define container_of(ptr, type, member)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
struct m0_ha_link_tags hlp_tags_local
M0_INTERNAL void m0_ha_entrypoint_client_request(struct m0_ha_entrypoint_client *ecl)
M0_INTERNAL struct m0_chan * m0_ha_link_chan(struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_entrypoint_server_reply(struct m0_ha_entrypoint_server *hes, const struct m0_uint128 *req_id, const struct m0_ha_entrypoint_rep *rep)
struct m0_fop_getxattr_rep * rep
M0_INTERNAL void m0_ha_link_flush(struct m0_ha_link *hl)
struct m0_reqh * hcf_reqh
M0_INTERNAL void m0_ha_link_start(struct m0_ha_link *hl, struct m0_ha_link_conn_cfg *hl_conn_cfg)
M0_INTERNAL enum m0_ha_link_state m0_ha_link_state_get(struct m0_ha_link *hl)
void(* hao_entrypoint_request)(struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
struct m0_reqh * hecc_reqh
M0_INTERNAL void m0_ha_link_send(struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t *tag)
M0_INTERNAL void m0_ha_disconnect(struct m0_ha *ha)
static int ha_link_incoming_create(struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, struct m0_ha_link_conn_cfg *hl_conn_cfg, struct ha_link_ctx **hlx_ptr)
static void ha_request_received_cb(struct m0_ha_entrypoint_server *hes, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
static bool ha_link_event_cb(struct m0_clink *clink)
M0_INTERNAL void m0_ha_cookie_fini(struct m0_ha_cookie *hc)
M0_INTERNAL bool m0_ha_cookie_is_eq(const struct m0_ha_cookie *a, const struct m0_ha_cookie *b)
M0_INTERNAL int m0_ha_entrypoint_mod_init(void)
struct m0_uint128 hlp_id_connection
struct m0_tlink hlx_tlink
M0_INTERNAL struct m0_rpc_session * m0_ha_outgoing_session(struct m0_ha *ha)
return M0_ERR(-EOPNOTSUPP)
struct m0_uint128 hlp_id_local
M0_INTERNAL void m0_ha_flush(struct m0_ha *ha, struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_stop(struct m0_ha *ha)
struct m0_clink hlx_stop_clink
M0_INTERNAL int m0_ha_entrypoint_server_init(struct m0_ha_entrypoint_server *hes, struct m0_ha_entrypoint_server_cfg *hes_cfg)
M0_INTERNAL void m0_ha_process_failed(struct m0_ha *ha, const struct m0_fid *process_fid)
M0_INTERNAL void m0_ha_link_cb_disconnecting(struct m0_ha_link *hl)
struct m0_ha_module * i_ha_module
struct m0_ha_entrypoint_server h_entrypoint_server
M0_INTERNAL void m0_ha_delivered(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg)
struct m0_ha_link * h_link
M0_INTERNAL void m0_ha_link_reconnect_cancel(struct m0_ha_link *hl)
void(* hao_entrypoint_replied)(struct m0_ha *ha, struct m0_ha_entrypoint_rep *rep)
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
const struct m0_ha_cookie m0_ha_cookie_no_record
struct m0_tl h_links_stopping
M0_INTERNAL void m0_ha_mod_fini(void)
M0_INTERNAL void m0_ha_entrypoint_server_fini(struct m0_ha_entrypoint_server *hes)
M0_INTERNAL int m0_ha_entrypoint_client_init(struct m0_ha_entrypoint_client *ecl, const char *ep, struct m0_ha_entrypoint_client_cfg *ecl_cfg)
struct m0_ha_entrypoint_req ecl_req
struct m0_ha_entrypoint_client_cfg hcf_entrypoint_client_cfg
static int ha_link_ctx_init(struct m0_ha *ha, struct ha_link_ctx *hlx, struct m0_ha_link_cfg *hl_cfg, const struct m0_ha_link_conn_cfg *hl_conn_cfg, const struct m0_fid *process_fid, enum ha_link_ctx_type hlx_type)
M0_INTERNAL void m0_module_setup(struct m0_module *module, const char *name, const struct m0_modlev *level, int level_nr, struct m0 *instance)
M0_INTERNAL void m0_ha_link_params_invert(struct m0_ha_link_params *dst, const struct m0_ha_link_params *src)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
M0_INTERNAL int m0_ha_link_mod_init(void)
M0_INTERNAL void m0_ha_link_reconnect_begin(struct m0_ha_link *hl, struct m0_ha_link_params *lp)
struct m0_reqh * hesc_reqh
static void ha_link_ctx_fini(struct m0_ha *ha, struct ha_link_ctx *hlx)
struct m0_ha_cookie h_cookie_local
M0_INTERNAL void m0_ha_link_tags_initial(struct m0_ha_link_tags *tags, bool tag_even)
M0_INTERNAL void m0_ha_link_reconnect_end(struct m0_ha_link *hl, const struct m0_ha_link_conn_cfg *hl_conn_cfg)
static struct m0_clink clink[RDWR_REQUEST_MAX]
bool h_warn_local_link_disconnect
static bool ha_link_stop_cb(struct m0_clink *clink)
struct m0_ha_cookie h_cookie_remote
M0_INTERNAL int m0_ha_link_service_init(struct m0_reqh_service **hl_service, struct m0_reqh *reqh)
struct m0_ha_link_tags hlp_tags_remote
struct m0_rpc_machine * hcf_rpc_machine
M0_INTERNAL uint64_t m0_ha_link_delivered_consume(struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_disconnect_incoming(struct m0_ha *ha, struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_link_delivered(struct m0_ha_link *hl, struct m0_ha_msg *msg)
M0_INTERNAL int m0_ha_link_service_mod_init(void)
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
M0_TL_DESCR_DEFINE(ha_links, "m0_ha::h_links_{incoming,outgoing}", static, struct ha_link_ctx, hlx_tlink, hlx_magic, 7, 8)
M0_TL_DEFINE(ha_links, static, struct ha_link_ctx)
M0_INTERNAL void m0_ha_cookie_record(struct m0_ha_cookie *hc)
struct m0_fid hlx_process_fid
static int ha_level_enter(struct m0_module *module)
M0_INTERNAL void m0_ha_link_mod_fini(void)
m0_ha_entrypoint_client_state
M0_INTERNAL int m0_ha_mod_init(void)
struct m0_reqh * hlc_reqh
void(* hao_msg_is_delivered)(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
M0_INTERNAL void m0_ha_link_service_fini(struct m0_reqh_service *hl_service)
static void ha_link_conn_cfg_make(struct m0_ha_link_conn_cfg *hl_conn_cfg, const char *rpc_endpoint)
M0_INTERNAL void m0_ha_entrypoint_client_fini(struct m0_ha_entrypoint_client *ecl)
void(* hao_msg_received)(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
M0_INTERNAL int m0_ha_init(struct m0_ha *ha, struct m0_ha_cfg *ha_cfg)
struct m0_module hmo_module
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
M0_INTERNAL void m0_ha_link_rpc_endpoint(struct m0_ha_link *hl, char *buf, m0_bcount_t buf_len)
struct ha_link_ctx * h_link_ctx
struct m0_ha_link_params hlcc_params
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
struct m0_module h_module
void(* hao_link_reused)(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
M0_INTERNAL void m0_ha_entrypoint_server_stop(struct m0_ha_entrypoint_server *hes)
enum ha_link_ctx_type hlx_type
M0_INTERNAL struct m0_chan * m0_ha_entrypoint_client_chan(struct m0_ha_entrypoint_client *ecl)
#define M0_UINT128(hi, lo)
static int ha_mod_level_enter(struct m0_module *module)
#define M0_MKTIME(secs, ns)
#define M0_ASSERT_INFO(cond, fmt,...)
M0_INTERNAL void m0_ha_link_reconnect_params(const struct m0_ha_link_params *lp_alive, struct m0_ha_link_params *lp_alive_new, struct m0_ha_link_params *lp_dead_new, const struct m0_uint128 *id_alive, const struct m0_uint128 *id_dead, const struct m0_uint128 *id_connection)
void(* hao_msg_is_not_delivered)(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
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)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
static void ha_mod_level_leave(struct m0_module *module)
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
M0_INTERNAL int m0_ha_link_init(struct m0_ha_link *hl, struct m0_ha_link_cfg *hl_cfg)
#define m0_tl_find(name, var, head,...)
#define m0_tl_for(name, head, obj)
M0_INTERNAL void m0_ha_entrypoint_client_start(struct m0_ha_entrypoint_client *ecl)
M0_INTERNAL void m0_ha_link_fini(struct m0_ha_link *hl)
static void ha_link_handle(struct m0_ha *ha, const struct m0_uint128 *req_id, const struct m0_ha_entrypoint_req *req, struct m0_ha_entrypoint_rep *rep, struct m0_ha_link **hl_ptr)
M0_INTERNAL uint64_t m0_ha_link_not_delivered_consume(struct m0_ha_link *hl)
struct m0_tl h_links_incoming
struct m0_ha_entrypoint_rep ecl_rep
static const struct m0_modlev ha_levels[]
static struct ha_link_ctx * ha_link_incoming_find(struct m0_ha *ha, const struct m0_ha_link_params *lp)
struct m0_fid hlcc_rpc_service_fid
struct m0_clink hlx_clink
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
M0_INTERNAL struct m0_rpc_session * m0_ha_link_rpc_session(struct m0_ha_link *hl)
struct m0_fid hcf_process_fid
static const char * process_fid
M0_INTERNAL void m0_ha_link_service_mod_fini(void)
struct m0_ha_link hlx_link
static void ha_link_id_next(struct m0_ha *ha, struct m0_uint128 *id)
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
#define M0_IMPOSSIBLE(fmt,...)