Motr  M0
Conf_glob

Data Structures

struct  m0_conf_glob
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF
 
#define conf_glob_step_pre(...)
 
#define conf_glob_step_post(...)
 
#define m0_conf_glob_init(glob, flags, errfunc, cache, origin, ...)
 

Typedefs

typedef int(* m0_conf_glob_errfunc_t) (int errcode, const struct m0_conf_obj *obj, const struct m0_fid *path)
 

Enumerations

enum  conf_glob_res { CONF_GLOB_CONT, CONF_GLOB_TARGET, CONF_GLOB_END }
 
enum  { M0_CONF_GLOB_ERR = 1 << 0 }
 

Functions

static int conf_glob_step (struct m0_conf_glob *glob, const struct m0_conf_obj **target)
 
static int conf_glob_err (struct m0_conf_glob *glob, int errcode, const struct m0_conf_obj *obj, const struct m0_fid *path)
 
M0_INTERNAL void m0_conf__glob_init (struct m0_conf_glob *glob, int flags, m0_conf_glob_errfunc_t errfunc, const struct m0_conf_cache *cache, const struct m0_conf_obj *origin, const struct m0_fid *path)
 
M0_INTERNAL int m0_conf_glob (struct m0_conf_glob *glob, uint32_t nr, const struct m0_conf_obj **objv)
 
M0_INTERNAL char * m0_conf_glob_error (const struct m0_conf_glob *glob, char *buf, size_t buflen)
 
static void conf_glob_turn (struct m0_conf_glob *glob)
 
static int conf_glob_down (struct m0_conf_glob *glob, const struct m0_conf_obj **target)
 
static int conf_glob_up (struct m0_conf_glob *glob)
 

Variables

enum conf_glob_res M0_XCA_DOMAIN
 

Detailed Description

m0_conf_glob() traverses a DAG of M0_CS_READY configuration objects and stores addresses of target objects, which given path leads to, in a preallocated array.

Example:

static int
foreach_service(const struct m0_conf_root *root,
void (*process)(const struct m0_conf_service *svc))
{
struct m0_conf_glob glob;
const struct m0_conf_obj *objv[BATCH];
int rc;
//
// "nodes/@/processes/@/services/@"
// (mentally substitute '@' with '*')
//
M0_CONF_ROOT_NODES_FID, M0_CONF_ANY_FID,
M0_CONF_NODE_PROCESSES_FID, M0_CONF_ANY_FID,
M0_CONF_PROCESS_SERVICES_FID, M0_CONF_ANY_FID);
while ((rc = m0_conf_glob(&glob, ARRAY_SIZE(objv), objv)) > 0) {
int i;
for (i = 0; i < rc; ++i)
process(M0_CONF_CAST(objv[i], m0_conf_service));
}
return M0_RC(rc);
}

Macro Definition Documentation

◆ conf_glob_step_post

#define conf_glob_step_post (   ...)

Definition at line 284 of file glob.c.

◆ conf_glob_step_pre

#define conf_glob_step_pre (   ...)

Definition at line 283 of file glob.c.

◆ m0_conf_glob_init

#define m0_conf_glob_init (   glob,
  flags,
  errfunc,
  cache,
  origin,
  ... 
)
Value:
m0_conf__glob_init((glob), (flags), (errfunc), (cache), (origin), \
(const struct m0_fid []){ __VA_ARGS__, M0_FID0 })
Definition: beck.c:235
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL void m0_conf__glob_init(struct m0_conf_glob *glob, int flags, m0_conf_glob_errfunc_t errfunc, const struct m0_conf_cache *cache, const struct m0_conf_obj *origin, const struct m0_fid *path)
Definition: glob.c:53
static int errfunc(int errcode, const struct m0_conf_obj *obj, const struct m0_fid *path)
Definition: glob.c:200
Definition: fid.h:38
#define M0_FID0
Definition: fid.h:93

Initialises ‘glob’.

If ‘origin’ is NULL, the root object (m0_conf_root) is implied. If ‘cache’ is NULL, origin->co_cache is used.

Precondition
cache != NULL || origin != NULL
ergo(origin != NULL && cache != NULL, origin->co_cache == cache)
m0_conf_cache_is_locked(cache ?: origin->co_cache)

Definition at line 142 of file glob.h.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF

Definition at line 28 of file glob.c.

Typedef Documentation

◆ m0_conf_glob_errfunc_t

typedef int(* m0_conf_glob_errfunc_t) (int errcode, const struct m0_conf_obj *obj, const struct m0_fid *path)

Definition at line 72 of file glob.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Bits set in the ‘flags’ argument to m0_conf_glob_init().

Enumerator
M0_CONF_GLOB_ERR 

Return on conf DAG traversal errors.

Definition at line 67 of file glob.h.

◆ conf_glob_res

Symbolic names for conf_glob_step() return values.

Enumerator
CONF_GLOB_CONT 

Another conf_glob_step() can be made.

CONF_GLOB_TARGET 

Target object reached. Another conf_glob_step() can be made.

CONF_GLOB_END 

Conf DAG traversal completed.

Definition at line 38 of file glob.c.

Function Documentation

◆ conf_glob_down()

static int conf_glob_down ( struct m0_conf_glob glob,
const struct m0_conf_obj **  target 
)
static

Definition at line 138 of file glob.c.

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

◆ conf_glob_err()

static int conf_glob_err ( struct m0_conf_glob glob,
int  errcode,
const struct m0_conf_obj obj,
const struct m0_fid path 
)
static

Definition at line 299 of file glob.c.

Here is the caller graph for this function:

◆ conf_glob_step()

static int conf_glob_step ( struct m0_conf_glob glob,
const struct m0_conf_obj **  target 
)
static

Definition at line 288 of file glob.c.

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

◆ conf_glob_turn()

static void conf_glob_turn ( struct m0_conf_glob glob)
static

Definition at line 132 of file glob.c.

Here is the caller graph for this function:

◆ conf_glob_up()

static int conf_glob_up ( struct m0_conf_glob glob)
static

Definition at line 195 of file glob.c.

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

◆ m0_conf__glob_init()

M0_INTERNAL void m0_conf__glob_init ( struct m0_conf_glob glob,
int  flags,
m0_conf_glob_errfunc_t  errfunc,
const struct m0_conf_cache cache,
const struct m0_conf_obj origin,
const struct m0_fid path 
)

Definition at line 53 of file glob.c.

Here is the call graph for this function:

◆ m0_conf_glob()

M0_INTERNAL int m0_conf_glob ( struct m0_conf_glob glob,
uint32_t  nr,
const struct m0_conf_obj **  objv 
)

Finds configuration objects that a path leads to.

m0_conf_glob() traverses a DAG of M0_CS_READY conf objects and stores addresses of path target objects in ‘objv’ array.

Parameters
globConf DAG traversal context.
nrOutput array capacity.
objvOutput array.
Returns
+N The number of target objects stored in ‘objv’. 0 DAG traversal has completed. -EPERM Conf object is not ready. -ENOENT Unreachable path.
Precondition
m0_conf_cache_is_locked(glob->cg_cache)
Postcondition
ergo(retval > 0, retval <= nr)
See also
m0_conf_glob_error()

Definition at line 92 of file glob.c.

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

◆ m0_conf_glob_error()

M0_INTERNAL char * m0_conf_glob_error ( const struct m0_conf_glob glob,
char *  buf,
size_t  buflen 
)

Returns string describing the most recent m0_conf_glob() error. Puts error description into ‘buf’.

Precondition
glob->cg_errcode < 0
buf != NULL && buflen > 0

Definition at line 115 of file glob.c.

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

Variable Documentation

◆ M0_XCA_DOMAIN

enum conf_glob_res M0_XCA_DOMAIN