Motr  M0
db.c File Reference
#include "lib/trace.h"
#include "lib/finject.h"
#include "conf/db.h"
#include "conf/onwire.h"
#include "conf/onwire_xc.h"
#include "conf/obj.h"
#include "xcode/xcode.h"
#include "be/btree.h"
#include "be/tx.h"
#include "be/op.h"
#include "lib/memory.h"
#include "lib/errno.h"
#include "lib/misc.h"
Include dependency graph for db.c:

Go to the source code of this file.

Data Structures

struct  __pack
 
struct  confx_allocator
 
struct  confx_obj_ctx
 
struct  confx_ctx
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF
 

Functions

static int confdb_objs_count (struct m0_be_btree *btree, size_t *result)
 
static void confdb_table_fini (struct m0_be_seg *seg)
 
M0_INTERNAL void m0_xc_m0_confx_obj_struct_init (void)
 
M0_INTERNAL void m0_xc_m0_confx_obj_struct_fini (void)
 
M0_INTERNAL size_t m0_confx_sizeof (void)
 
static void * _conf_xcode_alloc (struct m0_xcode_cursor *ctx M0_UNUSED, size_t nob)
 
static void confx_to_xcode_obj (struct m0_confx_obj *xobj, struct m0_xcode_obj *out, bool allocated)
 
static void xcode_ctx_init (struct m0_xcode_ctx *ctx, struct m0_confx_obj *xobj, bool allocated)
 
static int confx_obj_measure (struct m0_confx_obj *xobj)
 
static m0_bcount_t confdb_ksize (const void *key)
 
static m0_bcount_t confdb_vsize (const void *val)
 
static int confdb_table_init (struct m0_be_seg *seg, struct m0_be_btree **btree, struct m0_be_tx *tx, const struct m0_fid *btree_fid)
 
static void * confdb_obj_alloc (struct m0_xcode_cursor *ctx, size_t nob)
 
static int confx_obj_dup (struct confx_allocator *alloc, struct m0_confx_obj **dest, struct m0_confx_obj *src)
 
M0_INTERNAL int m0_confdb_create_credit (struct m0_be_seg *seg, const struct m0_confx *conf, struct m0_be_tx_credit *accum)
 
static int confdb_alloc (struct confx_allocator *alloc, struct m0_be_seg *seg, struct m0_be_tx *tx, int size)
 
static m0_bcount_t conf_sizeof (const struct m0_confx *conf)
 
static int confx_allocator_init (struct confx_allocator *alloc, const struct m0_confx *conf, struct m0_be_seg *seg, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_confdb_create (struct m0_be_seg *seg, struct m0_be_tx *tx, const struct m0_confx *conf, const struct m0_fid *btree_fid)
 
M0_INTERNAL void m0_confdb_destroy_credit (struct m0_be_seg *seg, struct m0_be_tx_credit *accum)
 
static int __confdb_free (struct m0_be_btree *btree, struct m0_be_seg *seg, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_confdb_destroy (struct m0_be_seg *seg, struct m0_be_tx *tx)
 
M0_INTERNAL void m0_confdb_fini (struct m0_be_seg *seg)
 
static struct m0_confxconfx_alloc (size_t nr_objs)
 
static void confx_fill (struct m0_confx *dest, struct m0_be_btree *btree)
 
M0_INTERNAL int m0_confdb_read (struct m0_be_seg *seg, struct m0_confx **out)
 

Variables

struct __pack conx_obj
 
M0_INTERNAL struct m0_xcode_typem0_confx_obj_xc = &conx_obj._p_xt
 
static const struct m0_be_btree_kv_ops confdb_ops
 
static const char btree_name [] = "conf"
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_CONF

Definition at line 23 of file db.c.

Function Documentation

◆ __confdb_free()

static int __confdb_free ( struct m0_be_btree btree,
struct m0_be_seg seg,
struct m0_be_tx tx 
)
static
Todo:
check validity of key and record addresses and sizes. Specifically, check that val.b_addr points to an allocated region in a segment with appropriate size and alignment. Such checks should be done generally by (not existing) beobj interface.
Todo:
also check that key (fid) matches m0_conf_objx_fid().

Definition at line 401 of file db.c.

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

◆ _conf_xcode_alloc()

static void* _conf_xcode_alloc ( struct m0_xcode_cursor *ctx  M0_UNUSED,
size_t  nob 
)
static

Definition at line 67 of file db.c.

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

◆ conf_sizeof()

static m0_bcount_t conf_sizeof ( const struct m0_confx conf)
static

Definition at line 301 of file db.c.

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

◆ confdb_alloc()

static int confdb_alloc ( struct confx_allocator alloc,
struct m0_be_seg seg,
struct m0_be_tx tx,
int  size 
)
static

Definition at line 287 of file db.c.

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

◆ confdb_ksize()

static m0_bcount_t confdb_ksize ( const void *  key)
static

Definition at line 145 of file db.c.

◆ confdb_obj_alloc()

static void* confdb_obj_alloc ( struct m0_xcode_cursor ctx,
size_t  nob 
)
static

Definition at line 204 of file db.c.

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

◆ confdb_objs_count()

static int confdb_objs_count ( struct m0_be_btree btree,
size_t *  result 
)
static

Definition at line 469 of file db.c.

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

◆ confdb_table_fini()

static void confdb_table_fini ( struct m0_be_seg seg)
static

Definition at line 192 of file db.c.

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

◆ confdb_table_init()

static int confdb_table_init ( struct m0_be_seg seg,
struct m0_be_btree **  btree,
struct m0_be_tx tx,
const struct m0_fid btree_fid 
)
static

Definition at line 168 of file db.c.

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

◆ confdb_vsize()

static m0_bcount_t confdb_vsize ( const void *  val)
static

Definition at line 150 of file db.c.

Here is the call graph for this function:

◆ confx_alloc()

static struct m0_confx* confx_alloc ( size_t  nr_objs)
static

Definition at line 488 of file db.c.

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

◆ confx_allocator_init()

static int confx_allocator_init ( struct confx_allocator alloc,
const struct m0_confx conf,
struct m0_be_seg seg,
struct m0_be_tx tx 
)
static

Definition at line 322 of file db.c.

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

◆ confx_fill()

static void confx_fill ( struct m0_confx dest,
struct m0_be_btree btree 
)
static
Todo:
check validity of key and record addresses and sizes. Specifically, check that val.b_addr points to an allocated region in a segment with appropriate size and alignment. Such checks should be done generally by (not existing) beobj interface.
Todo:
also check that key (fid) matches m0_conf_objx_fid().
Todo:
handle iteration errors.

Definition at line 509 of file db.c.

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

◆ confx_obj_dup()

static int confx_obj_dup ( struct confx_allocator alloc,
struct m0_confx_obj **  dest,
struct m0_confx_obj src 
)
static

Definition at line 222 of file db.c.

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

◆ confx_obj_measure()

static int confx_obj_measure ( struct m0_confx_obj xobj)
static

Definition at line 94 of file db.c.

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

◆ confx_to_xcode_obj()

static void confx_to_xcode_obj ( struct m0_confx_obj xobj,
struct m0_xcode_obj out,
bool  allocated 
)
static

Definition at line 72 of file db.c.

Here is the caller graph for this function:

◆ m0_confdb_create()

M0_INTERNAL int m0_confdb_create ( struct m0_be_seg seg,
struct m0_be_tx tx,
const struct m0_confx conf,
const struct m0_fid btree_fid 
)

Creates configuration database, populating it with provided configuration data.

Precondition
conf->cx_nr > 0

Definition at line 331 of file db.c.

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

◆ m0_confdb_create_credit()

M0_INTERNAL int m0_confdb_create_credit ( struct m0_be_seg seg,
const struct m0_confx conf,
struct m0_be_tx_credit accum 
)

Calculates BE credits required by configuration database tables and .

Definition at line 255 of file db.c.

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

◆ m0_confdb_destroy()

M0_INTERNAL int m0_confdb_destroy ( struct m0_be_seg seg,
struct m0_be_tx tx 
)

Definition at line 443 of file db.c.

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

◆ m0_confdb_destroy_credit()

M0_INTERNAL void m0_confdb_destroy_credit ( struct m0_be_seg seg,
struct m0_be_tx_credit accum 
)

Calculates BE credits in-order to destroy configuration database from persistent store.

Definition at line 380 of file db.c.

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

◆ m0_confdb_fini()

M0_INTERNAL void m0_confdb_fini ( struct m0_be_seg seg)

Finalises in-memory configuration database.

Definition at line 464 of file db.c.

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

◆ m0_confdb_read()

M0_INTERNAL int m0_confdb_read ( struct m0_be_seg seg,
struct m0_confx **  out 
)

Creates m0_confx and populates it with data read from a configuration database.

Note
If the call succeeds, the user is responsible for freeing allocated memory with m0_confx_free(*out).

Definition at line 544 of file db.c.

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

◆ m0_confx_sizeof()

M0_INTERNAL size_t m0_confx_sizeof ( void  )

Definition at line 61 of file db.c.

Here is the caller graph for this function:

◆ m0_xc_m0_confx_obj_struct_fini()

M0_INTERNAL void m0_xc_m0_confx_obj_struct_fini ( void  )

Definition at line 58 of file db.c.

◆ m0_xc_m0_confx_obj_struct_init()

M0_INTERNAL void m0_xc_m0_confx_obj_struct_init ( void  )

Definition at line 55 of file db.c.

◆ xcode_ctx_init()

static void xcode_ctx_init ( struct m0_xcode_ctx ctx,
struct m0_confx_obj xobj,
bool  allocated 
)
static

Definition at line 79 of file db.c.

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

Variable Documentation

◆ btree_name

const char btree_name[] = "conf"
static

Definition at line 166 of file db.c.

◆ confdb_ops

const struct m0_be_btree_kv_ops confdb_ops
static
Initial value:
= {
.ko_type = M0_BBT_CONFDB,
.ko_ksize = &confdb_ksize,
.ko_vsize = &confdb_vsize,
.ko_compare = (void *)&m0_fid_cmp
}
static m0_bcount_t confdb_vsize(const void *val)
Definition: db.c:150
M0_INTERNAL int m0_fid_cmp(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:170
static m0_bcount_t confdb_ksize(const void *key)
Definition: db.c:145

Definition at line 155 of file db.c.

◆ conx_obj

M0_BASSERT&[0][0] conx_obj
Initial value:
= {
._p_xt = {
.xct_name = "m0_confx_obj",
},
}

Definition at line 51 of file db.c.

◆ m0_confx_obj_xc

M0_INTERNAL struct m0_xcode_type* m0_confx_obj_xc = &conx_obj._p_xt

Definition at line 53 of file db.c.