Motr  M0
cob.c File Reference
#include "fid/fid.h"
#include "lib/trace.h"
#include "lib/misc.h"
#include "lib/arith.h"
#include "lib/errno.h"
#include "lib/assert.h"
#include "lib/memory.h"
#include "lib/bitstring.h"
#include "lib/locality.h"
#include "cob/cob.h"
#include "be/domain.h"
#include "be/btree.h"
#include "be/seg0.h"
#include "be/tx.h"
#include "module/instance.h"
#include "reqh/reqh_service.h"
#include "reqh/reqh.h"
#include "format/format.h"
#include <sys/stat.h>
Include dependency graph for cob.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_COB
 
#define M0_COB_KEY_LOG(logger, fmt, key, fid_member, str_member, ...)
 
#define M0_COB_NSKEY_LOG(logger, fmt, key, ...)   M0_COB_KEY_LOG(logger, fmt, key, cnk_pfid, cnk_name, ## __VA_ARGS__)
 
#define MKFS_ROOT_SIZE   4096
 
#define MKFS_ROOT_BLKSIZE   4096
 
#define MKFS_ROOT_BLOCKS   16
 
#define TCREDIT(table, t_optype, t_kvtype, accum)
 

Enumerations

enum  { M0_COB_NAME_MAX = 256, M0_COB_EA_MAX = 4096 }
 
enum  cob_table_optype { COB_TABLE_DELETE, COB_TABLE_UPDATE, COB_TABLE_INSERT }
 
enum  cob_table_kvtype {
  COB_KVTYPE_OMG, COB_KVTYPE_FAB, COB_KVTYPE_FEA, COB_KVTYPE_NS,
  COB_KVTYPE_OI, COB_KVTYPE_BC
}
 

Functions

static int cob0_init (struct m0_be_domain *dom, const char *suffix, const struct m0_buf *data)
 
static void cob0_fini (struct m0_be_domain *dom, const char *suffix, const struct m0_buf *data)
 
M0_INTERNAL int m0_cob_nskey_cmp (const struct m0_cob_nskey *k0, const struct m0_cob_nskey *k1)
 
M0_INTERNAL size_t m0_cob_nskey_size (const struct m0_cob_nskey *cnk)
 
M0_INTERNAL int m0_cob_eakey_make (struct m0_cob_eakey **keyh, const struct m0_fid *fid, const char *name, size_t namelen)
 
static int m0_cob_max_eakey_make (struct m0_cob_eakey **keyh, const struct m0_fid *fid, const char *name, int namelen)
 
M0_INTERNAL int m0_cob_eakey_cmp (const struct m0_cob_eakey *k0, const struct m0_cob_eakey *k1)
 
M0_INTERNAL size_t m0_cob_eakey_size (const struct m0_cob_eakey *cek)
 
static size_t m0_cob_earec_size (const struct m0_cob_earec *rec)
 
M0_INTERNAL size_t m0_cob_max_earec_size (void)
 
static size_t m0_cob_max_eakey_size (void)
 
static size_t m0_cob_fabrec_size (const struct m0_cob_fabrec *rec)
 
static size_t m0_cob_max_fabrec_size (void)
 
static int m0_cob_max_fabrec_make (struct m0_cob_fabrec **rech)
 
static int m0_cob_max_nskey_make (struct m0_cob_nskey **keyh, const struct m0_fid *pfid, const char *name, int namelen)
 
static size_t m0_cob_max_nskey_size (void)
 
static int ns_cmp (const void *key0, const void *key1)
 
static m0_bcount_t ns_ksize (const void *key)
 
static m0_bcount_t ns_vsize (const void *val)
 
static size_t m0_cob_bckey_size (void)
 
static size_t m0_cob_bcrec_size (void)
 
static m0_bcount_t bc_ksize (const void *key)
 
static m0_bcount_t bc_vsize (const void *val)
 
static int m0_cob_bckey_make (struct m0_cob_bckey **keyh, const struct m0_fid *pver_fid, uint64_t user_id)
 
M0_INTERNAL int m0_cob_bckey_cmp (const struct m0_cob_bckey *k0, const struct m0_cob_bckey *k1)
 
static int bc_cmp (const void *key0, const void *key1)
 
static int oi_cmp (const void *key0, const void *key1)
 
static m0_bcount_t oi_ksize (const void *key)
 
static int fb_cmp (const void *key0, const void *key1)
 
static m0_bcount_t fb_ksize (const void *key)
 
static m0_bcount_t fb_vsize (const void *val)
 
static int ea_cmp (const void *key0, const void *key1)
 
static m0_bcount_t ea_ksize (const void *key)
 
static m0_bcount_t ea_vsize (const void *val)
 
static int omg_cmp (const void *key0, const void *key1)
 
static m0_bcount_t omg_ksize (const void *key)
 
static m0_bcount_t omg_vsize (const void *val)
 
static M0_UNUSED char * cob_dom_id_make (char *buf, const struct m0_cob_domain_id *id, const char *prefix)
 
int m0_cob_domain_init (struct m0_cob_domain *dom, struct m0_be_seg *seg)
 
void m0_cob_domain_fini (struct m0_cob_domain *dom)
 
static void cob_domain_id2str (char **s, const struct m0_cob_domain_id *cdid)
 
M0_INTERNAL int m0_cob_domain_credit_add (struct m0_cob_domain *dom, struct m0_be_domain *bedom, struct m0_be_seg *seg, const struct m0_cob_domain_id *cdid, struct m0_be_tx_credit *cred)
 
M0_INTERNAL int m0_cob_domain_create_prepared (struct m0_cob_domain **out, struct m0_sm_group *grp, const struct m0_cob_domain_id *cdid, struct m0_be_domain *bedom, struct m0_be_seg *seg, struct m0_be_tx *tx)
 
int m0_cob_domain_create (struct m0_cob_domain **dom, struct m0_sm_group *grp, const struct m0_cob_domain_id *cdid, struct m0_be_domain *bedom, struct m0_be_seg *seg)
 
int m0_cob_domain_destroy (struct m0_cob_domain *dom, struct m0_sm_group *grp, struct m0_be_domain *bedom)
 
static int cob_table_delete (struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_buf *key)
 
static int cob_table_update (struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_buf *key, struct m0_buf *val)
 
static int cob_table_insert (struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_buf *key, struct m0_buf *val)
 
static int cob_table_lookup (struct m0_be_btree *tree, struct m0_buf *key, struct m0_buf *out)
 
M0_INTERNAL int m0_cob_domain_mkfs (struct m0_cob_domain *dom, const struct m0_fid *rootfid, struct m0_be_tx *tx)
 
static void cob_free_cb (struct m0_ref *ref)
 
M0_INTERNAL void m0_cob_init (struct m0_cob_domain *dom, struct m0_cob *cob)
 
static void cob_fini (struct m0_cob *cob)
 
static int cob_ns_lookup (struct m0_cob *cob)
 
static int cob_oi_lookup (struct m0_cob *cob)
 
static int cob_fab_lookup (struct m0_cob *cob)
 
static int cob_omg_lookup (struct m0_cob *cob)
 
static int cob_get_fabomg (struct m0_cob *cob, uint64_t flags)
 
M0_INTERNAL int m0_cob_lookup (struct m0_cob_domain *dom, struct m0_cob_nskey *nskey, uint64_t flags, struct m0_cob **out)
 
M0_INTERNAL int m0_cob_locate (struct m0_cob_domain *dom, struct m0_cob_oikey *oikey, uint64_t flags, struct m0_cob **out)
 
static bool m0_cob_is_valid (struct m0_cob *cob)
 
M0_INTERNAL int m0_cob_create (struct m0_cob *cob, struct m0_cob_nskey *nskey, struct m0_cob_nsrec *nsrec, struct m0_cob_fabrec *fabrec, struct m0_cob_omgrec *omgrec, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_delete (struct m0_cob *cob, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_delete_put (struct m0_cob *cob, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_update (struct m0_cob *cob, struct m0_cob_nsrec *nsrec, struct m0_cob_fabrec *fabrec, struct m0_cob_omgrec *omgrec, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_name_add (struct m0_cob *cob, struct m0_cob_nskey *nskey, struct m0_cob_nsrec *nsrec, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_name_del (struct m0_cob *cob, struct m0_cob_nskey *nskey, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_name_update (struct m0_cob *cob, struct m0_cob_nskey *srckey, struct m0_cob_nskey *tgtkey, struct m0_be_tx *tx)
 
M0_INTERNAL void m0_cob_nsrec_init (struct m0_cob_nsrec *nsrec)
 
M0_INTERNAL int m0_cob_ea_get (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_cob_earec *out, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_ea_set (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_cob_earec *earec, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_ea_del (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_be_tx *tx)
 
static void cob_table_tx_credit (struct m0_be_btree *tree, enum cob_table_optype t_optype, enum cob_table_kvtype t_kvtype, struct m0_be_tx_credit *accum)
 

Variables

struct m0_be_0type m0_be_cob0
 
static const struct m0_be_btree_kv_ops cob_ns_ops
 
static const struct m0_be_btree_kv_ops cob_bc_ops
 
static const struct m0_be_btree_kv_ops cob_oi_ops
 
static const struct m0_be_btree_kv_ops cob_fab_ops
 
static const struct m0_be_btree_kv_ops cob_ea_ops
 
static const struct m0_be_btree_kv_ops cob_omg_ops
 

as a start position.

Init cob iterator on passed and

const struct m0_fid_type m0_cob_fid_type
 
M0_INTERNAL const struct m0_fidm0_cob_fid (const struct m0_cob *cob)
 
M0_INTERNAL int m0_cob_mod_init (void)
 
M0_INTERNAL void m0_cob_mod_fini (void)
 
M0_INTERNAL void m0_cob_oikey_make (struct m0_cob_oikey *oikey, const struct m0_fid *fid, int linkno)
 
M0_INTERNAL int m0_cob_nskey_make (struct m0_cob_nskey **keyh, const struct m0_fid *pfid, const char *name, size_t namelen)
 
M0_INTERNAL int m0_cob_fabrec_make (struct m0_cob_fabrec **rech, const char *link, size_t linklen)
 
M0_INTERNAL int m0_cob_bc_iterator_init (struct m0_cob *cob, struct m0_cob_bc_iterator *it, const struct m0_fid *pver_fid, uint64_t user_id)
 
M0_INTERNAL int m0_cob_bc_iterator_get (struct m0_cob_bc_iterator *it)
 
M0_INTERNAL int m0_cob_bc_iterator_next (struct m0_cob_bc_iterator *it)
 
M0_INTERNAL void m0_cob_bc_iterator_fini (struct m0_cob_bc_iterator *it)
 
M0_INTERNAL int m0_cob_bc_entries_dump (struct m0_cob_domain *cdom, struct m0_buf **out_keys, struct m0_buf **out_recs, uint32_t *out_count)
 
M0_INTERNAL void m0_cob_get (struct m0_cob *cob)
 
M0_INTERNAL void m0_cob_put (struct m0_cob *cob)
 
M0_INTERNAL int m0_cob_alloc (struct m0_cob_domain *dom, struct m0_cob **out)
 
M0_INTERNAL int m0_cob_bc_lookup (struct m0_cob *cob, struct m0_cob_bckey *bc_key, struct m0_cob_bcrec *bc_rec)
 
M0_INTERNAL int m0_cob_bc_insert (struct m0_cob *cob, struct m0_cob_bckey *bc_key, struct m0_cob_bcrec *bc_val, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_bc_update (struct m0_cob *cob, struct m0_cob_bckey *bc_key, struct m0_cob_bcrec *bc_val, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_iterator_init (struct m0_cob *cob, struct m0_cob_iterator *it, struct m0_bitstring *name)
 
M0_INTERNAL void m0_cob_iterator_fini (struct m0_cob_iterator *it)
 
M0_INTERNAL int m0_cob_iterator_get (struct m0_cob_iterator *it)
 
M0_INTERNAL int m0_cob_iterator_next (struct m0_cob_iterator *it)
 
M0_INTERNAL int m0_cob_ea_iterator_init (struct m0_cob *cob, struct m0_cob_ea_iterator *it, struct m0_bitstring *name)
 
M0_INTERNAL int m0_cob_ea_iterator_get (struct m0_cob_ea_iterator *it)
 
M0_INTERNAL int m0_cob_ea_iterator_next (struct m0_cob_ea_iterator *it)
 
M0_INTERNAL void m0_cob_ea_iterator_fini (struct m0_cob_ea_iterator *it)
 
M0_INTERNAL int m0_cob_alloc_omgid (struct m0_cob_domain *dom, uint64_t *omgid)
 
M0_INTERNAL int m0_cob_setattr (struct m0_cob *cob, struct m0_cob_attr *attr, struct m0_be_tx *tx)
 
M0_INTERNAL int m0_cob_size_update (struct m0_cob *cob, uint64_t size, struct m0_be_tx *tx)
 
M0_INTERNAL void m0_cob_tx_credit (struct m0_cob_domain *dom, enum m0_cob_op optype, struct m0_be_tx_credit *accum)
 
M0_INTERNAL void m0_cob_ea_get_credit (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_cob_earec *out, struct m0_be_tx_credit *accum)
 
M0_INTERNAL void m0_cob_ea_set_credit (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_cob_earec *earec, struct m0_be_tx_credit *accum)
 
M0_INTERNAL void m0_cob_ea_del_credit (struct m0_cob *cob, struct m0_cob_eakey *eakey, struct m0_be_tx_credit *accum)
 
M0_INTERNAL void m0_cob_ea_iterator_init_credit (struct m0_cob *cob, struct m0_cob_ea_iterator *it, struct m0_bitstring *name, struct m0_be_tx_credit *accum)
 

Macro Definition Documentation

◆ M0_COB_KEY_LOG

#define M0_COB_KEY_LOG (   logger,
  fmt,
  key,
  fid_member,
  str_member,
  ... 
)
Value:
M0_ ## logger (fmt, (long)(key)->fid_member.f_container, \
(long)(key)->fid_member.f_key, \
m0_bitstring_len_get(&((key)->str_member)), \
(char *)m0_bitstring_buf_get(&((key)->str_member)), \
## __VA_ARGS__)
M0_INTERNAL uint32_t m0_bitstring_len_get(const struct m0_bitstring *c)
Definition: bitstring.c:38
char * fmt(const char *format,...) __attribute__((format(printf
M0_INTERNAL void * m0_bitstring_buf_get(struct m0_bitstring *c)
Definition: bitstring.c:33
Definition: idx_mock.c:47

Definition at line 27 of file cob.c.

◆ M0_COB_NSKEY_LOG

#define M0_COB_NSKEY_LOG (   logger,
  fmt,
  key,
  ... 
)    M0_COB_KEY_LOG(logger, fmt, key, cnk_pfid, cnk_name, ## __VA_ARGS__)

Definition at line 33 of file cob.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_COB

Definition at line 24 of file cob.c.

◆ TCREDIT

#define TCREDIT (   table,
  t_optype,
  t_kvtype,
  accum 
)
Value:
cob_table_tx_credit((table), COB_TABLE_##t_optype, \
COB_KVTYPE_##t_kvtype, (accum))
static void cob_table_tx_credit(struct m0_be_btree *tree, enum cob_table_optype t_optype, enum cob_table_kvtype t_kvtype, struct m0_be_tx_credit *accum)
Definition: cob.c:2222