Motr  M0
Request handler service
Collaboration diagram for Request handler service:

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
}
 

Functions

 M0_TL_DESCR_DECLARE (abandoned_svc_ctxs, M0_EXTERN)
 
 M0_TL_DECLARE (abandoned_svc_ctxs, M0_EXTERN, struct m0_reqh_service_ctx)
 
 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)
 
 M0_TL_DEFINE (rstypes, static, struct m0_reqh_service_type)
 
 M0_BOB_DEFINE (static, &rstypes_bob, m0_reqh_service_type)
 
 M0_BOB_DEFINE (static, &reqh_svc_ctx, m0_reqh_service_ctx)
 
static void reqh_service_ctx_destroy_if_abandoned (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL bool m0_reqh_service_invariant (const struct m0_reqh_service *svc)
 
M0_INTERNAL struct m0_reqh_service_typem0_reqh_service_type_find (const char *sname)
 
M0_INTERNAL int m0_reqh_service_allocate (struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
 
static void reqh_service_ha_event (struct m0_reqh_service *service, enum m0_reqh_service_state state)
 
static void reqh_service_state_set (struct m0_reqh_service *service, enum m0_reqh_service_state state)
 
static void reqh_service_starting_common (struct m0_reqh *reqh, struct m0_reqh_service *service, unsigned key)
 
static void reqh_service_failed_common (struct m0_reqh *reqh, struct m0_reqh_service *service, unsigned key)
 
M0_INTERNAL int m0_reqh_service_start_async (struct m0_reqh_service_start_async_ctx *asc)
 
static void reqh_service_started_common (struct m0_reqh *reqh, struct m0_reqh_service *service)
 
M0_INTERNAL void m0_reqh_service_started (struct m0_reqh_service *service)
 
M0_INTERNAL void m0_reqh_service_failed (struct m0_reqh_service *service)
 
M0_INTERNAL int m0_reqh_service_start (struct m0_reqh_service *service)
 
M0_INTERNAL void m0_reqh_service_prepare_to_stop (struct m0_reqh_service *service)
 
M0_INTERNAL void m0_reqh_service_stop (struct m0_reqh_service *service)
 
M0_INTERNAL void m0_reqh_service_init (struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
 
M0_INTERNAL void m0_reqh_service_fini (struct m0_reqh_service *service)
 
int m0_reqh_service_type_register (struct m0_reqh_service_type *rstype)
 
void m0_reqh_service_type_unregister (struct m0_reqh_service_type *rstype)
 
M0_INTERNAL int m0_reqh_service_types_length (void)
 
M0_INTERNAL void m0_reqh_service_list_print (void)
 
M0_INTERNAL bool m0_reqh_service_is_registered (const char *sname)
 
M0_INTERNAL int m0_reqh_service_types_init (void)
 
M0_INTERNAL void m0_reqh_service_types_fini (void)
 
M0_INTERNAL struct m0_reqh_servicem0_reqh_service_find (const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
 
M0_INTERNAL struct m0_reqh_servicem0_reqh_service_lookup (const struct m0_reqh *reqh, const struct m0_fid *fid)
 
M0_INTERNAL int m0_reqh_service_state_get (const struct m0_reqh_service *s)
 
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)
 
M0_INTERNAL void m0_reqh_service_quit (struct m0_reqh_service *svc)
 
int m0_reqh_service_async_start_simple (struct m0_reqh_service_start_async_ctx *asc)
 
static bool service_type_is_valid (enum m0_conf_service_type t)
 
static bool reqh_service_context_invariant (const struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL void m0_reqh_service_ctx_subscribe (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL void m0_reqh_service_ctx_unsubscribe (struct m0_reqh_service_ctx *ctx)
 
static void reqh_service_connect_locked (struct m0_reqh_service_ctx *ctx, m0_time_t deadline)
 
M0_INTERNAL void m0_reqh_service_connect (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL bool m0_reqh_service_ctx_is_connected (const struct m0_reqh_service_ctx *ctx)
 
static void reqh_service_disconnect_locked (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL void m0_reqh_service_disconnect (struct m0_reqh_service_ctx *ctx)
 
static int reqh_service_ctx_state_wait (struct m0_reqh_service_ctx *ctx, int state)
 
M0_INTERNAL void m0_reqh_service_connect_wait (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL int m0_reqh_service_disconnect_wait (struct m0_reqh_service_ctx *ctx)
 
static void reqh_service_reconnect_locked (struct m0_reqh_service_ctx *ctx, const char *addr)
 
M0_INTERNAL void m0_reqh_service_cancel_reconnect (struct m0_reqh_service_ctx *ctx)
 
static void reqh_service_session_cancel (struct m0_reqh_service_ctx *ctx)
 
static bool reqh_service_ctx_is_cancelled (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL void m0_reqh_service_ctxs_shutdown_prepare (struct m0_reqh *reqh)
 
M0_INTERNAL void m0_reqh_service_ctx_fini (struct m0_reqh_service_ctx *ctx)
 
static void reqh_service_ctx_ast_cb (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static bool reqh_service_ctx_rlink_cb (struct m0_clink *clink)
 
static bool process_event_handler (struct m0_clink *clink)
 
static bool service_event_handler (struct m0_clink *clink)
 
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 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_ctx_destroy (struct m0_reqh_service_ctx *ctx)
 
M0_INTERNAL struct m0_reqh_service_ctxm0_reqh_service_ctx_from_session (struct m0_rpc_session *session)
 
static void abandoned_ctx_destroy_cb (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 

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
 

Detailed Description

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,

static const struct m0_reqh_service_type_ops dummy_stype_ops = {
};

Typical service specific start and stop operations may look like below,

{
...
rc = dummy_fops_init();
...
}
{
...
dummy_fops_fini();
...
}

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()]

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
M0_REQH_SVC_RPC_SERVICE_TYPE 
REQH_SVC_CONNECT_TIMEOUT 

Timeout for rpc_link connect operation in seconds. If endpoint is unreachable the timeout allows to disconnect from reqh service when -ETIMEDOUT is returned.

Definition at line 66 of file reqh_service.c.

◆ m0_reqh_service_level

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.

◆ m0_reqh_service_state

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.

See also
m0_reqh_service_allocate()
M0_RST_INITIALISED 

A service transitions to M0_RST_INITIALISED state, once it is successfully initialised.

See also
m0_reqh_service_init()
M0_RST_STARTING 

A service transitions to M0_RST_STARTING state before service specific start routine is invoked.

See also
m0_reqh_service_start_async(), m0_reqh_service_start()
M0_RST_STARTED 

A service transitions to M0_RST_STARTED state when it is ready to process FOP requests.

See also
m0_reqh_service_started(), m0_reqh_service_start()
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.

See also
m0_reqh_service_prepare_to_stop(), m0_reqh_service_stop()
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.

See also
m0_reqh_service_stop()
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.

◆ m0_service_health

Health status of the service or the motr process

See also
m0_spiel_service_health, m0_spiel_process_health
m0_reqh_service_ops::rso_health
Enumerator
M0_HEALTH_GOOD 

Good health (service is able to process incoming requests, process is running, etc.)

M0_HEALTH_BAD 

Something wrong with the resource

M0_HEALTH_INACTIVE 

Service isn't in M0_RST_STARTED state

M0_HEALTH_UNKNOWN 

Health unknown (e.g. service doesn't implement ::rso_health)

Definition at line 306 of file reqh_service.h.

Function Documentation

◆ abandoned_ctx_destroy_cb()

static void abandoned_ctx_destroy_cb ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 1296 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ M0_BOB_DEFINE() [1/2]

M0_BOB_DEFINE ( static  ,
rstypes_bob,
m0_reqh_service_type   
)

◆ M0_BOB_DEFINE() [2/2]

M0_BOB_DEFINE ( static  ,
reqh_svc_ctx,
m0_reqh_service_ctx   
)

◆ m0_reqh_service_allocate()

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.

Precondition
service != NULL && stype != NULL
Postcondition
ergo(retval == 0, m0_reqh_service_invariant(service))
See also
struct m0_reqh_service_type_ops

Definition at line 185 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_async_start_simple()

int m0_reqh_service_async_start_simple ( struct m0_reqh_service_start_async_ctx asc)

Implementation of simple .rso_start_async().

Note
: Currently all services uses simple async service start which is not really async implementation. But later it may require to implement async service startup.

Definition at line 601 of file reqh_service.c.

Here is the call graph for this function:

◆ m0_reqh_service_cancel_reconnect()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_connect()

M0_INTERNAL void m0_reqh_service_connect ( struct m0_reqh_service_ctx ctx)

Establishes rpc connection asynchronously.

Precondition
m0_conf_cache_is_locked(ctx->sc_service->co_cache)

Definition at line 730 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_connect_wait()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_create()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_destroy()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_fini()

M0_INTERNAL void m0_reqh_service_ctx_fini ( struct m0_reqh_service_ctx ctx)

Definition at line 971 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_from_session()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_init()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_is_connected()

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’.

Note
Result doesn't reflect actual connection state.

Definition at line 760 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_subscribe()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctx_unsubscribe()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_ctxs_shutdown_prepare()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_disconnect()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_disconnect_wait()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_failed()

M0_INTERNAL void m0_reqh_service_failed ( struct m0_reqh_service service)

Fail the service because it could not initialize itself.

Precondition
m0_reqh_service_state_get(service) == M0_RST_STARTING
Postcondition
m0_reqh_service_state_get(service) == M0_RST_FAILED

Definition at line 326 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_find()

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).

See also
m0_reqh_service_lookup

Definition at line 538 of file reqh_service.c.

Here is the caller graph for this function:

◆ m0_reqh_service_fini()

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.

Parameters
serviceService to be finalised
Precondition
service != NULL
See also
struct m0_reqh_service_ops
m0_reqh_services_terminate()

Definition at line 457 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_init()

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.

Parameters
serviceservice to be initialised
reqhRequest handler
fidPointer to service fid or NULL if not known.
Precondition
service != NULL && reqh != NULL && service->rs_sm.sm_state == M0_RST_INITIALISING
See also
struct m0_reqh_service_type_ops
cs_service_init()

Definition at line 428 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_invariant()

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.

Here is the caller graph for this function:

◆ m0_reqh_service_is_registered()

M0_INTERNAL bool m0_reqh_service_is_registered ( const char *  sname)

Definition at line 514 of file reqh_service.c.

Here is the caller graph for this function:

◆ m0_reqh_service_list_print()

M0_INTERNAL void m0_reqh_service_list_print ( void  )

Definition at line 504 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_lookup()

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

See also
m0_reqh_service_find

Definition at line 551 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_prepare_to_stop()

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.

Precondition
service != NULL
M0_IN(m0_reqh_service_state_get(service), (M0_RST_STARTED, M0_RST_STOPPING))
Postcondition
m0_reqh_service_state_get(service) == M0_RST_STOPPING

Definition at line 375 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_quit()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_setup()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_start()

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.

Precondition
m0_reqh_service_state_get(service) == M0_RST_INITIALIZED
Postcondition
m0_reqh_service_state_get(service) == M0_RST_STARTED
See also
struct m0_reqh_service_ops

Definition at line 343 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_start_async()

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.

Parameters
ascAsynchronous service context, duly initialized.
Precondition
m0_reqh_service_state_get(service) == M0_RST_INITIALIZED
asc->sac_service->rs_ops->rso_start_async != NULL
Postcondition
m0_reqh_service_state_get(service) == M0_RST_STARTING

Definition at line 272 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_started()

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.

Parameters
serviceThe service that has completed startup activities initiated with m0_reqh_service_start_async().
Precondition
m0_reqh_service_state_get(service) == M0_RST_STARTING
Postcondition
m0_reqh_service_state_get(service) == M0_RST_STARTED

Definition at line 311 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_state_get()

M0_INTERNAL int m0_reqh_service_state_get ( const struct m0_reqh_service s)

Definition at line 560 of file reqh_service.c.

Here is the caller graph for this function:

◆ m0_reqh_service_stop()

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.

Parameters
serviceService to be stopped
Precondition
service != NULL
M0_IN(m0_reqh_service_state_get(service), (M0_RST_STARTED, M0_RST_STOPPING))
Postcondition
m0_reqh_service_state_get(service) == M0_RST_STOPPED
See also
struct m0_reqh_service_ops
m0_reqh_service_prepare_to_stop()
m0_reqh_services_terminate()

Definition at line 402 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_type_find()

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.

Parameters
sname,nameof the service to be searched in global list
Precondition
sname != NULL
See also
m0_reqh_service_init()

Definition at line 168 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_type_register()

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.

Precondition
rstype != NULL && rstype->rst_magix == M0_RHS_MAGIC

Definition at line 473 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_type_unregister()

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.

Precondition
rstype != NULL

Definition at line 490 of file reqh_service.c.

Here is the caller graph for this function:

◆ m0_reqh_service_types_fini()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_types_init()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_reqh_service_types_length()

M0_INTERNAL int m0_reqh_service_types_length ( void  )

Definition at line 499 of file reqh_service.c.

◆ M0_TL_DECLARE()

M0_TL_DECLARE ( abandoned_svc_ctxs  ,
M0_EXTERN  ,
struct m0_reqh_service_ctx   
)

◆ M0_TL_DEFINE()

M0_TL_DEFINE ( rstypes  ,
static  ,
struct m0_reqh_service_type   
)

◆ M0_TL_DESCR_DECLARE()

M0_TL_DESCR_DECLARE ( abandoned_svc_ctxs  ,
M0_EXTERN   
)

◆ M0_TL_DESCR_DEFINE()

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   
)

◆ process_event_handler()

static bool process_event_handler ( struct m0_clink clink)
static

Connect/Disconnect service context on process event from HA.

Definition at line 1089 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_connect_locked()

static void reqh_service_connect_locked ( struct m0_reqh_service_ctx ctx,
m0_time_t  deadline 
)
static

Definition at line 718 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_context_invariant()

static bool reqh_service_context_invariant ( const struct m0_reqh_service_ctx ctx)
static

Definition at line 686 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ctx_ast_cb()

static void reqh_service_ctx_ast_cb ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 993 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ctx_destroy_if_abandoned()

static void reqh_service_ctx_destroy_if_abandoned ( struct m0_reqh_service_ctx ctx)
static

Destroys service context if found in m0_pools_common::pc_abandoned_svc_ctxs list.

Definition at line 1311 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ctx_is_cancelled()

static bool reqh_service_ctx_is_cancelled ( struct m0_reqh_service_ctx ctx)
static

Definition at line 884 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ctx_rlink_cb()

static bool reqh_service_ctx_rlink_cb ( struct m0_clink clink)
static

Definition at line 1066 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ctx_state_wait()

static int reqh_service_ctx_state_wait ( struct m0_reqh_service_ctx ctx,
int  state 
)
static

Definition at line 801 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_disconnect_locked()

static void reqh_service_disconnect_locked ( struct m0_reqh_service_ctx ctx)
static

Definition at line 766 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_failed_common()

static void reqh_service_failed_common ( struct m0_reqh reqh,
struct m0_reqh_service service,
unsigned  key 
)
static

Definition at line 262 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_ha_event()

static void reqh_service_ha_event ( struct m0_reqh_service service,
enum m0_reqh_service_state  state 
)
static

Definition at line 207 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_reconnect_locked()

static void reqh_service_reconnect_locked ( struct m0_reqh_service_ctx ctx,
const char *  addr 
)
static

Definition at line 836 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_session_cancel()

static void reqh_service_session_cancel ( struct m0_reqh_service_ctx ctx)
static

Definition at line 868 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_started_common()

static void reqh_service_started_common ( struct m0_reqh reqh,
struct m0_reqh_service service 
)
static

Definition at line 305 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_starting_common()

static void reqh_service_starting_common ( struct m0_reqh reqh,
struct m0_reqh_service service,
unsigned  key 
)
static

Definition at line 245 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reqh_service_state_set()

static void reqh_service_state_set ( struct m0_reqh_service service,
enum m0_reqh_service_state  state 
)
static

Definition at line 236 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ service_event_handler()

static bool service_event_handler ( struct m0_clink clink)
static

Cancel items for service on service failure event from HA.

Definition at line 1154 of file reqh_service.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ service_type_is_valid()

static bool service_type_is_valid ( enum m0_conf_service_type  t)
static

Definition at line 612 of file reqh_service.c.

Here is the caller graph for this function:

Variable Documentation

◆ reqh_svc_ctx

const struct m0_bob_type reqh_svc_ctx
static
Initial value:
= {
.bt_name = "m0_reqh_service_ctx",
.bt_magix_offset = M0_MAGIX_OFFSET(struct m0_reqh_service_ctx,
sc_magic),
.bt_magix = M0_REQH_SVC_CTX_MAGIC,
.bt_check = NULL
}
#define NULL
Definition: misc.h:38
#define M0_MAGIX_OFFSET(type, field)
Definition: misc.h:356

Definition at line 91 of file reqh_service.c.

◆ rstypes

struct m0_tl rstypes
static

static global list of service types. Holds struct m0_reqh_service_type instances linked via m0_reqh_service_type::rst_linkage.

See also
struct m0_reqh_service_type

Definition at line 64 of file reqh_service.c.

◆ rstypes_bob

struct m0_bob_type rstypes_bob
static

Definition at line 88 of file reqh_service.c.

◆ rstypes_rwlock

struct m0_rwlock rstypes_rwlock
static

Protects access to list rstypes.

Definition at line 80 of file reqh_service.c.

◆ service_ctx_states

struct m0_sm_state_descr service_ctx_states[]
static
Initial value:
= {
.sd_name = "M0_RSC_OFFLINE",
.sd_allowed = M0_BITS(M0_RSC_CONNECTING)
},
.sd_name = "M0_RSC_ONLINE",
},
.sd_name = "M0_RSC_CONNECTING",
.sd_allowed = M0_BITS(M0_RSC_ONLINE,
},
.sd_name = "M0_RSC_DISCONNECTING",
.sd_allowed = M0_BITS(M0_RSC_OFFLINE)
},
.sd_name = "M0_RSC_CANCELLED",
},
}
#define M0_BITS(...)
Definition: misc.h:236

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.

◆ service_ctx_states_conf

const struct m0_sm_conf service_ctx_states_conf
static
Initial value:
= {
.scf_name = "Service ctx connection states",
.scf_nr_states = ARRAY_SIZE(service_ctx_states),
.scf_state = service_ctx_states
}
static struct m0_sm_state_descr service_ctx_states[]
Definition: reqh_service.c:654
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 680 of file reqh_service.c.

◆ service_states

struct m0_sm_state_descr service_states[]
static

Definition at line 100 of file reqh_service.c.

◆ service_states_conf

const struct m0_sm_conf service_states_conf
Initial value:
= {
.scf_name = "Service states",
.scf_nr_states = ARRAY_SIZE(service_states),
.scf_state = service_states
}
static struct m0_sm_state_descr service_states[]
Definition: reqh_service.c:100
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 133 of file reqh_service.c.