Motr  M0
reqh_service.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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_REQH_REQH_SERVICE_H__
26 #define __MOTR_REQH_REQH_SERVICE_H__
27 
28 #include "lib/atomic.h"
29 #include "lib/chan.h"
30 #include "lib/tlist.h"
31 #include "lib/bob.h"
32 #include "lib/mutex.h"
33 #include "lib/semaphore.h"
34 #include "lib/types.h"
35 #include "be/tx.h" /* m0_be_tx_remid */
36 #include "conf/schema.h" /* m0_conf_service_type */
37 #include "fid/fid.h"
38 #include "rpc/link.h" /* m0_rpc_link */
39 #include "sm/sm.h"
40 
41 struct m0_fop;
42 struct m0_fom;
43 struct m0_conf_obj;
44 struct m0_rpc_session;
45 
207 };
208 
221 
228 
236  unsigned rs_level;
244  struct m0_sm rs_sm;
245 
250 
255 
259  struct m0_reqh *rs_reqh;
260 
267 
272 
282 
286  uint64_t rs_magix;
287 };
288 
295  struct m0_fom *sac_fom;
297  int sac_rc;
298 };
299 
324 };
325 
326 
342 
361 
372 
387  void (*rso_stop)(struct m0_reqh_service *service);
388 
399  void (*rso_fini)(struct m0_reqh_service *service);
400 
409  struct m0_fop *fop);
418 };
419 
436  const struct m0_reqh_service_type *stype);
437 };
438 
447  const char *rst_name;
448 
451 
456  unsigned rst_key;
457  unsigned rst_level;
472 
479  uint64_t rst_magix;
480 };
481 
490 M0_INTERNAL int
492  const struct m0_reqh_service_type *stype,
493  struct m0_reqh_context *rctx);
494 
506 M0_INTERNAL struct m0_reqh_service_type *
507 m0_reqh_service_type_find(const char *sname);
508 
519 M0_INTERNAL int m0_reqh_service_start_async(struct
521  *asc);
522 
531 M0_INTERNAL void m0_reqh_service_started(struct m0_reqh_service *service);
532 
538 M0_INTERNAL void m0_reqh_service_failed(struct m0_reqh_service *service);
539 
551 M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service);
552 
562 M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service
563  *service);
564 
581 M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service);
582 
598 M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service,
599  struct m0_reqh *reqh,
600  const struct m0_fid *fid);
601 
614 M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service);
615 
620  /* General levels */
628 
629  /* Special levels */
645 };
646 
654 
661 
666 M0_INTERNAL int m0_reqh_service_types_init(void);
667 
672 M0_INTERNAL void m0_reqh_service_types_fini(void);
673 
677 M0_INTERNAL bool m0_reqh_service_invariant(const struct m0_reqh_service
678  *service);
679 
686 M0_INTERNAL struct m0_reqh_service *
688  const struct m0_reqh *reqh);
689 
695 M0_INTERNAL struct m0_reqh_service *
696 m0_reqh_service_lookup(const struct m0_reqh *reqh, const struct m0_fid *fid);
697 
698 M0_INTERNAL int m0_reqh_service_types_length(void);
699 M0_INTERNAL bool m0_reqh_service_is_registered(const char *sname);
700 M0_INTERNAL void m0_reqh_service_list_print(void);
701 M0_INTERNAL int m0_reqh_service_state_get(const struct m0_reqh_service *s);
702 
707 M0_INTERNAL int m0_reqh_service_setup(struct m0_reqh_service **out,
708  struct m0_reqh_service_type *stype,
709  struct m0_reqh *reqh,
710  struct m0_reqh_context *rctx,
711  const struct m0_fid *fid);
712 
714 M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc);
715 
724 int
726 
734 
740 
742  uint64_t stx_link_magic;
743 };
744 
751  struct m0_fid sc_fid;
754 
756 
758 
763  uint64_t sc_conn_flags;
764 
765  struct m0_sm sc_sm;
767 
770 
774 
779 
784 
786  uint64_t sc_magic;
787 };
788 
789 M0_INTERNAL int m0_reqh_service_ctx_init(struct m0_reqh_service_ctx *ctx,
790  struct m0_conf_obj *svc_obj,
792  struct m0_rpc_machine *rmach,
793  const char *addr,
794  uint32_t max_rpc_nr_in_flight);
795 
796 M0_INTERNAL void m0_reqh_service_ctx_fini(struct m0_reqh_service_ctx *ctx);
797 
801 M0_INTERNAL int m0_reqh_service_ctx_create(struct m0_conf_obj *svc_obj,
803  struct m0_rpc_machine *rmach,
804  const char *addr,
805  uint32_t max_rpc_nr_in_flight,
806  struct m0_reqh_service_ctx **ctx);
807 
809 M0_INTERNAL void
811 
824 M0_INTERNAL void m0_reqh_service_ctxs_shutdown_prepare(struct m0_reqh *reqh);
825 
831 M0_INTERNAL void m0_reqh_service_connect(struct m0_reqh_service_ctx *ctx);
832 
838 M0_INTERNAL bool
840 
842 M0_INTERNAL void m0_reqh_service_disconnect(struct m0_reqh_service_ctx *ctx);
843 
845 M0_INTERNAL void
847 
849 M0_INTERNAL void m0_reqh_service_connect_wait(struct m0_reqh_service_ctx *ctx);
850 
852 M0_INTERNAL int
854 
858 M0_INTERNAL struct m0_reqh_service_ctx *
860 
864 M0_INTERNAL void m0_reqh_service_ctx_subscribe(struct m0_reqh_service_ctx *ctx);
865 
869 M0_INTERNAL void
871 
873 #endif /* __MOTR_REQH_REQH_SERVICE_H__ */
874 
875 /*
876  * Local variables:
877  * c-indentation-style: "K&R"
878  * c-basic-offset: 8
879  * tab-width: 8
880  * fill-column: 80
881  * scroll-step: 1
882  * End:
883  */
M0_INTERNAL int m0_reqh_service_state_get(const struct m0_reqh_service *s)
Definition: reqh_service.c:560
M0_INTERNAL int m0_reqh_service_start_async(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.c:272
M0_INTERNAL void m0_reqh_service_cancel_reconnect(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:852
struct m0_pools_common * sc_pc
Definition: reqh_service.h:755
M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service)
Definition: reqh_service.c:343
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_lookup(const struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:551
M0_INTERNAL int m0_reqh_service_types_init(void)
Definition: reqh_service.c:520
int(* rso_start)(struct m0_reqh_service *service)
Definition: reqh_service.h:360
struct m0_sm rs_sm
Definition: reqh_service.h:244
struct m0_fid sc_fid
Definition: reqh_service.h:751
struct m0_fid sc_fid_process
Definition: reqh_service.h:753
M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:402
m0_conf_service_type
Definition: schema.h:194
struct m0_mutex sc_max_pending_tx_lock
Definition: reqh_service.h:773
m0_reqh_service_level
Definition: reqh_service.h:619
enum m0_conf_service_type rst_typecode
Definition: reqh_service.h:471
unsigned rs_level
Definition: reqh_service.h:236
M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:375
M0_INTERNAL void m0_reqh_service_ctx_subscribe(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:693
void(* rso_fini)(struct m0_reqh_service *service)
Definition: reqh_service.h:399
M0_INTERNAL bool m0_reqh_service_ctx_is_connected(const struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:760
M0_INTERNAL void m0_reqh_service_ctx_destroy(struct m0_reqh_service_ctx *ctx)
const struct m0_reqh_service_type_ops * rst_ops
Definition: reqh_service.h:450
struct m0_sm sc_sm
Definition: reqh_service.h:765
Definition: sm.h:504
static struct m0_rpc_session session
Definition: formation2.c:38
M0_INTERNAL void m0_reqh_service_connect_wait(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:822
M0_INTERNAL int m0_reqh_service_types_length(void)
Definition: reqh_service.c:499
struct m0_conf_obj * sc_process
Definition: reqh_service.h:778
int m0_reqh_service_type_register(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:473
struct m0_reqh_service * sac_service
Definition: reqh_service.h:293
M0_INTERNAL struct m0_reqh_service_type * m0_reqh_service_type_find(const char *sname)
Definition: reqh_service.c:168
struct m0_fid fid
Definition: di.c:46
struct m0_buf rs_ss_param
Definition: reqh_service.h:281
struct m0_reqh_context rctx
Definition: buf.h:37
struct m0_sm_group sc_sm_grp
Definition: reqh_service.h:766
M0_INTERNAL bool m0_reqh_service_is_registered(const char *sname)
Definition: reqh_service.c:514
struct m0_clink sc_rlink_abort
Definition: reqh_service.h:760
M0_INTERNAL int m0_reqh_service_disconnect_wait(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:831
void(* rso_stop)(struct m0_reqh_service *service)
Definition: reqh_service.h:387
m0_service_health
Definition: reqh_service.h:306
static const struct socktype stype[]
Definition: sock.c:1156
M0_INTERNAL int m0_reqh_service_ctx_create(struct m0_conf_obj *svc_obj, enum m0_conf_service_type stype, struct m0_rpc_machine *rmach, const char *addr, uint32_t max_rpc_nr_in_flight, struct m0_reqh_service_ctx **out)
M0_INTERNAL void m0_reqh_service_connect(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:730
M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc)
Definition: reqh_service.c:588
struct m0_be_tx_remid stx_tri
Definition: reqh_service.h:739
int(* rso_fop_accept)(struct m0_reqh_service *service, struct m0_fop *fop)
Definition: reqh_service.h:408
const char * rst_name
Definition: reqh_service.h:447
M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service)
Definition: reqh_service.c:457
struct m0_fid rs_service_fid
Definition: reqh_service.h:220
struct m0_reqh_context * rs_reqh_ctx
Definition: reqh_service.h:271
M0_INTERNAL bool m0_reqh_service_invariant(const struct m0_reqh_service *svc)
Definition: reqh_service.c:143
struct m0_reqh_service_ctx * stx_service_ctx
Definition: reqh_service.h:733
enum m0_service_health(* rso_health)(struct m0_reqh_service *service)
Definition: reqh_service.h:417
enum m0_conf_service_type sc_type
Definition: reqh_service.h:757
Definition: xcode.h:73
m0_reqh_service_state
Definition: reqh_service.h:156
M0_INTERNAL int m0_reqh_service_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
Definition: reqh_service.c:185
Definition: reqh.h:94
M0_INTERNAL int m0_reqh_service_ctx_init(struct m0_reqh_service_ctx *ctx, struct m0_conf_obj *svc_obj, enum m0_conf_service_type stype, struct m0_rpc_machine *rmach, const char *addr, uint32_t max_rpc_nr_in_flight)
M0_INTERNAL void m0_reqh_service_ctx_unsubscribe(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:702
M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:428
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
int m0_reqh_service_async_start_simple(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.c:601
struct m0_mutex rs_mutex
Definition: reqh_service.h:249
Definition: fom.h:481
struct m0_clink sc_rlink_wait
Definition: reqh_service.h:761
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find(const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
Definition: reqh_service.c:538
struct m0_reqh reqh
Definition: rm_foms.c:48
M0_INTERNAL void m0_reqh_service_types_fini(void)
Definition: reqh_service.c:530
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
struct m0_clink sc_process_event
Definition: reqh_service.h:783
struct m0_tlink stx_tlink
Definition: reqh_service.h:741
Definition: fid.h:38
const struct m0_reqh_service_type * rs_type
Definition: reqh_service.h:227
void(* rso_prepare_to_stop)(struct m0_reqh_service *service)
Definition: reqh_service.h:371
M0_INTERNAL void m0_reqh_service_list_print(void)
Definition: reqh_service.c:504
static struct m0_net_test_service svc
Definition: service.c:34
Definition: sm.h:301
struct m0_sm_ast sc_rlink_ast
Definition: reqh_service.h:762
static struct m0_fop * fop
Definition: item.c:57
struct m0_clink sc_svc_event
Definition: reqh_service.h:781
struct m0_tlink rs_linkage
Definition: reqh_service.h:266
M0_INTERNAL void m0_reqh_service_started(struct m0_reqh_service *service)
Definition: reqh_service.c:311
Definition: nucleus.c:42
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_reqh_service_disconnect(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:781
struct m0_conf_obj * sc_service
Definition: reqh_service.h:776
struct m0_rpc_link sc_rlink
Definition: reqh_service.h:759
M0_INTERNAL void m0_reqh_service_ctx_fini(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:971
struct m0_reqh * rs_reqh
Definition: reqh_service.h:259
Definition: mutex.h:47
static struct m0_addb2_source * s
Definition: consumer.c:39
struct m0_tlink sc_link
Definition: reqh_service.h:769
uint64_t rs_magix
Definition: reqh_service.h:286
void m0_reqh_service_type_unregister(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:490
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
M0_INTERNAL void m0_reqh_service_ctxs_shutdown_prepare(struct m0_reqh *reqh)
Definition: reqh_service.c:892
int(* rso_start_async)(struct m0_reqh_service_start_async_ctx *asc)
Definition: reqh_service.h:341
struct m0_reqh_service_txid sc_max_pending_tx
Definition: reqh_service.h:772
Definition: fop.h:79
struct m0_tlink rst_linkage
Definition: reqh_service.h:478
M0_INTERNAL void m0_reqh_service_failed(struct m0_reqh_service *service)
Definition: reqh_service.c:326
const struct m0_reqh_service_ops * rs_ops
Definition: reqh_service.h:254
M0_INTERNAL struct m0_reqh_service_ctx * m0_reqh_service_ctx_from_session(struct m0_rpc_session *session)