Motr
M0
|
#include "lib/memory.h"
#include "lib/errno.h"
#include "lib/uuid.h"
#include "lib/finject.h"
#include "lib/arith.h"
#include "lib/mutex.h"
#include "lib/time.h"
#include "addb2/global.h"
#include "addb2/sys.h"
#include "fid/fid.h"
#include "conf/ha.h"
#include "conf/helpers.h"
#include "conf/confc.h"
#include "rpc/rpclib.h"
#include "pool/pool.h"
#include "rm/rm_service.h"
#include "net/lnet/lnet_core_types.h"
#include "dtm0/service.h"
#include "dtm0/helper.h"
#include "motr/io.h"
#include "motr/client.h"
#include "motr/addb.h"
#include "motr/client_internal.h"
#include "motr/layout.h"
#include "lib/trace.h"
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT |
#define | NOT_EMPTY(x) (x != NULL && *x != '\0') |
Enumerations | |
enum | initlift_states { IL_UNINITIALISED = 0, IL_NET, IL_RPC, IL_AST_THREAD, IL_HA, IL_CONFC, IL_POOLS, IL_POOL_VERSION, IL_RESOURCE_MANAGER, IL_LAYOUT_DB, IL_IDX_SERVICE, IL_ROOT_FID, IL_ADDB2, IL_DTM0, IL_INITIALISED, IL_FAILED } |
Functions | |
M0_BOB_DEFINE (static, &m0c_bobtype, m0_client) | |
static int | initlift_uninitialised (struct m0_sm *mach) |
static int | initlift_net (struct m0_sm *mach) |
static int | initlift_rpc (struct m0_sm *mach) |
static int | initlift_ast_thread (struct m0_sm *mach) |
static int | initlift_ha (struct m0_sm *mach) |
static int | initlift_confc (struct m0_sm *mach) |
static int | initlift_pools (struct m0_sm *mach) |
static int | initlift_pool_version (struct m0_sm *mach) |
static int | initlift_resource_manager (struct m0_sm *mach) |
static int | initlift_layouts (struct m0_sm *mach) |
static int | initlift_idx_service (struct m0_sm *mach) |
static int | initlift_rootfid (struct m0_sm *mach) |
static int | initlift_addb2 (struct m0_sm *mach) |
static int | initlift_dtm0 (struct m0_sm *mach) |
static bool | m0c_invariant (struct m0_client *m0c) |
static struct m0_rconfc * | rconfc (struct m0_client *m0c) |
M0_INTERNAL struct m0_confc * | m0_confc (struct m0_client *m0c) |
static int | client_fid_sscanf (const char *s, struct m0_fid *fid, const char *descr) |
static int | initlift_get_next_floor (struct m0_client *m0c) |
static void | initlift_move_next_floor (struct m0_client *m0c) |
static void | initlift_fail (int rc, struct m0_client *m0c) |
static void | client_net_fini (struct m0_client *m0c) |
static int | client_net_init (struct m0_client *m0c) |
static void | rpc_fini (struct m0_client *m0c) |
static int | rpc_init (struct m0_client *m0c) |
static void | ast_thread (struct m0_client *m0c) |
static void | ha_process_event (struct m0_client *m0c, enum m0_conf_ha_process_event event) |
static int | ha_init (struct m0_client *m0c) |
static void | ha_fini (struct m0_client *m0c) |
static bool | rconfc_expired_cb (struct m0_clink *clink) |
static bool | rconfc_ready_cb (struct m0_clink *clink) |
static void | rconfc_fatal_cb (struct m0_rconfc *rconfc) |
static void | io_ref_cb (struct m0_ref *ref) |
static bool | confc_ready_async_cb (struct m0_clink *clink) |
M0_INTERNAL int | m0__io_ref_get (struct m0_client *m0c) |
M0_INTERNAL void | m0__io_ref_put (struct m0_client *m0c) |
static int | confc_init (struct m0_client *m0c) |
static void | confc_fini (struct m0_client *m0c) |
static int | pools_init (struct m0_client *m0c) |
static void | pools_fini (struct m0_client *m0c) |
static int | service_start (struct m0_reqh *reqh, struct m0_fid *sfid, struct m0_reqh_service_type *stype, struct m0_reqh_service **service) |
static int | rootfid_lookup (struct m0_client *m0c) |
M0_INTERNAL void | m0_client_global_fini (void) |
static int | get_online_cpus (void) |
M0_INTERNAL int | m0_client_global_init (void) |
int | m0_client_init (struct m0_client **m0c_p, struct m0_config *conf, bool init_m0) |
void | m0_client_fini (struct m0_client *m0c, bool fini_m0) |
void | m0_process_fid (const struct m0_client *m0c, struct m0_fid *proc_fid) |
Variables | |
static const struct m0_bob_type | m0c_bobtype |
struct m0_conf_root * | conf_root |
struct m0_sm_state_descr | initlift_phases [] |
struct m0_sm_trans_descr | initlift_trans [] |
struct m0_sm_conf | initlift_conf |
static struct m0_motr_ha_cfg | motr_ha_cfg |
static struct m0 | m0_client_motr_instance |
#define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT |
Definition at line 49 of file client_init.c.
enum initlift_states |
The Initialisation code in client is fiddly, lots of different parts of motr need to be initialised in the correct order, if something fails, all the parts that have been initialised need to be finalised and an error returned.
This typically means that all the initialisation code needs to know how to finalise client too, while not being the finalisation code. A rats nest of implicit states need to be tracked by *_init functions, pinned down by a rack of gotos, so that init can 'fini' what it has done so far.
This gives us difficult to read duplicated code, which in turns gives us really-difficult-to-test code paths when one component fails to initialise.
Why not use a state machine? Client initialises these components, in this order. If something fails it automatically reverses and moves back to IL_UNINITIALISED.
Rule of thumb: if you need a goto, you are probably tracking some kind of state that should be added here instead.
Enumerator | |
---|---|
IL_UNINITIALISED | |
IL_NET | |
IL_RPC | |
IL_AST_THREAD | |
IL_HA | |
IL_CONFC | |
IL_POOLS | |
IL_POOL_VERSION | |
IL_RESOURCE_MANAGER | |
IL_LAYOUT_DB | |
IL_IDX_SERVICE | |
IL_ROOT_FID | |
IL_ADDB2 | |
IL_DTM0 | |
IL_INITIALISED | |
IL_FAILED |
Definition at line 92 of file client_init.c.
|
static |
This is heavily based on m0t1fs/linux_kernel/super.cast_thread
Definition at line 618 of file client_init.c.
|
static |
Definition at line 320 of file client_init.c.
|
static |
This is heavily based on m0t1fs/linux_kernel/super.cm0t1fs_net_fini
m0c | the client instance we are working with. |
Definition at line 423 of file client_init.c.
|
static |
This is heavily based on m0t1fs/linux_kernel/super.cm0t1fs_net_init. m0t1fs is a kernel model and it sets the local addr and other arguments when installing the kernel model. For Motr client, as it supports both user and kernel modes, it is not feasible to pass arguments as m0t1fs does, instead Client asks an applition to input local endpoint and others explictly. (comments on commit d56b031c)
m0c | the client instance we are working with. |
Definition at line 448 of file client_init.c.
|
static |
Definition at line 985 of file client_init.c.
|
static |
Definition at line 906 of file client_init.c.
|
static |
Definition at line 858 of file client_init.c.
|
static |
Retrieves the number of online CPUs
Definition at line 1482 of file client_init.c.
|
static |
Clears global HA session info and terminates rpc session to HA service.
Definition at line 751 of file client_init.c.
|
static |
Definition at line 715 of file client_init.c.
|
static |
HA service connectivity.
Definition at line 684 of file client_init.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Helper function to fail initialisation, move the lift into reverse and log the failing rc.
rc | the failing rc. |
m0c | the client instance we are working with. |
Definition at line 388 of file client_init.c.
|
static |
Helper function to get the value of the next floor in the direction of travel.
m0c | the client instance we are working with. |
Definition at line 338 of file client_init.c.
|
static |
|
static |
|
static |
|
static |
Helper function to move the initlift onto its next state in the direction of travel.
m0c | the client instance we are working with. |
Definition at line 363 of file client_init.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Forward declarations for state callbacks
Definition at line 398 of file client_init.c.
|
static |
Definition at line 834 of file client_init.c.
M0_INTERNAL int m0__io_ref_get | ( | struct m0_client * | m0c | ) |
Definition at line 868 of file client_init.c.
M0_INTERNAL void m0__io_ref_put | ( | struct m0_client * | m0c | ) |
Definition at line 897 of file client_init.c.
M0_BOB_DEFINE | ( | static | , |
& | m0c_bobtype, | ||
m0_client | |||
) |
M0_INTERNAL void m0_client_global_fini | ( | void | ) |
M0_INTERNAL int m0_client_global_init | ( | void | ) |
global init/fini, used by motr/init.c
Definition at line 1495 of file client_init.c.
Gets the confc from client instance.
m0c | client instance. |
Definition at line 315 of file client_init.c.
|
static |
Checks a m0_client struct is correct.
m0c | The client instance to check. |
Definition at line 305 of file client_init.c.
|
static |
Definition at line 1066 of file client_init.c.
|
static |
Definition at line 1031 of file client_init.c.
Definition at line 310 of file client_init.c.
|
static |
Definition at line 790 of file client_init.c.
|
static |
Definition at line 821 of file client_init.c.
|
static |
Definition at line 809 of file client_init.c.
|
static |
Lookup the fid of the root filesystem. This is a m0t1fsism.
m0c | The client instance we are working with. |
Definition at line 1282 of file client_init.c.
|
static |
This is heavily based on m0t1fs/linux_kernel/super.cm0t1fs_rpc_fini
m0c | the client instance we are working with. |
Definition at line 509 of file client_init.c.
|
static |
This is heavily based on m0t1fs/linux_kernel/super.cm0t1fs_rpc_init
m0c | the client instance we are working with. |
Definition at line 533 of file client_init.c.
|
static |
Definition at line 1129 of file client_init.c.
struct m0_conf_root* conf_root |
Pointer to the root configuration object that a Client client attaches to. It is closed after Client initilisation is done as it may become invalid at some point of time.
Definition at line 68 of file client_init.c.
struct m0_sm_conf initlift_conf |
Configuration structure for the client init state machine.
Definition at line 291 of file client_init.c.
struct m0_sm_state_descr initlift_phases[] |
State machine phases for client operations.
Definition at line 130 of file client_init.c.
struct m0_sm_trans_descr initlift_trans[] |
Textual descriptions for the valid state machine transitions.
Definition at line 225 of file client_init.c.
|
static |
Definition at line 1532 of file client_init.c.
|
static |
Definition at line 53 of file client_init.c.
|
static |
Establishes rpc session to HA service. The session is set up to be used globally.
Definition at line 714 of file client_init.c.