Motr  M0
setup.c File Reference
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <err.h>
#include "lib/trace.h"
#include "lib/assert.h"
#include "lib/errno.h"
#include "lib/finject.h"
#include "lib/string.h"
#include "lib/getopts.h"
#include "lib/memory.h"
#include "lib/misc.h"
#include "lib/locality.h"
#include "lib/uuid.h"
#include "lib/fs.h"
#include "lib/thread.h"
#include "fid/fid.h"
#include "stob/ad.h"
#include "net/net.h"
#include "net/lnet/lnet.h"
#include "rpc/rpc.h"
#include "reqh/reqh.h"
#include "cob/cob.h"
#include "mdstore/mdstore.h"
#include "motr/setup.h"
#include "motr/setup_dix.h"
#include "motr/setup_internal.h"
#include "motr/magic.h"
#include "motr/version.h"
#include "rpc/rpclib.h"
#include "rpc/rpc_internal.h"
#include "addb2/storage.h"
#include "addb2/net.h"
#include "module/instance.h"
#include "conf/obj.h"
#include "conf/helpers.h"
#include "conf/obj_ops.h"
#include "be/ut/helper.h"
#include "ioservice/fid_convert.h"
#include "ioservice/storage_dev.h"
#include "ioservice/io_service.h"
#include "stob/linux.h"
#include "conf/ha.h"
#include "dtm0/helper.h"
Include dependency graph for setup.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_M0D
 
#define CS_MODULE_LEVEL(level)
 

Enumerations

enum  { M0_BC_REPAIR_ZONE_SAFETY_MUL = 1, M0_BC_REPAIR_ZONE_SAFETY_DIV = 1, M0_BC_REPAIR_ZONE_MAX_ALLOWED = 40 }
 
enum  cs_level {
  CS_LEVEL_MOTR_INIT, CS_LEVEL_BUFFER_POOL_AND_NET_DOMAINS_FINI_WORKAROUND, CS_LEVEL_REQH_CTX_INIT, CS_LEVEL_CS_INIT,
  CS_LEVEL_RWLOCK_LOCK, CS_LEVEL_ARGS_PARSE, CS_LEVEL_REQH_CTX_VALIDATE, CS_LEVEL_DAEMONIZE,
  CS_LEVEL_NET_DOMAINS_INIT, CS_LEVEL_BUFFER_POOL_SETUP, CS_LEVEL_REQH_START, CS_LEVEL_RPC_MACHINES_INIT,
  CS_LEVEL_HA_INIT, CS_LEVEL_HA_CONNECT_ATTEMPT1, CS_LEVEL_REQH_STOP_WORKAROUND, CS_LEVEL_RCONFC_INIT_START,
  CS_LEVEL_CONF_GET, CS_LEVEL_CONF_FULL_LOAD, CS_LEVEL_CONF_SERVICES_INIT, CS_LEVEL_CONF_TO_ARGS,
  CS_LEVEL_CONF_ARGS_PARSE, CS_LEVEL_HA_CONNECT_ATTEMPT2, CS_LEVEL_POOLS_COMMON_INIT, CS_LEVEL_POOLS_SETUP,
  CS_LEVEL_SET_OOSTORE, CS_LEVEL_REQH_CTX_SERVICES_VALIDATE, CS_LEVEL_CONF_FS_CONFC_CLOSE, CS_LEVEL_STORAGE_SETUP,
  CS_LEVEL_DTM0_INIT, CS_LEVEL_RWLOCK_UNLOCK, CS_LEVEL_STARTED_EVENT_FOR_MKFS, CS_LEVEL_RCONFC_FATAL_CALLBACK,
  CS_LEVEL_DIX_SETUP, CS_LEVEL_SETUP_ENV, CS_LEVEL_CHECK_CONFIG, CS_LEVEL_CONF_GET2,
  CS_LEVEL_POOLS_SERVICE_CTX_CREATE, CS_LEVEL_POOL_VERSIONS_SETUP, CS_LEVEL_REQH_SERVICES_START, CS_LEVEL_REQH_MDPOOL_LAYOUTS_SETUP,
  CS_LEVEL_CONF_CONFC_HA_UPDATE, CS_LEVEL_CONF_FS_CONFC_CLOSE2, CS_LEVEL_STARTED_EVENT_FOR_M0D, CS_LEVEL_START
}
 

Functions

 M0_TL_DESCR_DEFINE (cs_buffer_pools, "buffer pools in the motr context", static, struct cs_buffer_pool, cs_bp_linkage, cs_bp_magic, M0_CS_BUFFER_POOL_MAGIC, M0_CS_BUFFER_POOL_HEAD_MAGIC)
 
 M0_TL_DEFINE (cs_buffer_pools, static, struct cs_buffer_pool)
 
 M0_TL_DESCR_DEFINE (cs_eps, "cs endpoints",, struct cs_endpoint_and_xprt, ex_linkage, ex_magix, M0_CS_ENDPOINT_AND_XPRT_MAGIC, M0_CS_EPS_HEAD_MAGIC)
 
 M0_TL_DEFINE (cs_eps, M0_INTERNAL, struct cs_endpoint_and_xprt)
 
 M0_BOB_DEFINE (extern, &cs_eps_bob, cs_endpoint_and_xprt)
 
static bool reqh_context_check (const void *bob)
 
 M0_BOB_DEFINE (static, &rhctx_bob, m0_reqh_context)
 
 M0_TL_DESCR_DEFINE (ndom, "network domains", static, struct m0_net_domain, nd_app_linkage, nd_magix, M0_NET_DOMAIN_MAGIC, M0_CS_NET_DOMAIN_HEAD_MAGIC)
 
 M0_TL_DEFINE (ndom, static, struct m0_net_domain)
 
 M0_BOB_DEFINE (static, &ndom_bob, m0_net_domain)
 
 M0_BOB_DEFINE (static inline, &cs_bob_type, m0_motr)
 
static bool reqh_ctx_services_are_valid (const struct m0_reqh_context *rctx)
 
static bool reqh_context_invariant (const struct m0_reqh_context *rctx)
 
static struct m0_reqhmotr2reqh (struct m0_motr *motr)
 
static struct m0_rconfcmotr2rconfc (struct m0_motr *motr)
 
M0_INTERNAL struct m0_confcm0_motr2confc (struct m0_motr *motr)
 
M0_INTERNAL struct m0_rpc_machinem0_motr_to_rmach (struct m0_motr *motr)
 
static struct m0_net_xprtcs_xprt_lookup (const char *xprt_name, struct m0_net_xprt **xprts, size_t xprts_nr)
 
static void cs_xprts_list (FILE *out, struct m0_net_xprt **xprts, size_t xprts_nr)
 
static void cs_stob_types_list (FILE *out)
 
static bool stype_is_valid (const char *stype)
 
static bool cs_endpoint_is_duplicate (const struct m0_reqh_context *rctx, const struct m0_net_xprt *xprt, const char *ep)
 
static int cs_endpoint_validate (struct m0_motr *cctx, const char *ep, const char *xprt_name)
 
M0_INTERNAL int m0_ep_and_xprt_extract (struct cs_endpoint_and_xprt *epx, const char *ep)
 
M0_INTERNAL void m0_ep_and_xprt_fini (struct cs_endpoint_and_xprt *epx)
 
static int ep_and_xprt_append (struct m0_tl *head, const char *ep)
 
static bool service_is_duplicate (const struct m0_reqh_context *rctx, const char *sname)
 
static int cs_reqh_ctx_init (struct m0_motr *cctx)
 
static void cs_reqh_ctx_fini (struct m0_reqh_context *rctx)
 
M0_INTERNAL struct m0_net_domainm0_cs_net_domain_locate (struct m0_motr *cctx, const char *xprt_name)
 
static struct m0_net_buffer_poolcs_buffer_pool_get (struct m0_motr *cctx, struct m0_net_domain *ndom)
 
static int cs_rpc_machine_init (struct m0_motr *cctx, const char *xprt_name, const char *ep, const uint32_t tm_colour, const uint32_t recv_queue_min_length, const uint32_t max_rpc_msg_size, struct m0_reqh *reqh)
 
static int cs_rpc_machines_init (struct m0_motr *cctx)
 
static void cs_rpc_machines_fini (struct m0_reqh *reqh)
 
static int cs_ha_init (struct m0_motr *cctx)
 
static bool bad_address (char *addr)
 
static void cs_ha_process_event (struct m0_motr *cctx, enum m0_conf_ha_process_event event)
 
static void cs_ha_stop (struct m0_motr *cctx)
 
static void cs_ha_fini (struct m0_motr *cctx)
 
static uint32_t cs_domain_tms_nr (struct m0_reqh_context *rctx, struct m0_net_domain *dom)
 
static uint32_t cs_dom_tm_min_recv_queue_total (struct m0_reqh_context *rctx, struct m0_net_domain *dom)
 
static void cs_buffer_pool_fini (struct m0_motr *cctx)
 
static int cs_buffer_pool_setup (struct m0_motr *cctx)
 
static int stob_file_id_get (yaml_document_t *doc, yaml_node_t *node, uint64_t *id)
 
static const char * stob_file_path_get (yaml_document_t *doc, yaml_node_t *node)
 
static int cs_stob_file_load (const char *dfile, struct cs_stobs *stob)
 
static void cs_storage_devs_fini (void)
 
static int cs_storage_devs_init (struct cs_stobs *stob, enum m0_storage_dev_type type, struct m0_be_seg *seg, const char *stob_path, bool force, bool disable_direct_io)
 
static char * cs_storage_ldom_location_gen (const char *stob_path)
 
static int cs_storage_ldom_destroy (const char *stob_path, const char *str_cfg_init)
 
static int cs_storage_bstore_prepare (const char *stob_path, const char *str_cfg_init, uint64_t dom_key, bool mkfs, struct m0_stob_domain **out)
 
static int cs_storage_init (const char *stob_type, const char *stob_path, uint64_t dom_key, struct cs_stobs *stob, struct m0_be_seg *seg, bool mkfs, bool force, bool disable_direct_io)
 
static void cs_storage_fini (struct cs_stobs *stob)
 
M0_INTERNAL int cs_service_init (const char *name, struct m0_reqh_context *rctx, struct m0_reqh *reqh, struct m0_fid *fid)
 
static int reqh_context_services_init (struct m0_reqh_context *rctx, struct m0_motr *cctx)
 
M0_INTERNAL void cs_service_fini (struct m0_reqh_service *service)
 
static void reqh_context_services_fini (struct m0_reqh_context *rctx, struct m0_motr *cctx)
 
static int reqh_services_start (struct m0_reqh_context *rctx, struct m0_motr *cctx)
 
static int cs_net_domain_init (struct cs_endpoint_and_xprt *ep, struct m0_motr *cctx)
 
static int cs_net_domains_init (struct m0_motr *cctx)
 
static void cs_net_domains_fini (struct m0_motr *cctx)
 
static int cs_storage_prepare (struct m0_reqh_context *rctx, bool erase)
 
static void be_seg_init (struct m0_be_ut_backend *be, m0_bcount_t size, bool preallocate, bool format, const char *stob_create_cfg, struct m0_be_seg **out)
 
static bool pver_is_actual (const struct m0_conf_obj *obj)
 
static int be_repair_zone_pcnt_get (struct m0_reqh *reqh, uint32_t *repair_zone_pcnt)
 
static int cs_be_dom_cfg_zone_pcnt_fill (struct m0_reqh *reqh, struct m0_be_domain_cfg *dom_cfg)
 
static int cs_be_init (struct m0_reqh_context *rctx, struct m0_be_ut_backend *be, const char *name, bool preallocate, bool format, struct m0_be_seg **out)
 
M0_INTERNAL void cs_be_fini (struct m0_be_ut_backend *be)
 
static int cs_reqh_start (struct m0_reqh_context *rctx)
 
static int cs_storage_setup (struct m0_motr *cctx)
 
static int cs_dtm0_init (struct m0_reqh_context *rctx)
 
static void cs_dtm0_fini (struct m0_reqh_context *rctx)
 
static void cs_reqh_shutdown (struct m0_reqh_context *rctx)
 
static void cs_reqh_stop (struct m0_reqh_context *rctx)
 
static void cs_reqh_storage_fini (struct m0_reqh_context *rctx)
 
struct m0_reqhm0_cs_reqh_get (struct m0_motr *cctx)
 
M0_INTERNAL struct m0_reqh_contextm0_cs_reqh_context (struct m0_reqh *reqh)
 
M0_INTERNAL struct m0_motrm0_cs_ctx_get (struct m0_reqh *reqh)
 
M0_INTERNAL struct m0_storage_devsm0_cs_storage_devs_get (void)
 
static void cs_motr_init (struct m0_motr *cctx)
 
static void cs_motr_fini (struct m0_motr *cctx)
 
static void cs_usage (FILE *out, const char *progname)
 
static void cs_help (FILE *out, const char *progname)
 
static int cs_reqh_ctx_validate (struct m0_motr *cctx)
 
static int cs_reqh_ctx_services_validate (struct m0_motr *cctx)
 
static int cs_daemonize (struct m0_motr *cctx)
 
static int process_fid_parse (const char *str, struct m0_fid *fid)
 
static void process_fid_generate_conditional (struct m0_reqh_context *rctx)
 
static int _args_parse (struct m0_motr *cctx, int argc, char **argv)
 
static int cs_args_parse (struct m0_motr *cctx, int argc, char **argv)
 
static void cs_ha_connect (struct m0_motr *cctx)
 
static int cs_conf_setup (struct m0_motr *cctx)
 
static void cs_conf_fini (struct m0_motr *cctx)
 
static int cs_reqh_mdpool_layouts_setup (struct m0_motr *cctx)
 
static void cs_rconfc_fatal_cb (struct m0_rconfc *rconfc)
 
M0_INTERNAL void m0_cs_gotsignal_reset (void)
 
static struct m0_motrcs_module2motr (struct m0_module *module)
 
static int cs_level_enter (struct m0_module *module)
 
static void cs_level_leave (struct m0_module *module)
 
int m0_cs_setup_env (struct m0_motr *cctx, int argc, char **argv)
 
int m0_cs_start (struct m0_motr *cctx)
 
int m0_cs_init (struct m0_motr *cctx, struct m0_net_xprt **xprts, size_t xprts_nr, FILE *out, bool mkfs)
 
void m0_cs_fini (struct m0_motr *cctx)
 
M0_INTERNAL int m0_motr_stob_reopen (struct m0_reqh *reqh, struct m0_poolmach *pm, uint32_t dev_id)
 

Variables

struct m0_reqh_service_type m0_ss_svc_type
 
static struct m0_bob_type cs_eps_bob
 
M0_INTERNAL const char * m0_cs_stypes [M0_STOB_TYPE_NR]
 
static struct m0_bob_type rhctx_bob
 
static struct m0_bob_type ndom_bob
 
static const struct m0_bob_type cs_bob_type
 
volatile sig_atomic_t gotsignal
 
static const struct m0_modlev cs_module_levels []
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_M0D

Definition at line 28 of file setup.c.