Motr
M0
|
Data Structures | |
struct | m0_reqh_service |
struct | m0_reqh_service_start_async_ctx |
struct | m0_reqh_service_ops |
struct | m0_reqh_service_type_ops |
struct | m0_reqh_service_type |
struct | m0_reqh_service_txid |
struct | m0_reqh_service_ctx |
Enumerations | |
enum | { M0_REQH_SVC_RPC_SERVICE_TYPE, REQH_SVC_CONNECT_TIMEOUT = 1 } |
enum | m0_reqh_service_state { M0_RST_INITIALISING, M0_RST_INITIALISED, M0_RST_STARTING, M0_RST_STARTED, M0_RST_STOPPING, M0_RST_STOPPED, M0_RST_FAILED } |
enum | m0_service_health { M0_HEALTH_GOOD = 0, M0_HEALTH_BAD = 1, M0_HEALTH_INACTIVE = 2, M0_HEALTH_UNKNOWN = 3 } |
enum | m0_reqh_service_level { M0_RS_LEVEL_UNKNOWN = 0, M0_RS_LEVEL_EARLIEST = 5, M0_RS_LEVEL_EARLY = 10, M0_RS_LEVEL_BEFORE_NORMAL = 20, M0_RS_LEVEL_NORMAL = 30, M0_RS_LEVEL_AFTER_NORMAL = 40, M0_RS_LEVEL_LATE = 50, M0_BE_TX_SVC_LEVEL = M0_RS_LEVEL_EARLY, M0_SS_SVC_LEVEL = M0_RS_LEVEL_BEFORE_NORMAL, M0_RM_SVC_LEVEL = M0_RS_LEVEL_BEFORE_NORMAL + 1, M0_MD_SVC_LEVEL = M0_RS_LEVEL_NORMAL, M0_HA_LINK_SVC_LEVEL = M0_RS_LEVEL_BEFORE_NORMAL - 1, M0_FDMI_SVC_LEVEL = M0_RS_LEVEL_BEFORE_NORMAL - 1, M0_HA_ENTRYPOINT_SVC_LEVEL = M0_RS_LEVEL_BEFORE_NORMAL - 1, M0_RPC_SVC_LEVEL = M0_HA_LINK_SVC_LEVEL - 1 } |
Variables | |
static struct m0_tl | rstypes |
static struct m0_rwlock | rstypes_rwlock |
static struct m0_bob_type | rstypes_bob |
static const struct m0_bob_type | reqh_svc_ctx |
static struct m0_sm_state_descr | service_states [] |
const struct m0_sm_conf | service_states_conf |
static struct m0_sm_state_descr | service_ctx_states [] |
static const struct m0_sm_conf | service_ctx_states_conf |
A motr service is described to a request handler using a struct m0_reqh_service_type data structure. Every service should register its corresponding m0_reqh_service_type instance containing service specific initialisation method, service name. Once the service type is defined it should be registered using m0_reqh_service_type_register() and unregister using m0_reqh_service_type_unregister(). During service type registration, the service type is added to the global list of the service types maintained by the request handler module. The request handler creates and initialises a service by invoking the constructor method of its service type, and obtains struct m0_reqh_service instance. The constructor should perform only internal house keeping tasks. Next, the service start method is invoked, it should properly initialise the internal state of the service, e.g. service fops, &c.
Request handler creates an rpc_machine for each specified end point per network domain. There could be multiple rpc machines running within a single request handler, resulting in the associated services being reachable through all of these end points.
Services need to be registered before they can be started. Service registration can be done as below,
First, we have to define service type operations,
Typical service specific start and stop operations may look like below,
Request Handler Service State Diagram A typical service transitions through its states as illustrated below. The triggering subroutine is identified, and the service method or service type method invoked is shown within square braces.
m0_reqh_service_allocate() <<START>> ---------------------> M0_RST_INITIALISING [rsto_service_allocate()] | | m0_reqh_service_init() m0_reqh_service_failed() v +------------------------------ M0_RST_INITIALISED | | m0_reqh_service_start_async()/ | | m0_reqh_service_start() v m0_reqh_service_failed() v +------------------------------ M0_RST_STARTING [rso_start[_async]()] | | m0_reqh_service_started()/ v | m0_reqh_service_start() M0_RST_FAILED v | M0_RST_STARTED | m0_reqh_service_fini() | m0_reqh_service_prepare_to_stop()/ v | m0_reqh_service_stop() <<END>> [rso_fini()] v ^ M0_RST_STOPPING [rso_prepare_to_stop()] | | | | m0_reqh_service_stop() | m0_reqh_service_fini() v +------------------------------ M0_RST_STOPPED [rso_stop()]
anonymous enum |
Definition at line 66 of file reqh_service.c.
Fine-grained REQH service level definitions.
Enumerator | |
---|---|
M0_RS_LEVEL_UNKNOWN | |
M0_RS_LEVEL_EARLIEST | |
M0_RS_LEVEL_EARLY | |
M0_RS_LEVEL_BEFORE_NORMAL | |
M0_RS_LEVEL_NORMAL | |
M0_RS_LEVEL_AFTER_NORMAL | |
M0_RS_LEVEL_LATE | |
M0_BE_TX_SVC_LEVEL | |
M0_SS_SVC_LEVEL | M0_SS_SVC_LEVEL must be >= M0_RS_LEVEL_BEFORE_NORMAL. This prevents finalisation of reqh resources before using the resources by ss_fom. Also SPIEL requires it to be less than M0_RS_LEVEL_NORMAL. |
M0_RM_SVC_LEVEL | |
M0_MD_SVC_LEVEL | |
M0_HA_LINK_SVC_LEVEL | |
M0_FDMI_SVC_LEVEL | Ignore during svc idle checks, stop earlier. |
M0_HA_ENTRYPOINT_SVC_LEVEL | |
M0_RPC_SVC_LEVEL |
Definition at line 619 of file reqh_service.h.
Phases through which a service typically passes.
Enumerator | |
---|---|
M0_RST_INITIALISING | A service is in M0_RST_INITIALISING state when it is created. in service specific start routine, once the service specific initialisation is complete, generic part of service is initialised.
|
M0_RST_INITIALISED | A service transitions to M0_RST_INITIALISED state, once it is successfully initialised.
|
M0_RST_STARTING | A service transitions to M0_RST_STARTING state before service specific start routine is invoked. |
M0_RST_STARTED | A service transitions to M0_RST_STARTED state when it is ready to process FOP requests. |
M0_RST_STOPPING | A service transitions to M0_RST_STOPPING state before the service specific rso_stop() routine is invoked. The optional rso_prepare_to_stop() method will be called when this state is entered. This gives a service a chance to trigger FOM termination before its rso_stop() method is invoked. |
M0_RST_STOPPED | A service transitions to M0_RST_STOPPED state, once service specific rso_stop() routine completes successfully and after it is unregistered from the request handler.
|
M0_RST_FAILED | A service transitions to M0_RST_FAILED state if the service start up fails. |
Definition at line 156 of file reqh_service.h.
enum m0_service_health |
Health status of the service or the motr process
Definition at line 306 of file reqh_service.h.
|
static |
Definition at line 1296 of file reqh_service.c.
M0_BOB_DEFINE | ( | static | , |
& | rstypes_bob, | ||
m0_reqh_service_type | |||
) |
M0_BOB_DEFINE | ( | static | , |
& | reqh_svc_ctx, | ||
m0_reqh_service_ctx | |||
) |
M0_INTERNAL int m0_reqh_service_allocate | ( | struct m0_reqh_service ** | service, |
const struct m0_reqh_service_type * | stype, | ||
struct m0_reqh_context * | rctx | ||
) |
Allocates and initialises service of given type.
Definition at line 185 of file reqh_service.c.
int m0_reqh_service_async_start_simple | ( | struct m0_reqh_service_start_async_ctx * | asc | ) |
Implementation of simple .rso_start_async().
Definition at line 601 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_cancel_reconnect | ( | struct m0_reqh_service_ctx * | ctx | ) |
Re-establishes rpc connection asynchronously after cancelling rpc_items.
Definition at line 852 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_connect | ( | struct m0_reqh_service_ctx * | ctx | ) |
Establishes rpc connection asynchronously.
Definition at line 730 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_connect_wait | ( | struct m0_reqh_service_ctx * | ctx | ) |
Waits until rpc connection is established.
Definition at line 822 of file reqh_service.c.
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 ** | ctx | ||
) |
Allocates and initialises m0_reqh_service_ctx for the given service type.
Definition at line 1249 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_ctx_destroy | ( | struct m0_reqh_service_ctx * | ctx | ) |
Finalises and destroys given service context.
Definition at line 1274 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_ctx_fini | ( | struct m0_reqh_service_ctx * | ctx | ) |
Definition at line 971 of file reqh_service.c.
M0_INTERNAL struct m0_reqh_service_ctx * m0_reqh_service_ctx_from_session | ( | struct m0_rpc_session * | session | ) |
Returns the outer m0_reqh_service_ctx from a m0_rpc_session.
Definition at line 1281 of file reqh_service.c.
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 | ||
) |
Definition at line 1208 of file reqh_service.c.
M0_INTERNAL bool m0_reqh_service_ctx_is_connected | ( | const struct m0_reqh_service_ctx * | ctx | ) |
Returns true if m0_reqh_service_connect() is called for the ‘ctx’.
Definition at line 760 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_ctx_subscribe | ( | struct m0_reqh_service_ctx * | ctx | ) |
Subscribes context to its service & process HA notifications.
Definition at line 693 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_ctx_unsubscribe | ( | struct m0_reqh_service_ctx * | ctx | ) |
Unsubscribes context from its service & process HA notifications.
Definition at line 702 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_ctxs_shutdown_prepare | ( | struct m0_reqh * | reqh | ) |
Iterates typed list m0_pools_common::pc_svc_ctxs and prepares all the contexts to REQH shutdown.
Service context may appear to be (re)connecting, and in this sense incomplete, when REQH services are about to shutdown. To free fom domains the respective rpc link foms are in the incomplete contexts need to be told to go offline instead.
Besides, every context gets unsubscribed from HA notifications here to have shutdown process undisturbed by cluster events.
Definition at line 892 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_disconnect | ( | struct m0_reqh_service_ctx * | ctx | ) |
Terminates rpc connection asynchronously.
Definition at line 781 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_disconnect_wait | ( | struct m0_reqh_service_ctx * | ctx | ) |
Waits until rpc connection is terminated.
Definition at line 831 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_failed | ( | struct m0_reqh_service * | service | ) |
Fail the service because it could not initialize itself.
Definition at line 326 of file reqh_service.c.
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find | ( | const struct m0_reqh_service_type * | st, |
const struct m0_reqh * | reqh | ||
) |
Returns service instance of the given service type. Search is done through "active" services (m0_reqh_service_start_{async}() is called and they are not stopped yet).
Definition at line 538 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_fini | ( | struct m0_reqh_service * | service | ) |
Performs generic part of service finalisation, including deregistering the service with its request handler. This is invoked before service specific finalisation routine.
service | Service to be finalised |
Definition at line 457 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_init | ( | struct m0_reqh_service * | service, |
struct m0_reqh * | reqh, | ||
const struct m0_fid * | fid | ||
) |
Performs generic part of service initialisation. Transitions service into M0_RST_INITIALISED state This is invoked after the service specific init routine returns successfully.
service | service to be initialised |
reqh | Request handler |
fid | Pointer to service fid or NULL if not known. |
Definition at line 428 of file reqh_service.c.
M0_INTERNAL bool m0_reqh_service_invariant | ( | const struct m0_reqh_service * | service | ) |
Checks consistency of a particular service.
Definition at line 143 of file reqh_service.c.
M0_INTERNAL bool m0_reqh_service_is_registered | ( | const char * | sname | ) |
M0_INTERNAL void m0_reqh_service_list_print | ( | void | ) |
Definition at line 504 of file reqh_service.c.
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_lookup | ( | const struct m0_reqh * | reqh, |
const struct m0_fid * | fid | ||
) |
Search for service in given request handler by fid. Search is done through all initialized services
Definition at line 551 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_prepare_to_stop | ( | struct m0_reqh_service * | service | ) |
Transitions the service to the M0_RST_STOPPING state and invoke its rso_prepare_to_stop() method if it is defined. It is a no-op if the state was M0_RST_STOPPING on entry.
Definition at line 375 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_quit | ( | struct m0_reqh_service * | svc | ) |
Dual to m0_reqh_service_setup(), stops and finalises the service.
Definition at line 588 of file reqh_service.c.
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 | ||
) |
A helper function that allocates, initialises and starts a service of the given type.
Definition at line 565 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_start | ( | struct m0_reqh_service * | service | ) |
Starts a particular service synchronously. Invokes service specific start routine, if service specific startup completes Successfully then the service is registered with the request handler and transitioned into M0_RST_STARTED state.
Definition at line 343 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_start_async | ( | struct m0_reqh_service_start_async_ctx * | asc | ) |
Transition a service into the starting state and initiate the asynchrous initialization of the service with the rso_start_async() operation.
asc | Asynchronous service context, duly initialized. |
Definition at line 272 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_started | ( | struct m0_reqh_service * | service | ) |
Complete the transition to the started state. The service gets registered with the request handler.
service | The service that has completed startup activities initiated with m0_reqh_service_start_async(). |
Definition at line 311 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_state_get | ( | const struct m0_reqh_service * | s | ) |
M0_INTERNAL void m0_reqh_service_stop | ( | struct m0_reqh_service * | service | ) |
Stops a particular service. Transitions the service to M0_RST_STOPPED state. The service is still registered with the request handler.
service | Service to be stopped |
Definition at line 402 of file reqh_service.c.
M0_INTERNAL struct m0_reqh_service_type * m0_reqh_service_type_find | ( | const char * | sname | ) |
Searches a particular type of service by traversing global list of service types maintained by request handler module.
sname,name | of the service to be searched in global list |
Definition at line 168 of file reqh_service.c.
int m0_reqh_service_type_register | ( | struct m0_reqh_service_type * | rstype | ) |
Registers a service type in a global service types list, i.e. rstypes.
Definition at line 473 of file reqh_service.c.
void m0_reqh_service_type_unregister | ( | struct m0_reqh_service_type * | rstype | ) |
Unregisters a service type from a global service types list, i.e. rstypes.
Definition at line 490 of file reqh_service.c.
M0_INTERNAL void m0_reqh_service_types_fini | ( | void | ) |
Finalises global list of service types. This is invoked from m0_reqhs_fini();
Definition at line 530 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_types_init | ( | void | ) |
Initialises global list of service types. This is invoked from m0_reqhs_init().
Definition at line 520 of file reqh_service.c.
M0_INTERNAL int m0_reqh_service_types_length | ( | void | ) |
Definition at line 499 of file reqh_service.c.
M0_TL_DECLARE | ( | abandoned_svc_ctxs | , |
M0_EXTERN | , | ||
struct m0_reqh_service_ctx | |||
) |
M0_TL_DEFINE | ( | rstypes | , |
static | , | ||
struct m0_reqh_service_type | |||
) |
M0_TL_DESCR_DECLARE | ( | abandoned_svc_ctxs | , |
M0_EXTERN | |||
) |
M0_TL_DESCR_DEFINE | ( | rstypes | , |
"reqh service types" | , | ||
static | , | ||
struct m0_reqh_service_type | , | ||
rst_linkage | , | ||
rst_magix | , | ||
M0_REQH_SVC_TYPE_MAGIC | , | ||
M0_REQH_SVC_HEAD_MAGIC | |||
) |
|
static |
Connect/Disconnect service context on process event from HA.
Definition at line 1089 of file reqh_service.c.
|
static |
Definition at line 718 of file reqh_service.c.
|
static |
Definition at line 686 of file reqh_service.c.
|
static |
Definition at line 993 of file reqh_service.c.
|
static |
Destroys service context if found in m0_pools_common::pc_abandoned_svc_ctxs list.
Definition at line 1311 of file reqh_service.c.
|
static |
Definition at line 884 of file reqh_service.c.
|
static |
Definition at line 1066 of file reqh_service.c.
|
static |
Definition at line 801 of file reqh_service.c.
|
static |
Definition at line 766 of file reqh_service.c.
|
static |
Definition at line 262 of file reqh_service.c.
|
static |
Definition at line 207 of file reqh_service.c.
|
static |
Definition at line 836 of file reqh_service.c.
|
static |
Definition at line 868 of file reqh_service.c.
|
static |
Definition at line 305 of file reqh_service.c.
|
static |
Definition at line 245 of file reqh_service.c.
|
static |
Definition at line 236 of file reqh_service.c.
|
static |
Cancel items for service on service failure event from HA.
Definition at line 1154 of file reqh_service.c.
|
static |
|
static |
Definition at line 91 of file reqh_service.c.
|
static |
static global list of service types. Holds struct m0_reqh_service_type instances linked via m0_reqh_service_type::rst_linkage.
Definition at line 64 of file reqh_service.c.
|
static |
Definition at line 88 of file reqh_service.c.
|
static |
Protects access to list rstypes.
Definition at line 80 of file reqh_service.c.
|
static |
State diagram.
* * ,-------> M0_RSC_OFFLINE * | | * | error v * |`------ M0_RSC_CONNECTING * | | * | | success * | v * | M0_RSC_ONLINE -------> M0_RSC_CANCELLED * | | | * | v | * `------ M0_RSC_DISCONNECTING <-----------' * *
M0_RSC_OFFLINE is initial and final state. After m0_reqh_service_connect() is called the service context transits to M0_RSC_CONNECTING every time it reaches M0_RSC_OFFLINE until m0_reqh_service_disconnect() is called.
Service context transits to M0_RSC_ONLINE when sc_rlink
is established and sc_rlink.rlk_sess
can be used.
In M0_RSC_CONNECTING and M0_RSC_DISCONNECTING states sc_rlink
must not be accessed. Exception is reqh_service_ctx_ast_cb() callback, which is called after rpc_link
receives "operation completed" notification. Therefore, all operations with sc_rlink
are deferred and performed inside reqh_service_ctx_ast_cb()
in these states.
Rpc session can be cancelled only in M0_RSC_ONLINE state. If service becomes unavailable in other state, service context keeps trying to connect until sc_rlink
is established. Cancelled session is always reconnected.
Definition at line 654 of file reqh_service.c.
|
static |
Definition at line 680 of file reqh_service.c.
|
static |
Definition at line 100 of file reqh_service.c.
const struct m0_sm_conf service_states_conf |
Definition at line 133 of file reqh_service.c.