23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CONF 322 .sd_name =
"S_INITIAL",
325 .sd_invariant =
NULL,
330 .sd_name =
"S_CHECK",
339 .sd_name =
"S_WAIT_REPLY",
342 .sd_invariant =
NULL,
348 .sd_name =
"S_WAIT_STATUS",
351 .sd_invariant =
NULL,
356 .sd_name =
"S_RETRY_CONFD",
359 .sd_invariant =
NULL,
364 .sd_name =
"S_SKIP_CONFD",
367 .sd_invariant =
NULL,
372 .sd_name =
"S_GROW_CACHE",
375 .sd_invariant =
NULL,
380 .sd_name =
"S_FAILURE",
388 .sd_name =
"S_TERMINAL",
397 .
scf_name =
"states of m0_confc_ctx::fc_mach",
398 .scf_nr_states =
S_NR,
427 return m0_confc_bob_check(
confc);
433 return m0_confc_ctx_bob_check(
ctx);
460 return s !=
NULL && *
s !=
'\0';
542 m0_confc_bob_init(
confc);
579 m0_confc_bob_fini(
confc);
664 return M0_ERR_INFO(-EPERM,
"Conf reading is not allowed" 670 ctx->fc_ast.sa_datum =
ctx;
672 m0_confc_ctx_bob_init(
ctx);
673 ctx->fc_finalized =
false;
688 ctx->fc_finalized =
true;
706 if (
ctx->fc_rpc_item !=
NULL) {
711 m0_confc_ctx_bob_fini(
ctx);
762 return ctx->fc_mach.sm_rc;
768 return ctx->fc_mach.sm_rc;
852 const struct m0_fid *path)
860 if (origin ==
NULL) {
861 ctx->fc_origin =
ctx->fc_confc->cc_root;
889 ctx->fc_origin = origin;
901 const struct m0_fid *path)
976 for (
i = 0;
i < dest_sz && !
eop(&
src[
i]); ++
i)
998 dir->co_cache == &
ctx->fc_confc->cc_cache);
1001 rc =
dir->co_ops->coo_readdir(
dir, pptr);
1088 static const int next_state[] = {
1107 return next_state[
rc];
1173 ctx->fc_confc->cc_gops->go_skip !=
NULL);
1176 rc =
ctx->fc_confc->cc_gops->go_skip(
ctx->fc_confc);
1186 M0_LEAVE(
"rc=%d retval=%s",
rc,
rc == 0 ?
"S_CHECK" :
"S_FAILURE");
1223 M0_LEAVE(
"rc=%d retval=%s",
rc,
rc == 0 ?
"S_CHECK" :
"S_FAILURE");
1270 if (
ctx->fc_confc->cc_gops !=
NULL &&
1271 ctx->fc_confc->cc_gops->go_skip !=
NULL)
1273 else if (
rc == -EAGAIN)
1300 return mach->sm_rc == 0 &&
ctx->fc_result ==
NULL &&
1307 return ctx->fc_result ==
NULL &&
ctx->fc_mach.sm_rc < 0;
1314 return mach->sm_rc == 0;
1319 return &
ctx->fc_confc->cc_cache.ca_ver;
1378 for (
rc = 0,
obj =
ctx->fc_origin, ri = 0;
1414 switch (
obj->co_status) {
1483 state =
ctx->fc_ast_datum;
1498 if (
ctx->fc_confc ==
NULL ||
ctx->fc_finalized) {
1515 rc =
ctx->fc_ast_datum;
1527 ctx->fc_ast_datum = datum;
1562 return M0_ERR_INFO(-EPROTO,
"Conflict of incoming and cached " 1563 "configuration data: src="FID_F" dest="FID_F,
1804 item = &
p->cf_fop.f_item;
1812 for (len = 0; !
eop(&
ctx->fc_path[ri + len]); ++len)
1814 req->f_path.af_count = len;
1815 req->f_path.af_elems = len == 0 ?
NULL : &
ctx->fc_path[ri];
1877 #undef M0_TRACE_SUBSYSTEM const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
M0_INTERNAL int m0_rpc_post(struct m0_rpc_item *item)
struct m0_sm_group * cc_group
static struct m0_addb2_philter p
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
struct m0_conf_obj * cc_root
static bool check_st_invariant(const struct m0_sm *mach)
M0_INTERNAL void m0_sm_fail(struct m0_sm *mach, int fail_state, int32_t rc)
M0_INTERNAL void m0_confx_free(struct m0_confx *enc)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
const struct m0_conf_obj_type * m0_conf_objx_type(const struct m0_confx_obj *obj)
M0_INTERNAL bool m0_conf_obj_match(const struct m0_conf_obj *cached, const struct m0_confx_obj *flat)
M0_INTERNAL bool m0_chan_is_locked(const struct m0_chan *ch)
static int path_walk(struct m0_confc_ctx *ctx)
static int path_copy(const struct m0_fid *src, struct m0_fid *dest, size_t dest_sz)
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
M0_INTERNAL void m0_clink_del(struct m0_clink *link)
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
static void _state_fail(struct m0_sm_group *grp M0_UNUSED, struct m0_sm_ast *ast)
void(* sa_cb)(struct m0_sm_group *grp, struct m0_sm_ast *)
M0_INTERNAL struct m0_conf_obj * m0_confc_ctx_result(struct m0_confc_ctx *ctx)
const m0_time_t M0_TIME_NEVER
static bool _ctx_check(const void *bob)
static struct io_request req
static int request_create(struct m0_confc_ctx *ctx, const struct m0_conf_obj *orig, size_t ri)
M0_INTERNAL struct m0_rpc_conn * m0_confc2conn(struct m0_confc *confc)
M0_INTERNAL int m0_rpc_link_init(struct m0_rpc_link *rlink, struct m0_rpc_machine *mach, struct m0_fid *svc_fid, const char *ep, uint64_t max_rpcs_in_flight)
static struct m0_sm_group * grp
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
M0_INTERNAL void m0_fop_init(struct m0_fop *fop, struct m0_fop_type *fopt, void *data, void(*fop_release)(struct m0_ref *))
void m0_rpc_item_put(struct m0_rpc_item *item)
#define M0_LOG(level,...)
static const struct m0_confc_ctx * const_mach_to_ctx(const struct m0_sm *mach)
M0_INTERNAL void m0_sm_ast_post(struct m0_sm_group *grp, struct m0_sm_ast *ast)
bool(* go_check)(struct m0_confc *confc)
struct m0_rpc_conn rlk_conn
void m0_rpc_item_get(struct m0_rpc_item *item)
static int confc_cache_preload(struct m0_confc *confc, const char *local_conf)
M0_INTERNAL int m0_confc_init(struct m0_confc *confc, struct m0_sm_group *sm_group, const char *confd_addr, struct m0_rpc_machine *rpc_mach, const char *local_conf)
static bool _confc_check(const void *bob)
M0_INTERNAL void m0_conf_obj_put(struct m0_conf_obj *obj)
static bool confc_group_is_locked(const struct m0_confc *confc)
static int failure_st_in(struct m0_sm *mach)
static m0_time_t confc_deadline(const struct m0_confc *confc)
void * m0_fop_data(const struct m0_fop *fop)
M0_INTERNAL void m0_confc_fini(struct m0_confc *confc)
M0_INTERNAL int32_t m0_confc_ctx_error_lock(const struct m0_confc_ctx *ctx)
M0_INTERNAL bool m0_clink_is_armed(const struct m0_clink *link)
static struct m0_addb2_mach * mach
M0_INTERNAL void m0_rpc_link_fini(struct m0_rpc_link *rlink)
static const struct m0_sm_conf confc_ctx_states_conf
#define M0_CONFX_AT(cx, idx)
struct m0_conf_cache * co_cache
#define container_of(ptr, type, member)
M0_INTERNAL void m0_confc_open_by_fid(struct m0_confc_ctx *ctx, const struct m0_fid *fid)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
static int confc_cache_create(struct m0_confc *confc, const char *local_conf)
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
static struct m0_rpc_item * item
static void ctx_state_fail(struct m0_confc_ctx *ctx, int rc)
M0_INTERNAL int m0_confc_reconnect(struct m0_confc *confc, struct m0_rpc_machine *rpc_mach, const char *confd_addr)
static int retry_confd_st_in(struct m0_sm *mach)
static const struct m0_rpc_item_ops confc_item_ops
#define m0_confc_open(ctx, origin,...)
M0_INTERNAL int m0_conf_obj_fill(struct m0_conf_obj *dest, const struct m0_confx_obj *src)
static struct m0_sm_ast ast[NR]
static void clink_cleanup_fini(struct m0_clink *link)
M0_INTERNAL void m0_conf_obj_get(struct m0_conf_obj *obj)
struct m0_rpc_machine * c_rpc_machine
struct m0_confc_gate_ops * cc_gops
static int wait_reply_st_in(struct m0_sm *mach)
#define M0_ERR_INFO(rc, fmt,...)
return M0_ERR(-EOPNOTSUPP)
struct m0_confc_ctx w_ctx
M0_INTERNAL void m0_rpc_machine_unlock(struct m0_rpc_machine *machine)
static void confc_group_unlock(const struct m0_confc *confc)
static int cache_grow(struct m0_confc *confc, const struct m0_conf_fetch_resp *resp)
M0_INTERNAL void m0_confc_ctx_fini(struct m0_confc_ctx *ctx)
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
M0_INTERNAL void m0_confc_ctx_fini_locked(struct m0_confc_ctx *ctx)
static struct m0_confc * confc
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
static struct m0_confc_ctx * item_to_ctx(const struct m0_rpc_item *item)
void m0_sm_state_set(struct m0_sm *mach, int state)
M0_INTERNAL bool m0_confc_ctx_is_completed(const struct m0_confc_ctx *ctx)
#define bob_of(ptr, type, field, bt)
struct m0_clink * cl_group
M0_INTERNAL void m0_conf_cache_init(struct m0_conf_cache *cache, struct m0_mutex *lock)
bool(* go_drain)(struct m0_clink *clink)
M0_INTERNAL bool m0_confc_is_online(const struct m0_confc *confc)
M0_INTERNAL int m0_confc_ctx_init(struct m0_confc_ctx *ctx, struct m0_confc *confc)
static int connect_to_confd(struct m0_confc *confc, const char *confd_addr, struct m0_rpc_machine *rpc_mach)
struct m0_conf_cache cc_cache
const char * confd_addr[]
static void _state_set(struct m0_sm_group *grp M0_UNUSED, struct m0_sm_ast *ast)
static bool not_empty(const char *s)
static int object_enrich(struct m0_conf_obj *dest, const struct m0_confx_obj *src, struct m0_confc *confc)
const struct m0_rpc_item_type * ri_type
M0_INTERNAL bool m0_confc_ctx_is_completed_lock(const struct m0_confc_ctx *ctx)
struct m0_rpc_item * ri_reply
static void confc_group_lock(const struct m0_confc *confc)
static bool ctx_invariant(const struct m0_confc_ctx *ctx)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
static bool sm__filter(struct m0_clink *link)
static int grow_cache_st_in(struct m0_sm *mach)
M0_INTERNAL int m0_conf_obj_find_lock(struct m0_conf_cache *cache, const struct m0_fid *id, struct m0_conf_obj **out)
static bool request_check(const struct m0_confc_ctx *ctx)
M0_INTERNAL int m0_conf_obj_find(struct m0_conf_cache *cache, const struct m0_fid *id, struct m0_conf_obj **out)
struct m0_confc_ctx * cf_ctx
M0_INTERNAL int m0_fop_data_alloc(struct m0_fop *fop)
M0_INTERNAL int m0_confc__open_sync(struct m0_conf_obj **result, struct m0_conf_obj *origin, const struct m0_fid *path)
#define M0_CONF_CAST(ptr, type)
M0_INTERNAL bool m0_confc_is_inited(const struct m0_confc *confc)
M0_INTERNAL int m0_rpc_link_disconnect_sync(struct m0_rpc_link *rlink, m0_time_t abs_timeout)
bool m0_conf_fid_is_valid(const struct m0_fid *fid)
static struct fdmi_ctx ctx
M0_INTERNAL void m0_chan_signal_lock(struct m0_chan *chan)
M0_INTERNAL int m0_rpc_link_connect_sync(struct m0_rpc_link *rlink, m0_time_t abs_timeout)
void(* rio_replied)(struct m0_rpc_item *item)
static void confc_fop_release(struct m0_ref *ref)
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
struct m0_rpc_link cc_rlink
int32_t m0_rpc_item_error(const struct m0_rpc_item *item)
static void confc_unlock(struct m0_confc *confc)
#define M0_MAGIX_OFFSET(type, field)
static void on_replied(struct m0_rpc_item *item)
M0_BOB_DEFINE(static, &confc_bob, m0_confc)
static bool eop(const struct m0_fid *buf)
M0_INTERNAL void m0_confc_gate_ops_set(struct m0_confc *confc, struct m0_confc_gate_ops *gops)
static bool terminal_st_invariant(const struct m0_sm *mach)
struct m0_mutex cc_unatt_guard
static struct m0_confc_ctx * mach_to_ctx(struct m0_sm *mach)
static void conf_obj_status_reset(struct m0_confc_ctx *ctx)
M0_INTERNAL int m0_confstr_parse(const char *str, struct m0_confx **out)
static int sm_waiter_wait(struct sm_waiter *w, struct m0_conf_obj **result)
void m0_rpc_item_put_lock(struct m0_rpc_item *item)
static int sm_waiter_init(struct sm_waiter *w, struct m0_confc *confc)
#define M0_FI_ENABLED(tag)
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
M0_INTERNAL void m0_rpc_machine_lock(struct m0_rpc_machine *machine)
M0_INTERNAL void m0_confc__open(struct m0_confc_ctx *ctx, struct m0_conf_obj *origin, const struct m0_fid *path)
M0_INTERNAL void m0_fop_release(struct m0_ref *ref)
static int path_walk_complete(struct m0_confc_ctx *ctx, struct m0_conf_obj *obj, size_t ri)
static int skip_confd_st_in(struct m0_sm *mach)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL void m0_clink_add(struct m0_chan *chan, struct m0_clink *link)
const struct m0_rpc_item_ops * ri_ops
m0_time_t m0_time_from_now(uint64_t secs, long ns)
const struct m0_fid M0_CONF_ROOT_FID
static void sm_waiter_fini(struct sm_waiter *w)
struct m0_rpc_session * ri_session
M0_INTERNAL bool m0_confc_invariant(const struct m0_confc *confc)
static const struct m0_bob_type ctx_bob
static void _ast_post(struct m0_sm_ast *ast, void(*cb)(struct m0_sm_group *, struct m0_sm_ast *), int datum)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
#define IS_IN_ARRAY(idx, array)
static int check_st_in(struct m0_sm *mach)
struct m0_rpc_item_type ft_rpc_item_type
static struct m0_confc_ctx * ast_to_ctx(struct m0_sm_ast *ast)
static const struct m0_bob_type confc_bob
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
static bool on_object_updated(struct m0_clink *link)
M0_INTERNAL struct m0_confc * m0_confc_from_obj(const struct m0_conf_obj *obj)
static struct m0_sm_state_descr confc_ctx_states[S_NR]
M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj)
struct m0_rpc_session rlk_sess
M0_INTERNAL struct m0_rpc_session * m0_confc2sess(struct m0_confc *confc)
static void ctx_state_set(struct m0_confc_ctx *ctx, enum confc_ctx_state state)
M0_INTERNAL int m0_confc_init_wait(struct m0_confc *confc, struct m0_sm_group *sm_group, const char *confd_addr, struct m0_rpc_machine *rpc_mach, const char *local_conf, uint64_t timeout_ns)
static bool failure_st_invariant(const struct m0_sm *mach)
static void disconnect_from_confd(struct m0_confc *confc)
M0_INTERNAL void m0_conf_cache_fini(struct m0_conf_cache *cache)
struct m0_rpc_machine * ri_rmachine
static uint64_t * confc_cache_ver(struct m0_confc_ctx *ctx)
const struct m0_conf_obj_type M0_CONF_DIR_TYPE
struct m0_chan cc_unattached
struct m0_fop_type m0_conf_fetch_fopt
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
static void confc_lock(struct m0_confc *confc)
static struct m0_addb2_source * s
M0_INTERNAL int m0_confc_readdir_sync(struct m0_conf_obj *dir, struct m0_conf_obj **pptr)
M0_INTERNAL int m0_confc_open_by_fid_sync(struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_obj **result)
static int cached_obj_update(struct m0_confc *confc, const struct m0_confx_obj *flat)
struct m0_pdclust_src_addr src
M0_INTERNAL void m0_chan_broadcast(struct m0_chan *chan)
M0_INTERNAL int32_t m0_confc_ctx_error(const struct m0_confc_ctx *ctx)
static struct confc_fop * confc_fop_alloc(struct m0_confc_ctx *ctx)
M0_INTERNAL bool m0_conf_obj_invariant(const struct m0_conf_obj *obj)
static bool confc_is_locked(const struct m0_confc *confc)
const struct m0_fid * m0_conf_objx_fid(const struct m0_confx_obj *obj)
M0_INTERNAL int m0_confc_readdir(struct m0_confc_ctx *ctx, struct m0_conf_obj *dir, struct m0_conf_obj **pptr)
#define M0_IMPOSSIBLE(fmt,...)
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)