Motr  M0
db.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CONF
24 #include "lib/trace.h"
25 #include "lib/finject.h"
26 
27 #include "conf/db.h"
28 #include "conf/onwire.h" /* m0_confx_obj, m0_confx */
29 #include "conf/onwire_xc.h"
30 #include "conf/obj.h"
31 #include "xcode/xcode.h"
32 #include "be/btree.h"
33 #include "be/tx.h"
34 #include "be/op.h"
35 #include "lib/memory.h" /* m0_alloc, m0_free */
36 #include "lib/errno.h" /* EINVAL */
37 #include "lib/misc.h" /* M0_SET0 */
38 
39 static int confdb_objs_count(struct m0_be_btree *btree, size_t *result);
40 static void confdb_table_fini(struct m0_be_seg *seg);
41 
42 struct __pack {
45 } conx_obj = {
46  ._p_xt = {
47  .xct_name = "m0_confx_obj",
48  },
49 };
50 
52 
54 
55 M0_INTERNAL void m0_xc_m0_confx_obj_struct_init(void)
56 {}
57 
58 M0_INTERNAL void m0_xc_m0_confx_obj_struct_fini(void)
59 {}
60 
61 M0_INTERNAL size_t m0_confx_sizeof(void)
62 {
64 }
65 
66 static void *
68 {
69  return m0_alloc(nob);
70 }
71 
72 static void confx_to_xcode_obj(struct m0_confx_obj *xobj,
73  struct m0_xcode_obj *out, bool allocated)
74 {
76 }
77 
78 /* Note: m0_xcode_ctx_init() doesn't allow `xobj' to be const. Sigh. */
79 static void xcode_ctx_init(struct m0_xcode_ctx *ctx, struct m0_confx_obj *xobj,
80  bool allocated)
81 {
82  struct m0_xcode_obj obj;
83 
84  M0_ENTRY();
85 
88  if (!allocated)
89  ctx->xcx_alloc = _conf_xcode_alloc;
90 
91  M0_LEAVE();
92 }
93 
94 static int confx_obj_measure(struct m0_confx_obj *xobj)
95 {
96  struct m0_xcode_ctx ctx;
97 
98  M0_ENTRY();
99  xcode_ctx_init(&ctx, xobj, true);
100  return M0_RC(m0_xcode_length(&ctx));
101 }
102 
103 /* ------------------------------------------------------------------
104  * Database operations
105  * ------------------------------------------------------------------
106  */
107 
119  void *a_chunk;
122 };
123 
133 };
134 
140 struct confx_ctx {
143 };
144 
145 static m0_bcount_t confdb_ksize(const void *key)
146 {
147  return sizeof(struct m0_fid);
148 }
149 
150 static m0_bcount_t confdb_vsize(const void *val)
151 {
152  return m0_confx_sizeof() + sizeof(struct confx_allocator);
153 }
154 
155 static const struct m0_be_btree_kv_ops confdb_ops = {
157  .ko_ksize = &confdb_ksize,
158  .ko_vsize = &confdb_vsize,
159  .ko_compare = (void *)&m0_fid_cmp
160 };
161 
162 /* ------------------------------------------------------------------
163  * Tables
164  * ------------------------------------------------------------------ */
165 
166 static const char btree_name[] = "conf";
167 
168 static int confdb_table_init(struct m0_be_seg *seg,
169  struct m0_be_btree **btree,
170  struct m0_be_tx *tx,
171  const struct m0_fid *btree_fid)
172 {
173  int rc;
174 
175  M0_ENTRY();
176 
179  M0_BE_OP_SYNC(op, m0_be_btree_create(*btree, tx, &op, btree_fid));
180 
182  if (rc == 0 && M0_FI_ENABLED("ut_confdb_create_failure"))
183  rc = -EINVAL;
184  if (rc != 0) {
186  m0_confdb_destroy(seg, tx);
187  }
188 
189  return M0_RC(rc);
190 }
191 
192 static void confdb_table_fini(struct m0_be_seg *seg)
193 {
194  int rc;
195  struct m0_be_btree *btree;
196 
197  M0_ENTRY();
199  if (rc == 0)
201  M0_LEAVE();
202 }
203 
204 static void *confdb_obj_alloc(struct m0_xcode_cursor *ctx, size_t nob)
205 {
206  struct confx_ctx *cctx;
207  struct confx_allocator *alloc;
208  char *addr;
209 
210  cctx = container_of(container_of(ctx, struct m0_xcode_ctx, xcx_it),
211  struct confx_ctx, c_xctx);
212  alloc = cctx->c_alloc;
213  M0_PRE(alloc->a_chunk != NULL);
214  M0_PRE(alloc->a_used + nob <= alloc->a_total);
215 
216  addr = (char *)alloc->a_chunk + alloc->a_used;
217  alloc->a_used += nob;
218 
219  return addr;
220 }
221 
223  struct m0_confx_obj **dest,
224  struct m0_confx_obj *src)
225 {
226  int rc = 0;
227  struct m0_xcode_obj src_obj;
228  struct m0_xcode_obj dest_obj;
229  struct m0_xcode_ctx *sctx = NULL;
230  struct confx_ctx *cctx = NULL;
231 
234  if (sctx == NULL || cctx == NULL)
235  goto out;
236 
237  confx_to_xcode_obj(src, &dest_obj, false);
238  confx_to_xcode_obj(src, &src_obj, true);
239  if (M0_FI_ENABLED("ut_confx_obj_dup_failure"))
240  rc = -EINVAL;
241  if (rc == 0) {
242  m0_xcode_ctx_init(sctx, &src_obj);
243  m0_xcode_ctx_init(&cctx->c_xctx, &dest_obj);
244  cctx->c_alloc = alloc;
245  cctx->c_xctx.xcx_alloc = confdb_obj_alloc;
246  rc = m0_xcode_dup(&cctx->c_xctx, sctx);
247  }
248  *dest = cctx->c_xctx.xcx_it.xcu_stack[0].s_obj.xo_ptr;
249  out:
250  m0_free(cctx);
251  m0_free(sctx);
252  return M0_RC(rc);
253 }
254 
255 M0_INTERNAL int m0_confdb_create_credit(struct m0_be_seg *seg,
256  const struct m0_confx *conf,
257  struct m0_be_tx_credit *accum)
258 {
259  struct m0_be_btree btree = { .bb_seg = seg };
260  int rc = 0;
261  int i;
262 
263  M0_ENTRY();
264  M0_BE_ALLOC_CREDIT_PTR(&btree, seg, accum);
266  m0_be_btree_create_credit(&btree, 1, accum);
267 
268  for (i = 0; i < conf->cx_nr; ++i) {
269  struct m0_confx_obj *obj;
270 
271  obj = M0_CONFX_AT(conf, i);
273  if (rc < 0)
274  break;
275  m0_be_btree_insert_credit2(&btree, 1, sizeof(struct m0_fid),
276  rc + sizeof(struct confx_allocator),
277  accum);
278  rc = 0;
279  }
280 
281  /* Allocate credits for db finalisation in-case of an error. */
283 
284  return M0_RC(rc);
285 }
286 
287 static int confdb_alloc(struct confx_allocator *alloc, struct m0_be_seg *seg,
288  struct m0_be_tx *tx, int size)
289 {
290  M0_BE_OP_SYNC(__op,
291  m0_be_alloc(m0_be_seg_allocator(seg), tx, &__op,
292  &alloc->a_chunk, size));
293  if (alloc->a_chunk == NULL)
294  return M0_ERR(-ENOMEM);
295  alloc->a_total = size;
296  alloc->a_used = 0;
297 
298  return 0;
299 }
300 
301 static m0_bcount_t conf_sizeof(const struct m0_confx *conf)
302 {
303  m0_bcount_t size = 0;
304  int i;
305  int rc;
306 
307  for (i = 0; i < conf->cx_nr; ++i) {
308  struct m0_confx_obj *obj;
309 
310  obj = M0_CONFX_AT(conf, i);
312  if (rc < 0) {
313  size = 0;
314  break;
315  }
316  size += m0_confx_sizeof() + rc;
317  }
318 
319  return size;
320 }
321 
323  const struct m0_confx *conf,
324  struct m0_be_seg *seg, struct m0_be_tx *tx)
325 {
326  m0_bcount_t conf_size;
327  return (conf_size = conf_sizeof(conf)) == 0 ? -EINVAL :
328  confdb_alloc(alloc, seg, tx, conf_size);
329 }
330 
331 M0_INTERNAL int m0_confdb_create(struct m0_be_seg *seg,
332  struct m0_be_tx *tx,
333  const struct m0_confx *conf,
334  const struct m0_fid *btree_fid)
335 {
336  struct m0_be_btree *btree;
337  struct confx_allocator alloc;
338  int i;
339  int rc;
340 
341  M0_ENTRY();
342  M0_PRE(conf->cx_nr > 0);
343 
344  rc = confdb_table_init(seg, &btree, tx, btree_fid);
345  if (rc != 0)
346  return M0_RC(rc);
348  for (i = 0; i < conf->cx_nr && rc == 0; ++i) {
349  struct confx_obj_ctx obj_ctx;
350  struct m0_buf key;
351  struct m0_buf val;
352 
353  /*
354  * Save confx_allocator information along with the configuration
355  * object in the btree.
356  * Allocator information is replicated with all the configuration
357  * objects in the btree.
358  */
359  obj_ctx.oc_alloc = alloc;
360  rc = confx_obj_dup(&alloc, &obj_ctx.oc_obj, M0_CONFX_AT(conf, i));
361  if (rc != 0)
362  break;
363  M0_ASSERT(obj_ctx.oc_obj != NULL);
364  /* discard const */
365  key = M0_FID_BUF((struct m0_fid *)m0_conf_objx_fid(obj_ctx.oc_obj));
367  sizeof(struct confx_allocator), &obj_ctx);
369  &op, &key, &val),
370  bo_u.u_btree.t_rc);
371  }
372  if (rc != 0) {
374  m0_confdb_destroy(seg, tx);
375  }
376 
377  return M0_RC(rc);
378 }
379 
380 M0_INTERNAL void m0_confdb_destroy_credit(struct m0_be_seg *seg,
381  struct m0_be_tx_credit *accum)
382 {
383  struct m0_be_btree *btp;
384  struct m0_be_btree btree = { .bb_seg = seg };
385  int rc;
386 
387  M0_ENTRY();
388 
389  rc = m0_be_seg_dict_lookup(seg, btree_name, (void **)&btp);
390  if (rc == 0) {
391  m0_be_btree_destroy_credit(btp, accum);
392  } else {
394  }
396  M0_BE_FREE_CREDIT_PTR(&btree, seg, accum);
397 
398  M0_LEAVE();
399 }
400 
401 static int __confdb_free(struct m0_be_btree *btree, struct m0_be_seg *seg,
402  struct m0_be_tx *tx)
403 {
404  int rc;
405  struct confx_allocator *alloc = NULL;
406  struct confx_obj_ctx *obj_ctx;
407  struct m0_buf key;
408  struct m0_buf val;
409  struct m0_be_btree_cursor *bcur;
410 
411  M0_ALLOC_PTR(bcur);
412  if (bcur == NULL)
413  return M0_ERR(-ENOMEM);
414 
417  if (rc != 0)
418  goto err;
429  obj_ctx = val.b_addr;
430  /*
431  * Fetch the confx allocator information from the first configuration
432  * object. Release pre-allocated BE segment memory from the allocator.
433  */
434  alloc = &obj_ctx->oc_alloc;
435  M0_BE_FREE_PTR_SYNC(alloc->a_chunk, seg, tx);
436  err:
438  m0_free(bcur);
439 
440  return M0_RC(rc);
441 }
442 
443 M0_INTERNAL int m0_confdb_destroy(struct m0_be_seg *seg,
444  struct m0_be_tx *tx)
445 {
446  struct m0_be_btree *btree;
447  int rc;
448 
449  M0_ENTRY();
450 
452  if (rc == 0) {
453  rc = __confdb_free(btree, seg, tx);
454  if (rc == 0 || rc == -ENOENT) {
458  }
459  }
460 
461  return M0_RC(rc);
462 }
463 
464 M0_INTERNAL void m0_confdb_fini(struct m0_be_seg *seg)
465 {
467 }
468 
469 static int confdb_objs_count(struct m0_be_btree *btree, size_t *result)
470 {
471  struct m0_be_btree_cursor bcur;
472  int rc;
473 
474  M0_ENTRY();
475  *result = 0;
477  for (rc = m0_be_btree_cursor_first_sync(&bcur); rc == 0;
478  rc = m0_be_btree_cursor_next_sync(&bcur)) {
479  ++*result;
480  }
482  /* Check for normal iteration completion. */
483  if (rc == -ENOENT)
484  rc = 0;
485  return M0_RC(rc);
486 }
487 
488 static struct m0_confx *confx_alloc(size_t nr_objs)
489 {
490  struct m0_confx *ret;
491  void *data;
492 
493  M0_PRE(nr_objs > 0);
494 
495  M0_ALLOC_PTR(ret);
496  if (ret == NULL)
497  return NULL;
498 
499  M0_ALLOC_ARR(data, nr_objs * m0_confx_sizeof());
500  if (data == NULL) {
501  m0_free(ret);
502  return NULL;
503  }
504  ret->cx__objs = data;
505  ret->cx_nr = nr_objs;
506  return ret;
507 }
508 
509 static void confx_fill(struct m0_confx *dest, struct m0_be_btree *btree)
510 {
511  struct m0_be_btree_cursor bcur;
512  size_t i; /* index in dest->cx__objs[] */
513  int rc;
514 
515  M0_ENTRY();
516  M0_PRE(dest->cx_nr > 0);
517 
519  for (i = 0, rc = m0_be_btree_cursor_first_sync(&bcur); rc == 0;
520  rc = m0_be_btree_cursor_next_sync(&bcur), ++i) {
521  struct confx_obj_ctx *obj_ctx;
522  struct m0_buf key;
523  struct m0_buf val;
524 
525  m0_be_btree_cursor_kv_get(&bcur, &key, &val);
526  M0_ASSERT(i < dest->cx_nr);
536  obj_ctx = val.b_addr;
537  memcpy(M0_CONFX_AT(dest, i), obj_ctx->oc_obj, m0_confx_sizeof());
538  }
541  M0_ASSERT(rc == -ENOENT); /* end of the table */
542 }
543 
544 M0_INTERNAL int m0_confdb_read(struct m0_be_seg *seg, struct m0_confx **out)
545 {
546  struct m0_be_btree *btree;
547  int rc;
548  size_t nr_objs = 0;
549 
550  M0_ENTRY();
551 
553  if (rc != 0)
554  return M0_RC(rc);
555 
556  rc = confdb_objs_count(btree, &nr_objs);
557  if (rc != 0)
558  goto out;
559 
560  if (nr_objs == 0) {
561  rc = -ENODATA;
562  goto out;
563  }
564 
565  *out = confx_alloc(nr_objs);
566  if (*out == NULL) {
567  rc = -ENOMEM;
568  goto out;
569  }
570 
571  confx_fill(*out, btree);
572 out:
573  return M0_RC(rc);
574 }
575 
576 #undef M0_TRACE_SUBSYSTEM
static const struct m0_be_btree_kv_ops confdb_ops
Definition: db.c:155
#define M0_BE_ALLOC_CREDIT_PTR(ptr, seg, accum)
Definition: alloc.h:355
#define M0_PRE(cond)
#define M0_BE_ALLOC_PTR_SYNC(ptr, seg, tx)
Definition: alloc.h:339
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
struct m0_confx_obj * cx__objs
Definition: onwire.h:267
static struct m0_confx * confx_alloc(size_t nr_objs)
Definition: db.c:488
static void confx_to_xcode_obj(struct m0_confx_obj *xobj, struct m0_xcode_obj *out, bool allocated)
Definition: db.c:72
M0_INTERNAL int m0_be_seg_dict_insert(struct m0_be_seg *seg, struct m0_be_tx *tx, const char *name, void *value)
Definition: seg_dict.c:255
uint64_t ko_type
Definition: btree.h:97
struct m0_xcode_type _p_xt
Definition: db.c:43
#define NULL
Definition: misc.h:38
Definition: idx_mock.c:52
static void confx_fill(struct m0_confx *dest, struct m0_be_btree *btree)
Definition: db.c:509
static int confdb_alloc(struct confx_allocator *alloc, struct m0_be_seg *seg, struct m0_be_tx *tx, int size)
Definition: db.c:287
M0_LEAVE()
struct confx_allocator oc_alloc
Definition: db.c:131
#define M0_FID_BUF(fid)
Definition: fid.h:95
static void * _conf_xcode_alloc(struct m0_xcode_cursor *ctx M0_UNUSED, size_t nob)
Definition: db.c:67
#define M0_BE_OP_SYNC(op_obj, action)
Definition: op.h:190
struct m0_confx_obj * oc_obj
Definition: db.c:132
struct m0_bufvec data
Definition: di.c:40
Definition: db.c:140
M0_INTERNAL void m0_xc_m0_confx_obj_struct_init(void)
Definition: db.c:55
static struct m0_rpc_client_ctx cctx
Definition: rconfc.c:69
struct m0_xcode_field xct_child[0]
Definition: xcode.h:345
Definition: conf.py:1
static m0_bcount_t confdb_vsize(const void *val)
Definition: db.c:150
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL struct m0_xcode_type * m0_confx_obj_xc
Definition: db.c:53
#define M0_CONFX_AT(cx, idx)
Definition: onwire.h:271
M0_INTERNAL void m0_be_btree_create(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_fid *btree_fid)
Definition: btree.c:1512
#define container_of(ptr, type, member)
Definition: misc.h:33
static struct m0_atomic64 allocated
Definition: memory.c:101
M0_INTERNAL void m0_be_btree_destroy_credit(struct m0_be_btree *tree, struct m0_be_tx_credit *accum)
Definition: btree.c:1831
M0_INTERNAL int m0_fid_cmp(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:170
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL void m0_confdb_destroy_credit(struct m0_be_seg *seg, struct m0_be_tx_credit *accum)
Definition: db.c:380
static void confdb_table_fini(struct m0_be_seg *seg)
Definition: db.c:192
M0_INTERNAL void m0_be_btree_cursor_fini(struct m0_be_btree_cursor *cursor)
Definition: btree.c:2290
M0_INTERNAL int m0_xcode_dup(struct m0_xcode_ctx *dest, struct m0_xcode_ctx *src)
Definition: xcode.c:522
uint32_t cx_nr
Definition: onwire.h:256
return M0_RC(rc)
op
Definition: libdemo.c:64
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
Definition: xcode.c:390
M0_INTERNAL int m0_be_btree_cursor_next_sync(struct m0_be_btree_cursor *cur)
Definition: btree.c:2464
static int btree(struct scanner *s, struct rectype *r, char *buf)
Definition: beck.c:1270
#define M0_ENTRY(...)
Definition: trace.h:170
Definition: db.c:42
Definition: buf.h:37
static char * addr
Definition: node_k.c:37
int i
Definition: dir.c:1033
return M0_ERR(-EOPNOTSUPP)
#define M0_BE_OP_SYNC_RET(op_obj, action, member)
Definition: op.h:243
M0_INTERNAL void m0_be_btree_insert_credit2(const struct m0_be_btree *tree, m0_bcount_t nr, m0_bcount_t ksize, m0_bcount_t vsize, struct m0_be_tx_credit *accum)
Definition: btree.c:1730
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)
Definition: db.c:168
M0_INTERNAL void m0_be_btree_create_credit(const struct m0_be_btree *tree, m0_bcount_t nr, struct m0_be_tx_credit *accum)
Definition: btree.c:1783
M0_INTERNAL void m0_be_btree_insert(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_buf *key, const struct m0_buf *val)
Definition: btree.c:1932
M0_INTERNAL int m0_be_seg_dict_delete(struct m0_be_seg *seg, struct m0_be_tx *tx, const char *name)
Definition: seg_dict.c:316
uint32_t cx_nr
Definition: onwire.h:259
static int confdb_objs_count(struct m0_be_btree *btree, size_t *result)
Definition: db.c:469
static int confx_allocator_init(struct confx_allocator *alloc, const struct m0_confx *conf, struct m0_be_seg *seg, struct m0_be_tx *tx)
Definition: db.c:322
M0_INTERNAL void m0_confdb_fini(struct m0_be_seg *seg)
Definition: db.c:464
#define M0_ASSERT(cond)
M0_INTERNAL void m0_be_btree_destroy(struct m0_be_btree *tree, struct m0_be_tx *tx, struct m0_be_op *op)
Definition: btree.c:1538
static m0_bcount_t confdb_ksize(const void *key)
Definition: db.c:145
M0_INTERNAL int m0_confdb_read(struct m0_be_seg *seg, struct m0_confx **out)
Definition: db.c:544
M0_INTERNAL struct m0_be_allocator * m0_be_seg_allocator(struct m0_be_seg *seg)
Definition: stubs.c:113
m0_bcount_t a_used
Definition: db.c:121
M0_INTERNAL void m0_be_alloc(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void **ptr, m0_bcount_t size)
Definition: alloc.c:1091
static struct ff2c_term * alloc(void)
Definition: parser.c:37
void * m0_alloc(size_t size)
Definition: memory.c:126
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
M0_INTERNAL void m0_be_btree_fini(struct m0_be_btree *tree)
Definition: btree.c:1503
Definition: xcode.h:73
M0_INTERNAL int m0_be_btree_cursor_first_sync(struct m0_be_btree_cursor *cur)
Definition: btree.c:2348
static m0_bcount_t conf_sizeof(const struct m0_confx *conf)
Definition: db.c:301
#define M0_BE_FREE_PTR_SYNC(ptr, seg, tx)
Definition: alloc.h:345
Definition: seg.h:66
M0_INTERNAL int m0_confdb_destroy(struct m0_be_seg *seg, struct m0_be_tx *tx)
Definition: db.c:443
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)
Definition: db.c:331
M0_INTERNAL size_t m0_confx_sizeof(void)
Definition: db.c:61
struct m0_xcode_field _p_field[M0_CONF_OBJ_TYPE_MAX]
Definition: db.c:44
M0_INTERNAL void m0_be_btree_cursor_kv_get(struct m0_be_btree_cursor *cur, struct m0_buf *key, struct m0_buf *val)
Definition: btree.c:2485
M0_INTERNAL void m0_xc_m0_confx_obj_struct_fini(void)
Definition: db.c:58
static void * confdb_obj_alloc(struct m0_xcode_cursor *ctx, size_t nob)
Definition: db.c:204
M0_INTERNAL void m0_be_seg_dict_delete_credit(struct m0_be_seg *seg, const char *name, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:131
struct confx_allocator * c_alloc
Definition: db.c:141
void * a_chunk
Definition: db.c:119
struct m0_xcode_ctx c_xctx
Definition: db.c:142
static int confx_obj_measure(struct m0_confx_obj *xobj)
Definition: db.c:94
static int __confdb_free(struct m0_be_btree *btree, struct m0_be_seg *seg, struct m0_be_tx *tx)
Definition: db.c:401
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
Definition: fid.h:38
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static struct m0_be_seg * seg
Definition: db.c:37
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL void m0_be_btree_init(struct m0_be_btree *tree, struct m0_be_seg *seg, const struct m0_be_btree_kv_ops *ops)
Definition: btree.c:1487
M0_INTERNAL void m0_be_btree_cursor_init(struct m0_be_btree_cursor *cur, struct m0_be_btree *btree)
Definition: btree.c:2281
size_t xct_sizeof
Definition: xcode.h:341
#define M0_XCODE_OBJ(type, ptr)
Definition: xcode.h:962
M0_INTERNAL int m0_confdb_create_credit(struct m0_be_seg *seg, const struct m0_confx *conf, struct m0_be_tx_credit *accum)
Definition: db.c:255
Definition: nucleus.c:42
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
Definition: xcode.c:373
#define out(...)
Definition: gen.c:41
m0_bcount_t a_total
Definition: db.c:120
static int confx_obj_dup(struct confx_allocator *alloc, struct m0_confx_obj **dest, struct m0_confx_obj *src)
Definition: db.c:222
static void xcode_ctx_init(struct m0_xcode_ctx *ctx, struct m0_confx_obj *xobj, bool allocated)
Definition: db.c:79
M0_INTERNAL void m0_be_seg_dict_insert_credit(struct m0_be_seg *seg, const char *name, struct m0_be_tx_credit *accum)
Definition: seg_dict.c:114
void m0_free(void *data)
Definition: memory.c:146
struct __pack conx_obj
Definition: db.c:51
M0_INTERNAL int m0_be_seg_dict_lookup(struct m0_be_seg *seg, const char *name, void **out)
Definition: seg_dict.c:180
#define M0_BUF_INIT(size, data)
Definition: buf.h:64
static const char btree_name[]
Definition: db.c:166
struct m0_pdclust_src_addr src
Definition: fd.c:108
int32_t rc
Definition: trigger_fop.h:47
#define M0_BASSERT(cond)
const char * xct_name
Definition: xcode.h:318
#define M0_BE_FREE_CREDIT_PTR(ptr, seg, accum)
Definition: alloc.h:359
const struct m0_fid * m0_conf_objx_fid(const struct m0_confx_obj *obj)
Definition: obj_ops.c:266
Definition: tx.h:280
Definition: idx_mock.c:47
#define M0_UNUSED
Definition: misc.h:380