Motr
M0
|
Data Structures | |
struct | m0 |
struct | m0_modlev |
struct | m0_moddep |
struct | m0_module |
struct | m0_module_type |
struct | m0_param_source |
Macros | |
#define | M0_MODDEP_INIT(other, src, dst) { .md_other = (other), .md_src = (src), .md_dst = (dst) } |
Enumerations | |
enum | m0_module_id { M0_MODULE_NET, M0_MODULE_UT, M0_MODULE_ADDB2, M0_MODULE_LOCALITY, M0_MODULE_HA, M0_MODULE_PROCESSOR, M0_MODULE_POOL, M0_MODULE_ISC, M0_MODULE_NR } |
enum | { M0_LEVEL_INST_PREPARE, M0_LEVEL_INST_QUIESCE_SYSTEM, M0_LEVEL_INST_ONCE, M0_LEVEL_INST_SUBSYSTEMS, M0_LEVEL_INST_READY } |
enum | { M0_MODLEV_NONE = -1, M0_MODLEV_MAX = 64, M0_MODDEP_MAX = 128 } |
Functions | |
M0_INTERNAL int | m0_init_once (struct m0 *instance) |
M0_INTERNAL void | m0_fini_once (void) |
M0_INTERNAL int | m0_subsystems_init (void) |
M0_INTERNAL void | m0_subsystems_fini (void) |
M0_INTERNAL int | m0_quiesce_init (void) |
M0_INTERNAL void | m0_quiesce_fini (void) |
M0_LOCKERS__DEFINE (M0_INTERNAL, m0_inst, m0, i_lockers) | |
M0_INTERNAL struct m0 * | m0_get (void) |
M0_INTERNAL void | m0_set (struct m0 *instance) |
static int | level_inst_enter (struct m0_module *module) |
static void | level_inst_leave (struct m0_module *module) |
M0_INTERNAL void | m0_instance_setup (struct m0 *instance) |
M0_LOCKERS__DECLARE (M0_INTERNAL, m0_inst, m0, 16) | |
static bool | moddeps_are_unique (const struct m0_moddep *arr, unsigned n) |
static bool | module_invariant (const struct m0_module *mod) |
static int | module_up (struct m0_module *module, int level) |
M0_INTERNAL int | m0_module_init (struct m0_module *module, int level) |
M0_INTERNAL void | m0_module_fini (struct m0_module *module, int level) |
M0_INTERNAL void | m0_module_dep_add (struct m0_module *m0, int l0, struct m0_module *m1, int l1) |
M0_INTERNAL void | m0_module_setup (struct m0_module *module, const char *name, const struct m0_modlev *level, int level_nr, struct m0 *instance) |
M0_TL_DESCR_DEFINE (m0_param_sources, "m0_param_sources", static, struct m0_param_source, ps_link, ps_magic, M0_PARAM_SOURCE_MAGIC, M0_PARAM_SOURCES_MAGIC) | |
M0_TL_DEFINE (m0_param_sources, M0_INTERNAL, struct m0_param_source) | |
static struct m0_tl * | param_sources (void) |
M0_INTERNAL void * | m0_param_get (const char *key) |
M0_INTERNAL void | m0_param_source_add (struct m0_param_source *src) |
M0_INTERNAL void | m0_param_source_del (struct m0_param_source *src) |
M0_TL_DECLARE (m0_param_sources, M0_INTERNAL, struct m0_param_source) | |
Variables | |
static const struct m0_modlev | levels_inst [] |
A module is part of Motr, which can be initialised or finalised. A module can correspond to a software module (e.g., lib/thread, reqh) or to a run-time entity (reqh instance, service, stob domain, etc.).
A module defines an ordered list of levels, corresponding to the states of module initialisation. E.g., a reqh instance module might have following levels:
0. m0_reqh structure initialised
With a level are associated entry and exit functions, executed when the level is entered and left.
There are dependencies between (module, level) pairs. A dependency
* (m0, l0) -> (m1, l1) *
means that the module m1 must be at least at the level l1 before the module m0 can enter the level l0. For example there can be a dependency
* (reqh_instance, locality_handler_threads_started) -> \ * (lib_thread, initialised) *
specifying that threading subsystem should be initialised before reqh can start threads.
It's important to understand that dependencies exist between (module, level) pairs rather than between modules. Because of this, a potential dependency cycle can be broken by introducing an additional level, instead of a more expensive operation of introducing an additional module.
The collection of modules is not fixed. An entry function of a module can add more modules and dependencies to the system. For example, one of m0d levels fetches configuration information from confc. The list of services to be run on this m0d is obtained from confc, and modules, corresponding to the services are added, with appropriate dependencies. After this m0d initialisation continues, taking new modules and dependencies into account.
Dependencies organize modules in an acyclic graph, which is not necessarily a tree. Flexible initialisation is achieved by adding special nodes in this graph. E.g., a unit test can introduce a module, depending on subsystems that the test needs. To prepare for the test, this module is initialised, starting subsystems. Another well-known nodes in this graph are m0t1fs_instance and m0d_instance: first is a module representing a m0t1fs mount point, depending on all subsystems that m0t1fs needs. The latter represents an m0d process.
As an example of a long(ish) chain of dependencies consider:
0. network starts
m0_param API is used to configure initialisation: Motr modules use m0_param_get() to obtain external information.
anonymous enum |
Levels of m0 instance.
Enumerator | |
---|---|
M0_LEVEL_INST_PREPARE | m0_param_source_add(), m0_param_source_del(), m0_param_get() may not be used before m0::i_self enters M0_LEVEL_INST_PREPARE or after it leaves it. |
M0_LEVEL_INST_QUIESCE_SYSTEM | Layer subsystem non-reloaded for reconfigure Motr. |
M0_LEVEL_INST_ONCE | |
M0_LEVEL_INST_SUBSYSTEMS | |
M0_LEVEL_INST_READY | The "fully initialised" level, which the users of m0 instance should m0_module_init() it to. M0_LEVEL_INST_READY depends on a particular set of modules, according to the use case (UT, m0t1fs, m0d, etc.). |
Definition at line 171 of file instance.h.
anonymous enum |
enum m0_module_id |
Identifiers of standard modules.
Enumerator | |
---|---|
M0_MODULE_NET | |
M0_MODULE_UT | |
M0_MODULE_ADDB2 | |
M0_MODULE_LOCALITY | |
M0_MODULE_HA | |
M0_MODULE_PROCESSOR | |
M0_MODULE_POOL | |
M0_MODULE_ISC | |
M0_MODULE_NR |
Definition at line 43 of file instance.h.
|
static |
|
static |
Definition at line 74 of file instance.c.
M0_INTERNAL void m0_fini_once | ( | void | ) |
M0_INTERNAL struct m0 * m0_get | ( | void | ) |
Returns current m0 instance.
In the kernel, there is only one instance. It is returned.
In user space, the instance is created by m0d early startup code and stored in thread-local storage. This instance is inherited by threads (i.e., when a thread is created it gets the instance of the creator and stores it in its TLS).
Theoretically, user space Motr can support multiple instances in the same address space.
Definition at line 41 of file instance.c.
M0_INTERNAL int m0_init_once | ( | struct m0 * | instance | ) |
M0_INTERNAL void m0_instance_setup | ( | struct m0 * | instance | ) |
Definition at line 110 of file instance.c.
M0_LOCKERS__DECLARE | ( | M0_INTERNAL | , |
m0_inst | , | ||
m0 | , | ||
16 | |||
) |
M0_LOCKERS__DEFINE | ( | M0_INTERNAL | , |
m0_inst | , | ||
m0 | , | ||
i_lockers | |||
) |
M0_INTERNAL void m0_module_fini | ( | struct m0_module * | module, |
int | level | ||
) |
M0_INTERNAL int m0_module_init | ( | struct m0_module * | module, |
int | level | ||
) |
Bring module at least to the given level.
This function is not self-cleaning: even if it fails, m0_module_fini() should be called.
Definition at line 131 of file module.c.
M0_INTERNAL void * m0_param_get | ( | const char * | key | ) |
M0_INTERNAL void m0_param_source_add | ( | struct m0_param_source * | src | ) |
Appends new element to m0::i_param_sources.
Definition at line 56 of file param.c.
M0_INTERNAL void m0_param_source_del | ( | struct m0_param_source * | src | ) |
Deletes ‘src’ from m0::i_param_sources.
Definition at line 62 of file param.c.
M0_INTERNAL void m0_quiesce_fini | ( | void | ) |
M0_INTERNAL int m0_quiesce_init | ( | void | ) |
M0_INTERNAL void m0_set | ( | struct m0 * | instance | ) |
Stores given pointer in thread-local storage.
Definition at line 48 of file instance.c.
M0_INTERNAL void m0_subsystems_fini | ( | void | ) |
M0_INTERNAL int m0_subsystems_init | ( | void | ) |
M0_TL_DECLARE | ( | m0_param_sources | , |
M0_INTERNAL | , | ||
struct m0_param_source | |||
) |
M0_TL_DEFINE | ( | m0_param_sources | , |
M0_INTERNAL | , | ||
struct m0_param_source | |||
) |
M0_TL_DESCR_DEFINE | ( | m0_param_sources | , |
"m0_param_sources" | , | ||
static | , | ||
struct m0_param_source | , | ||
ps_link | , | ||
ps_magic | , | ||
M0_PARAM_SOURCE_MAGIC | , | ||
M0_PARAM_SOURCES_MAGIC | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 84 of file instance.c.