Motr  M0
ha.h
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 
23 #pragma once
24 
25 #ifndef __MOTR_HA_HA_H__
26 #define __MOTR_HA_HA_H__
27 
204 #include "lib/tlist.h" /* m0_tl */
205 #include "lib/types.h" /* uint64_t */
206 #include "lib/mutex.h" /* m0_mutex */
207 
208 #include "fid/fid.h" /* m0_fid */
209 #include "module/module.h" /* m0_module */
210 #include "ha/entrypoint.h" /* m0_ha_entrypoint_client */
211 #include "ha/cookie.h" /* m0_ha_cookie */
212 
213 struct m0_uint128;
214 struct m0_rpc_machine;
215 struct m0_reqh;
216 struct m0_ha;
217 struct m0_ha_msg;
218 struct m0_ha_link;
219 struct m0_ha_entrypoint_req;
220 
237 };
238 
239 struct m0_ha_ops {
240  void (*hao_entrypoint_request)
241  (struct m0_ha *ha,
242  const struct m0_ha_entrypoint_req *req,
243  const struct m0_uint128 *req_id);
244  void (*hao_entrypoint_replied)(struct m0_ha *ha,
245  struct m0_ha_entrypoint_rep *rep);
246  void (*hao_msg_received)(struct m0_ha *ha,
247  struct m0_ha_link *hl,
248  struct m0_ha_msg *msg,
249  uint64_t tag);
250  void (*hao_msg_is_delivered)(struct m0_ha *ha,
251  struct m0_ha_link *hl,
252  uint64_t tag);
253  void (*hao_msg_is_not_delivered)(struct m0_ha *ha,
254  struct m0_ha_link *hl,
255  uint64_t tag);
256  void (*hao_link_connected)(struct m0_ha *ha,
257  const struct m0_uint128 *req_id,
258  struct m0_ha_link *hl);
259  void (*hao_link_reused)(struct m0_ha *ha,
260  const struct m0_uint128 *req_id,
261  struct m0_ha_link *hl);
262  void (*hao_link_absent)(struct m0_ha *ha,
263  const struct m0_uint128 *req_id);
264  void (*hao_link_is_disconnecting)(struct m0_ha *ha,
265  struct m0_ha_link *hl);
266  void (*hao_link_disconnected)(struct m0_ha *ha,
267  struct m0_ha_link *hl);
268  /* not implemented yet */
269  void (*hao_error_no_memory)(struct m0_ha *ha, int unused);
270 };
271 
272 struct m0_ha_cfg {
275  struct m0_reqh *hcf_reqh;
277  const char *hcf_addr;
280 
281  /* m0_ha is resposible for the next fields */
282 
285 };
286 
287 struct ha_link_ctx;
288 
289 struct m0_ha {
290  struct m0_ha_cfg h_cfg;
292  struct m0_mutex h_lock;
309  /*
310  * A cookie that belongs to this m0_ha.
311  * It's sent in the m0_ha_entrypoint_rep::hae_cookie_actual to every
312  * m0_ha that requests entrypoint from this one.
313  * It's compared with m0_ha_entrypoint_req::heq_cookie_expected to see
314  * if the requester expects exactly this instance of m0_ha.
315  */
317  /*
318  * The expected cookie of the remote end of m0_ha::h_link.
319  * It's sent in m0_ha_entrypoint_req::heq_cookie_expected to tell about
320  * the expectations.
321  * It's compared with the cookie from the
322  * m0_ha_entrypoint_rep::hae_cookie_actual to detect remote restart.
323  */
325 };
326 
327 M0_INTERNAL int m0_ha_init(struct m0_ha *ha, struct m0_ha_cfg *ha_cfg);
328 M0_INTERNAL int m0_ha_start(struct m0_ha *ha);
329 M0_INTERNAL void m0_ha_stop(struct m0_ha *ha);
330 M0_INTERNAL void m0_ha_fini(struct m0_ha *ha);
331 
332 M0_INTERNAL void
333 m0_ha_entrypoint_reply(struct m0_ha *ha,
334  const struct m0_uint128 *req_id,
335  const struct m0_ha_entrypoint_rep *rep,
336  struct m0_ha_link **hl_ptr);
337 
338 M0_INTERNAL struct m0_ha_link *m0_ha_connect(struct m0_ha *ha);
339 M0_INTERNAL void m0_ha_disconnect(struct m0_ha *ha);
340 
341 M0_INTERNAL void m0_ha_disconnect_incoming(struct m0_ha *ha,
342  struct m0_ha_link *hl);
343 
344 M0_INTERNAL void m0_ha_send(struct m0_ha *ha,
345  struct m0_ha_link *hl,
346  const struct m0_ha_msg *msg,
347  uint64_t *tag);
348 M0_INTERNAL void m0_ha_delivered(struct m0_ha *ha,
349  struct m0_ha_link *hl,
350  struct m0_ha_msg *msg);
351 
352 M0_INTERNAL void m0_ha_flush(struct m0_ha *ha,
353  struct m0_ha_link *hl);
354 
355 M0_INTERNAL void m0_ha_process_failed(struct m0_ha *ha,
356  const struct m0_fid *process_fid);
357 
358 M0_INTERNAL struct m0_ha_link *m0_ha_outgoing_link(struct m0_ha *ha);
359 M0_INTERNAL struct m0_rpc_session *m0_ha_outgoing_session(struct m0_ha *ha);
360 
361 M0_INTERNAL void m0_ha_rpc_endpoint(struct m0_ha *ha,
362  struct m0_ha_link *hl,
363  char *buf,
364  m0_bcount_t buf_len);
365 
366 M0_INTERNAL int m0_ha_mod_init(void);
367 M0_INTERNAL void m0_ha_mod_fini(void);
368 
370 #endif /* __MOTR_HA_HA_H__ */
371 
372 /*
373  * Local variables:
374  * c-indentation-style: "K&R"
375  * c-basic-offset: 8
376  * tab-width: 8
377  * fill-column: 80
378  * scroll-step: 1
379  * End:
380  */
381 /*
382  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
383  */
struct m0_tl h_links_outgoing
Definition: ha.h:294
uint64_t h_link_id_counter
Definition: ha.h:306
struct m0_ha_entrypoint_client h_entrypoint_client
Definition: ha.h:303
M0_INTERNAL struct m0_ha_link * m0_ha_connect(struct m0_ha *ha)
Definition: ha.c:687
struct m0_mutex h_lock
Definition: ha.h:292
M0_INTERNAL void m0_ha_fini(struct m0_ha *ha)
Definition: ha.c:679
struct m0_ha_entrypoint_server_cfg hcf_entrypoint_server_cfg
Definition: ha.h:284
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
static struct io_request req
Definition: file.c:100
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
struct m0_reqh_service * h_hl_service
Definition: ha.h:302
uint64_t h_generation_counter
Definition: ha.h:307
void(* hao_link_disconnected)(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ha.h:266
M0_INTERNAL int m0_ha_start(struct m0_ha *ha)
Definition: ha.c:659
struct m0_ha_cfg h_cfg
Definition: ha.h:290
M0_INTERNAL struct m0_ha_link * m0_ha_outgoing_link(struct m0_ha *ha)
Definition: ha.c:1006
void(* hao_link_connected)(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: ha.h:256
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
void(* hao_link_absent)(struct m0_ha *ha, const struct m0_uint128 *req_id)
Definition: ha.h:262
uint64_t m0_bcount_t
Definition: types.h:77
struct m0_ha_ops hcf_ops
Definition: ha.h:273
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
Definition: sock.c:887
struct m0_reqh * hcf_reqh
Definition: ha.h:275
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
M0_INTERNAL void m0_ha_disconnect(struct m0_ha *ha)
Definition: ha.c:707
M0_INTERNAL struct m0_rpc_session * m0_ha_outgoing_session(struct m0_ha *ha)
Definition: ha.c:1016
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
M0_INTERNAL void m0_ha_process_failed(struct m0_ha *ha, const struct m0_fid *process_fid)
Definition: ha.c:972
struct m0_ha_entrypoint_server h_entrypoint_server
Definition: ha.h:304
M0_INTERNAL void m0_ha_delivered(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg)
Definition: ha.c:870
void(* hao_link_is_disconnecting)(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ha.h:264
struct m0_ha_link * h_link
Definition: ha.h:298
void(* hao_entrypoint_replied)(struct m0_ha *ha, struct m0_ha_entrypoint_rep *rep)
Definition: ha.h:244
struct m0_tl h_links_stopping
Definition: ha.h:296
M0_INTERNAL void m0_ha_mod_fini(void)
Definition: ha.c:1052
Definition: tlist.h:251
struct m0_ha_entrypoint_client_cfg hcf_entrypoint_client_cfg
Definition: ha.h:283
const char * hcf_addr
Definition: ha.h:277
Definition: msg.h:115
Definition: reqh.h:94
struct m0_ha_cookie h_cookie_local
Definition: ha.h:316
bool h_warn_local_link_disconnect
Definition: ha.h:308
struct m0_ha_cookie h_cookie_remote
Definition: ha.h:324
struct m0_rpc_machine * hcf_rpc_machine
Definition: ha.h:274
M0_INTERNAL void m0_ha_disconnect_incoming(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ha.c:714
Definition: ha.h:289
bool h_link_started
Definition: ha.h:301
void(* hao_error_no_memory)(struct m0_ha *ha, int unused)
Definition: ha.h:269
M0_INTERNAL int m0_ha_mod_init(void)
Definition: ha.c:1032
void(* hao_msg_is_delivered)(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: ha.h:250
Definition: fid.h:38
struct m0_clink h_clink
Definition: ha.h:305
void(* hao_msg_received)(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
Definition: ha.h:246
M0_INTERNAL int m0_ha_init(struct m0_ha *ha, struct m0_ha_cfg *ha_cfg)
Definition: ha.c:641
struct ha_link_ctx * h_link_ctx
Definition: ha.h:300
Definition: ha.h:272
Definition: ha.h:239
struct m0_module h_module
Definition: ha.h:291
void(* hao_link_reused)(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: ha.h:259
m0_ha_level
Definition: ha.h:221
void(* hao_msg_is_not_delivered)(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: ha.h:253
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
Definition: mutex.h:47
struct m0_tl h_links_incoming
Definition: ha.h:293
struct m0_fid hcf_process_fid
Definition: ha.h:279
static const char * process_fid
Definition: idx_dix.c:73