Motr  M0
helpers.c File Reference
#include "lib/trace.h"
#include "conf/helpers.h"
#include "conf/obj_ops.h"
#include "conf/confc.h"
#include "conf/dir.h"
#include "conf/diter.h"
#include "conf/pvers.h"
#include "ha/note.h"
#include "reqh/reqh.h"
#include "lib/string.h"
#include "lib/memory.h"
#include "lib/finject.h"
#include "fis/fi_service.h"
Include dependency graph for helpers.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF
 
#define X(type)
 
#define conf_objs_count(confc, filter, arg, count, ...)
 

Enumerations

enum  { CACHE_LOCALITY = 1 }
 

Functions

static int confc_obj_get (struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_obj **result)
 
M0_INTERNAL bool m0_conf_obj_is_pool (const struct m0_conf_obj *obj)
 
M0_INTERNAL int m0_conf_pver_get (struct m0_confc *confc, const struct m0_fid *pool, struct m0_conf_pver **out)
 
static bool conf_obj_is_sdev (const struct m0_conf_obj *obj)
 
M0_INTERNAL int m0_conf_device_cid_to_fid (struct m0_confc *confc, uint64_t cid, struct m0_fid *fid)
 
static int _conf_load (struct m0_conf_root *root, const struct m0_fid *path, uint32_t nr_levels)
 
M0_INTERNAL int m0_conf_full_load (struct m0_conf_root *r)
 
M0_INTERNAL bool m0_conf_service_ep_is_known (const struct m0_conf_obj *svc_obj, const char *ep_addr)
 
M0_INTERNAL int m0_confc_root_open (struct m0_confc *confc, struct m0_conf_root **root)
 
M0_INTERNAL int m0_confc_profile_open (struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_profile **out)
 
static bool conf_obj_is_service (const struct m0_conf_obj *obj)
 
static int confc_service_find (struct m0_confc *confc, enum m0_conf_service_type stype, const char *ep, struct m0_conf_obj **result)
 
M0_INTERNAL int m0_confc_service_find (struct m0_confc *confc, enum m0_conf_service_type stype, const char *ep, struct m0_conf_obj **result)
 
M0_INTERNAL bool m0_conf_service_is_top_rms (const struct m0_conf_service *svc)
 
static struct m0_confcconf_obj2confc (const struct m0_conf_obj *obj)
 
M0_INTERNAL struct m0_reqhm0_confc2reqh (const struct m0_confc *confc)
 
M0_INTERNAL struct m0_reqhm0_conf_obj2reqh (const struct m0_conf_obj *obj)
 
static int conf__objs_count (struct m0_confc *confc, bool(*filter)(const struct m0_conf_obj *obj, void *arg), void *arg, uint32_t *count, int level, const struct m0_fid *path)
 
M0_INTERNAL struct m0_conf_pver ** m0_conf_pvers (const struct m0_conf_obj *obj)
 
M0_INTERNAL bool m0_disk_is_of_type (const struct m0_conf_obj *obj, uint64_t svc_types)
 
M0_INTERNAL bool m0_is_ios_disk (const struct m0_conf_obj *obj)
 
M0_INTERNAL bool m0_is_cas_disk (const struct m0_conf_obj *obj)
 
static bool dev_has_type (const struct m0_conf_obj *obj, void *arg)
 
M0_INTERNAL int m0_conf_devices_count (struct m0_confc *confc, uint64_t svc_types, uint32_t *nr_devices)
 
M0_INTERNAL void m0_confc_expired_cb (struct m0_rconfc *rconfc)
 
static void confc_ready_async_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
M0_INTERNAL void m0_confc_ready_cb (struct m0_rconfc *rconfc)
 
M0_INTERNAL int m0_conf_process2service_get (struct m0_confc *confc, const struct m0_fid *process_fid, enum m0_conf_service_type stype, struct m0_fid *sfid)
 
M0_INTERNAL int m0_conf_objs_ha_update (struct m0_ha_nvec *nvec)
 
M0_INTERNAL int m0_conf_obj_ha_update (const struct m0_fid *obj_fid)
 
static void __ha_nvec_reset (struct m0_ha_nvec *nvec, int32_t total)
 
M0_INTERNAL int m0_conf_confc_ha_update_async (struct m0_confc *confc, struct m0_ha_nvec *nvec, struct m0_chan *chan)
 
M0_INTERNAL int m0_conf_confc_ha_update (struct m0_confc *confc)
 

Variables

enum { ... }  M0_XCA_DOMAIN
 
 M0_CONF_OBJ_GETTERS
 

Macro Definition Documentation

◆ conf_objs_count

#define conf_objs_count (   confc,
  filter,
  arg,
  count,
  ... 
)
Value:
M0_COUNT_PARAMS(__VA_ARGS__) + 1, \
(const struct m0_fid []){ __VA_ARGS__, M0_FID0 })
#define M0_COUNT_PARAMS(...)
Definition: misc.h:370
static m0_bcount_t count
Definition: xcode.c:167
Definition: filter.py:1
static int conf__objs_count(struct m0_confc *confc, bool(*filter)(const struct m0_conf_obj *obj, void *arg), void *arg, uint32_t *count, int level, const struct m0_fid *path)
Definition: helpers.c:356
static struct m0_confc * confc
Definition: file.c:94
Definition: fid.h:38
#define M0_FID0
Definition: fid.h:93

Returns the number of conf objects located along the path.

Parameters
confcInitialised confc.
filterReturns true for objects of interest.
[out]countOutput parameter.
...Configuration path.

Definition at line 395 of file helpers.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF

Definition at line 22 of file helpers.c.

◆ X

#define X (   type)
Value:
M0_INTERNAL int type ## _get(struct m0_confc *confc, \
const struct m0_fid *fid, \
struct type **out) \
{ \
struct m0_conf_obj *obj; \
int rc; \
\
rc = confc_obj_get(confc, fid, &obj); \
if (rc == 0) \
return M0_RC(rc); \
} \
struct __ ## type ## _semicolon_catcher
static int confc_obj_get(struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_obj **result)
Definition: helpers.c:40
static struct foo * obj
Definition: tlist.c:302
struct m0_fid fid
Definition: di.c:46
return M0_RC(rc)
static struct m0_confc * confc
Definition: file.c:94
#define M0_CONF_CAST(ptr, type)
Definition: obj.h:780
Definition: fid.h:38
#define out(...)
Definition: gen.c:41
int type
Definition: dir.c:1031
int32_t rc
Definition: trigger_fop.h:47

Definition at line 48 of file helpers.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
CACHE_LOCALITY 

Definition at line 38 of file helpers.c.

Function Documentation

◆ __ha_nvec_reset()

static void __ha_nvec_reset ( struct m0_ha_nvec nvec,
int32_t  total 
)
static

Definition at line 598 of file helpers.c.

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

◆ _conf_load()

static int _conf_load ( struct m0_conf_root root,
const struct m0_fid path,
uint32_t  nr_levels 
)
static

Definition at line 141 of file helpers.c.

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

◆ conf__objs_count()

static int conf__objs_count ( struct m0_confc confc,
bool(*)(const struct m0_conf_obj *obj, void *arg)  filter,
void *  arg,
uint32_t *  count,
int  level,
const struct m0_fid path 
)
static

Definition at line 356 of file helpers.c.

Here is the call graph for this function:

◆ conf_obj2confc()

static struct m0_confc* conf_obj2confc ( const struct m0_conf_obj obj)
static

Definition at line 336 of file helpers.c.

Here is the caller graph for this function:

◆ conf_obj_is_sdev()

static bool conf_obj_is_sdev ( const struct m0_conf_obj obj)
static

Definition at line 95 of file helpers.c.

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

◆ conf_obj_is_service()

static bool conf_obj_is_service ( const struct m0_conf_obj obj)
static

Definition at line 249 of file helpers.c.

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

◆ confc_obj_get()

static int confc_obj_get ( struct m0_confc confc,
const struct m0_fid fid,
struct m0_conf_obj **  result 
)
static

Definition at line 40 of file helpers.c.

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

◆ confc_ready_async_ast()

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

Asynchronous part of conf ready event processing. Intended to run clink callbacks registered with m0_reqh::rh_conf_cache_ready_async channel.

Definition at line 478 of file helpers.c.

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

◆ confc_service_find()

static int confc_service_find ( struct m0_confc confc,
enum m0_conf_service_type  stype,
const char *  ep,
struct m0_conf_obj **  result 
)
static

Tries to locate service object by its type and endpoint address.

Definition at line 255 of file helpers.c.

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

◆ dev_has_type()

static bool dev_has_type ( const struct m0_conf_obj obj,
void *  arg 
)
static

Definition at line 445 of file helpers.c.

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

◆ m0_conf_confc_ha_update()

M0_INTERNAL int m0_conf_confc_ha_update ( struct m0_confc confc)
Todo:
XXX RELOCATEME: This function belongs ha subsystem, not conf.

Update configuration objects ha state from ha service. Fetches HA state of configuration objects from HA service and updates local configuration cache.

Definition at line 658 of file helpers.c.

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

◆ m0_conf_confc_ha_update_async()

M0_INTERNAL int m0_conf_confc_ha_update_async ( struct m0_confc confc,
struct m0_ha_nvec nvec,
struct m0_chan chan 
)

Asynchronous version of m0_conf_confc_ha_update().

Parameters
nvecshould be preserved until the update completion. nvec->nv_note array will be allocated, user is responsible to free it.

Definition at line 606 of file helpers.c.

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

◆ m0_conf_device_cid_to_fid()

M0_INTERNAL int m0_conf_device_cid_to_fid ( struct m0_confc confc,
uint64_t  cid,
struct m0_fid out 
)

Finds a device object using device index as a key.

Definition at line 100 of file helpers.c.

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

◆ m0_conf_devices_count()

M0_INTERNAL int m0_conf_devices_count ( struct m0_confc confc,
uint64_t  svc_types,
uint32_t *  nr_devices 
)

Checks that 'obj' is of type M0_CONF_DRIVE_TYPE and this disk is attached to a service of one of types specified in 'svc_types' bitmask.

Example:

m0_is_disk_of_type(conf_obj, M0_BITS(M0_CST_IOS, M0_CST_CAS));
@encode
/
M0_INTERNAL bool m0_disk_is_of_type(const struct m0_conf_obj *obj,
uint64_t svc_types);
M0_INTERNAL bool m0_is_cas_disk(const struct m0_conf_obj *obj);
M0_INTERNAL bool m0_is_ios_disk(const struct m0_conf_obj *obj);

Definition at line 450 of file helpers.c.

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

◆ m0_conf_full_load()

M0_INTERNAL int m0_conf_full_load ( struct m0_conf_root r)

Loads full configuration tree.

Definition at line 165 of file helpers.c.

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

◆ m0_conf_obj2reqh()

M0_INTERNAL struct m0_reqh* m0_conf_obj2reqh ( const struct m0_conf_obj obj)

Definition at line 351 of file helpers.c.

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

◆ m0_conf_obj_ha_update()

M0_INTERNAL int m0_conf_obj_ha_update ( const struct m0_fid obj_fid)
Todo:
XXX RELOCATEME: This function belongs ha subsystem, not conf.

Definition at line 587 of file helpers.c.

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

◆ m0_conf_obj_is_pool()

M0_INTERNAL bool m0_conf_obj_is_pool ( const struct m0_conf_obj obj)

Definition at line 66 of file helpers.c.

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

◆ m0_conf_objs_ha_update()

M0_INTERNAL int m0_conf_objs_ha_update ( struct m0_ha_nvec nvec)
Todo:
XXX RELOCATEME: This function belongs ha subsystem, not conf.

Update configuration objects ha state from ha service according to provided HA note vector.

The difference from m0_conf_confc_ha_state_update() is dealing with an arbitrary note vector. Client may fill in the vector following any logic that suits its needs. All the status results which respective conf objects exist in the provided confc instance cache will be applied to all HA clients currently registered with HA global context.

Precondition
nvec->nv_nr <= M0_HA_STATE_UPDATE_LIMIT

Definition at line 557 of file helpers.c.

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

◆ m0_conf_process2service_get()

M0_INTERNAL int m0_conf_process2service_get ( struct m0_confc confc,
const struct m0_fid process_fid,
enum m0_conf_service_type  stype,
struct m0_fid sfid 
)

Gets service fid of type stype from process with process_fid.

Definition at line 518 of file helpers.c.

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

◆ m0_conf_pver_get()

M0_INTERNAL int m0_conf_pver_get ( struct m0_confc confc,
const struct m0_fid pool,
struct m0_conf_pver **  out 
)

Obtains a pool version that consists of online elements only.

Precondition
m0_conf_fid_type(pool) == &M0_CONF_POOL_TYPE
Note
The resulting conf object should be m0_confc_close()d eventually.
See also
m0_conf_pver_find()

Definition at line 71 of file helpers.c.

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

◆ m0_conf_pvers()

M0_INTERNAL struct m0_conf_pver** m0_conf_pvers ( const struct m0_conf_obj obj)

Obtains m0_conf_pver array from rack/enclousure/controller.

Definition at line 400 of file helpers.c.

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

◆ m0_conf_service_ep_is_known()

M0_INTERNAL bool m0_conf_service_ep_is_known ( const struct m0_conf_obj svc_obj,
const char *  ep_addr 
)

Finds out if service configuration includes the specified endpoint address, i.e. endpoint is known to service configuration.

Definition at line 197 of file helpers.c.

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

◆ m0_conf_service_is_top_rms()

M0_INTERNAL bool m0_conf_service_is_top_rms ( const struct m0_conf_service svc)

Definition at line 319 of file helpers.c.

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

◆ m0_confc2reqh()

M0_INTERNAL struct m0_reqh* m0_confc2reqh ( const struct m0_confc confc)

Definition at line 342 of file helpers.c.

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

◆ m0_confc_expired_cb()

M0_INTERNAL void m0_confc_expired_cb ( struct m0_rconfc rconfc)

Definition at line 465 of file helpers.c.

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

◆ m0_confc_profile_open()

M0_INTERNAL int m0_confc_profile_open ( struct m0_confc confc,
const struct m0_fid fid,
struct m0_conf_profile **  out 
)

Opens profile configuration object.

Parameters
confcInitialised confc instance.
fidFid of the profile to open.
outOutput parameter. Should be m0_confc_close()d by user.

Definition at line 234 of file helpers.c.

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

◆ m0_confc_ready_cb()

M0_INTERNAL void m0_confc_ready_cb ( struct m0_rconfc rconfc)

Definition at line 488 of file helpers.c.

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

◆ m0_confc_root_open()

M0_INTERNAL int m0_confc_root_open ( struct m0_confc confc,
struct m0_conf_root **  root 
)

Opens root configuration object.

Parameters
confcInitialised confc instance.
rootOutput parameter. Should be m0_confc_close()d by user.

Definition at line 219 of file helpers.c.

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

◆ m0_confc_service_find()

M0_INTERNAL int m0_confc_service_find ( struct m0_confc confc,
enum m0_conf_service_type  stype,
const char *  ep,
struct m0_conf_obj **  result 
)

Tries to find m0_conf_service object by service type and endpoint address.

Postcondition
ergo(rc == 0, *result == NULL || m0_conf_obj_type(*result) == &M0_CONF_SERVICE_TYPE)

Definition at line 304 of file helpers.c.

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

◆ m0_disk_is_of_type()

M0_INTERNAL bool m0_disk_is_of_type ( const struct m0_conf_obj obj,
uint64_t  svc_types 
)

Definition at line 418 of file helpers.c.

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

◆ m0_is_cas_disk()

M0_INTERNAL bool m0_is_cas_disk ( const struct m0_conf_obj obj)

Definition at line 440 of file helpers.c.

Here is the call graph for this function:

◆ m0_is_ios_disk()

M0_INTERNAL bool m0_is_ios_disk ( const struct m0_conf_obj obj)

Definition at line 435 of file helpers.c.

Here is the call graph for this function:

Variable Documentation

◆ M0_CONF_OBJ_GETTERS

M0_CONF_OBJ_GETTERS

Definition at line 63 of file helpers.c.

◆ M0_XCA_DOMAIN

enum { ... } M0_XCA_DOMAIN