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 #include "fop/wire.h"
41 
42 struct m0_fop;
43 struct m0_fom;
44 struct m0_conf_obj;
45 struct m0_rpc_session;
46 
208 };
209 
222 
229 
237  unsigned rs_level;
245  struct m0_sm rs_sm;
246 
251 
256 
260  struct m0_reqh *rs_reqh;
261 
268 
273 
283 
287  uint64_t rs_magix;
288 };
289 
296  struct m0_fom *sac_fom;
298  int sac_rc;
299 };
300 
325 };
326 
327 
343 
362 
373 
388  void (*rso_stop)(struct m0_reqh_service *service);
389 
400  void (*rso_fini)(struct m0_reqh_service *service);
401 
410  struct m0_fop *fop);
419 };
420 
437  const struct m0_reqh_service_type *stype);
438 };
439 
448  const char *rst_name;
449 
452 
457  unsigned rst_key;
458  unsigned rst_level;
473 
480  uint64_t rst_magix;
481 };
482 
491 M0_INTERNAL int
493  const struct m0_reqh_service_type *stype,
494  struct m0_reqh_context *rctx);
495 
507 M0_INTERNAL struct m0_reqh_service_type *
508 m0_reqh_service_type_find(const char *sname);
509 
520 M0_INTERNAL int m0_reqh_service_start_async(struct
522  *asc);
523 
532 M0_INTERNAL void m0_reqh_service_started(struct m0_reqh_service *service);
533 
539 M0_INTERNAL void m0_reqh_service_failed(struct m0_reqh_service *service);
540 
552 M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service);
553 
563 M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service
564  *service);
565 
582 M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service);
583 
599 M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service,
600  struct m0_reqh *reqh,
601  const struct m0_fid *fid);
602 
615 M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service);
616 
621  /* General levels */
629 
630  /* Special levels */
646 };
647 
655 
662 
667 M0_INTERNAL int m0_reqh_service_types_init(void);
668 
673 M0_INTERNAL void m0_reqh_service_types_fini(void);
674 
678 M0_INTERNAL bool m0_reqh_service_invariant(const struct m0_reqh_service
679  *service);
680 
687 M0_INTERNAL struct m0_reqh_service *
689  const struct m0_reqh *reqh);
690 
696 M0_INTERNAL struct m0_reqh_service *
697 m0_reqh_service_lookup(const struct m0_reqh *reqh, const struct m0_fid *fid);
698 
699 M0_INTERNAL int m0_reqh_service_types_length(void);
700 M0_INTERNAL bool m0_reqh_service_is_registered(const char *sname);
701 M0_INTERNAL void m0_reqh_service_list_print(void);
702 M0_INTERNAL int m0_reqh_service_state_get(const struct m0_reqh_service *s);
703 
708 M0_INTERNAL int m0_reqh_service_setup(struct m0_reqh_service **out,
709  struct m0_reqh_service_type *stype,
710  struct m0_reqh *reqh,
711  struct m0_reqh_context *rctx,
712  const struct m0_fid *fid);
713 
715 M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc);
716 
725 int
727 
735 
741 
743  uint64_t stx_link_magic;
744 };
745 
752  struct m0_fid sc_fid;
755 
757 
759 
764  uint64_t sc_conn_flags;
765 
766  struct m0_sm sc_sm;
768 
771 
775 
780 
785 
787  uint64_t sc_magic;
788 };
789 
790 M0_INTERNAL int m0_reqh_service_ctx_init(struct m0_reqh_service_ctx *ctx,
791  struct m0_conf_obj *svc_obj,
793  struct m0_rpc_machine *rmach,
794  const char *addr,
795  uint32_t max_rpc_nr_in_flight);
796 
797 M0_INTERNAL void m0_reqh_service_ctx_fini(struct m0_reqh_service_ctx *ctx);
798 
802 M0_INTERNAL int m0_reqh_service_ctx_create(struct m0_conf_obj *svc_obj,
804  struct m0_rpc_machine *rmach,
805  const char *addr,
806  uint32_t max_rpc_nr_in_flight,
807  struct m0_reqh_service_ctx **ctx);
808 
810 M0_INTERNAL void
812 
825 M0_INTERNAL void m0_reqh_service_ctxs_shutdown_prepare(struct m0_reqh *reqh);
826 
832 M0_INTERNAL void m0_reqh_service_connect(struct m0_reqh_service_ctx *ctx);
833 
839 M0_INTERNAL bool
841 
843 M0_INTERNAL void m0_reqh_service_disconnect(struct m0_reqh_service_ctx *ctx);
844 
846 M0_INTERNAL void
848 
850 M0_INTERNAL void m0_reqh_service_connect_wait(struct m0_reqh_service_ctx *ctx);
851 
853 M0_INTERNAL int
855 
859 M0_INTERNAL struct m0_reqh_service_ctx *
861 
865 M0_INTERNAL void m0_reqh_service_ctx_subscribe(struct m0_reqh_service_ctx *ctx);
866 
870 M0_INTERNAL void
872 
874 #endif /* __MOTR_REQH_REQH_SERVICE_H__ */
875 
876 /*
877  * Local variables:
878  * c-indentation-style: "K&R"
879  * c-basic-offset: 8
880  * tab-width: 8
881  * fill-column: 80
882  * scroll-step: 1
883  * End:
884  */
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:756
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:361
struct m0_sm rs_sm
Definition: reqh_service.h:245
struct m0_fid sc_fid
Definition: reqh_service.h:752
struct m0_fid sc_fid_process
Definition: reqh_service.h:754
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:774
m0_reqh_service_level
Definition: reqh_service.h:620
enum m0_conf_service_type rst_typecode
Definition: reqh_service.h:472
unsigned rs_level
Definition: reqh_service.h:237
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:400
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:451
struct m0_sm sc_sm
Definition: reqh_service.h:766
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:779
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:294
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:282
struct m0_reqh_context rctx
Definition: buf.h:37
struct m0_sm_group sc_sm_grp
Definition: reqh_service.h:767
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:761
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:388
m0_service_health
Definition: reqh_service.h:307
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:740
int(* rso_fop_accept)(struct m0_reqh_service *service, struct m0_fop *fop)
Definition: reqh_service.h:409
const char * rst_name
Definition: reqh_service.h:448
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:221
struct m0_reqh_context * rs_reqh_ctx
Definition: reqh_service.h:272
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:734
enum m0_service_health(* rso_health)(struct m0_reqh_service *service)
Definition: reqh_service.h:418
enum m0_conf_service_type sc_type
Definition: reqh_service.h:758
Definition: xcode.h:73
m0_reqh_service_state
Definition: reqh_service.h:157
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:250
Definition: fom.h:481
struct m0_clink sc_rlink_wait
Definition: reqh_service.h:762
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:436
struct m0_clink sc_process_event
Definition: reqh_service.h:784
struct m0_tlink stx_tlink
Definition: reqh_service.h:742
Definition: fid.h:38
const struct m0_reqh_service_type * rs_type
Definition: reqh_service.h:228
void(* rso_prepare_to_stop)(struct m0_reqh_service *service)
Definition: reqh_service.h:372
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:763
static struct m0_fop * fop
Definition: item.c:57
struct m0_clink sc_svc_event
Definition: reqh_service.h:782
struct m0_tlink rs_linkage
Definition: reqh_service.h:267
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:777
struct m0_rpc_link sc_rlink
Definition: reqh_service.h:760
M0_INTERNAL void m0_reqh_service_ctx_fini(struct m0_reqh_service_ctx *ctx)
Definition: reqh_service.c:962
struct m0_reqh * rs_reqh
Definition: reqh_service.h:260
Definition: mutex.h:47
static struct m0_addb2_source * s
Definition: consumer.c:39
struct m0_tlink sc_link
Definition: reqh_service.h:770
uint64_t rs_magix
Definition: reqh_service.h:287
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:342
struct m0_reqh_service_txid sc_max_pending_tx
Definition: reqh_service.h:773
Definition: fop.h:80
struct m0_tlink rst_linkage
Definition: reqh_service.h:479
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:255
M0_INTERNAL struct m0_reqh_service_ctx * m0_reqh_service_ctx_from_session(struct m0_rpc_session *session)