Motr  M0
fmt.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2014-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_BE
24 #include "lib/trace.h"
25 
26 #include "be/fmt.h"
27 #include "be/fmt_xc.h"
28 
29 #include "lib/buf.h" /* m0_buf */
30 #include "lib/vec.h" /* M0_BUFVEC_INIT_BUF */
31 #include "lib/misc.h" /* container_of */
32 #include "lib/errno.h" /* ENOMEM */
33 #include "lib/memory.h" /* M0_ALLOC_ARR */
34 #include "xcode/xcode.h" /* m0_xcode_ctx */
35 
42 static void *disabled_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
43 {
44  M0_IMPOSSIBLE("Xcode allocate shouldn't be called from be/fmt/decode");
45 }
46 
48 {
49  M0_IMPOSSIBLE("Xcode free shouldn't be called from be/fmt/decode");
50 }
51 
53  void *object)
54 {
55  struct m0_xcode_ctx ctx;
56  struct m0_xcode_obj obj = M0_XCODE_OBJ(type, object);
57 
59  ctx.xcx_alloc = disabled_xcode_alloc;
60  ctx.xcx_free = disabled_xcode_free;
61 
62  return m0_xcode_length(&ctx);
63 }
64 
65 static int be_fmt_encode(struct m0_xcode_type *type,
66  void *object,
67  struct m0_bufvec_cursor *cur)
68 {
69  struct m0_xcode_ctx ctx;
70  struct m0_xcode_obj obj = M0_XCODE_OBJ(type, object);
71  int rc;
72 
74 
75  ctx.xcx_alloc = disabled_xcode_alloc;
76  ctx.xcx_free = disabled_xcode_free;
77 
78  ctx.xcx_buf = *cur;
80  if (rc == 0)
81  *cur = ctx.xcx_buf;
82 
83  return rc;
84 }
85 
87  struct m0_xcode_ctx ctx;
88  const struct m0_be_fmt_decode_cfg *cfg;
89  int err;
90 };
91 
92 static void *be_fmt_alloc(struct m0_xcode_cursor *it, size_t nob)
93 {
94  struct m0_xcode_ctx *xctx =
96  struct m0_fmt_xcode_ctx *fctx =
97  container_of(xctx, struct m0_fmt_xcode_ctx, ctx);
98 
99  uint64_t group_size_max = fctx->cfg->dc_group_size_max;
100 
101  struct m0_xcode_cursor_frame *top = m0_xcode_cursor_top(it);
102  bool err;
103 
104  fctx->err = 0;
105 
106  if (M0_IN(top->s_obj.xo_type, (m0_be_fmt_content_header_reg_xc,
107  m0_be_fmt_content_header_tx_xc,
108  m0_buf_xc)))
109  err = nob < top->s_obj.xo_type->xct_sizeof ||
110  nob >= group_size_max;
111  else if (M0_IN(top->s_obj.xo_type, (m0_be_fmt_cblock_xc,
112  m0_be_fmt_group_xc,
113  m0_be_fmt_log_header_xc,
114  m0_be_fmt_log_record_header_xc,
115  m0_be_fmt_log_record_footer_xc,
116  m0_be_fmt_log_store_header_xc)))
117  err = nob != top->s_obj.xo_type->xct_sizeof ||
118  nob >= group_size_max ||
119  top->s_obj.xo_type->xct_sizeof >= group_size_max;
120  else {
121  err = nob >= group_size_max;
122  fctx->err = EPROTO;
123  }
124 
125  if (err)
126  M0_LOG(M0_WARN, "type: %s, sizeof: %lu, nob: %lu",
127  top->s_obj.xo_type->xct_name,
128  top->s_obj.xo_type->xct_sizeof,
129  nob);
130 
131  return err ? NULL : m0_xcode_alloc(it, nob);
132 }
133 
134 static int be_fmt_decode(struct m0_xcode_type *type,
135  void **object,
136  struct m0_bufvec_cursor *cur,
137  const struct m0_be_fmt_decode_cfg *cfg)
138 {
139  struct m0_fmt_xcode_ctx fctx;
140  struct m0_xcode_ctx *ctx = &fctx.ctx;
142  int rc;
143 
145  fctx.cfg = cfg;
146  ctx->xcx_iter = cfg->dc_iter;
147  ctx->xcx_iter_end = cfg->dc_iter_end;
148 
149  /*
150  * xcode doesn't want to use default m0_xcode_alloc() (m0_alloc())
151  * if this field is not set but it uses m0_free() if xcx_free is not
152  * set. It's just some dark magic. It will be fixed some day. I hope..
153  */
154  ctx->xcx_alloc = be_fmt_alloc;
155 
156  ctx->xcx_buf = *cur;
158 
159  if (rc == -ENOMEM)
160  rc = -fctx.err;
161 
162  if (rc == 0)
163  *cur = ctx->xcx_buf;
164 
165  *object = rc == 0 ? m0_xcode_ctx_top(ctx) : NULL;
166 
167  return rc;
168 }
169 
171  void *object)
172 {
173  struct m0_xcode_obj obj = M0_XCODE_OBJ(type, object);
174 
176 }
177 
178 /* -------------------------------------------------------------------------- */
179 
181 {
182  const struct m0_be_fmt_content_header_txs *ht =
184  const struct m0_be_fmt_content_payloads *cp =
186  const struct m0_be_fmt_group_cfg *cfg = (void *)fg->fg_cfg;
187 
188  return _0C(ht->cht_nr < cfg->fgc_tx_nr_max) &&
189  _0C(cp->fcp_nr < cfg->fgc_tx_nr_max) &&
190  _0C(fg->fg_header.fgh_tx_nr < cfg->fgc_tx_nr_max) &&
191  _0C(ht->cht_nr == cp->fcp_nr) &&
192  _0C(ht->cht_nr == fg->fg_header.fgh_tx_nr);
193 }
194 
196 {
197  const struct m0_be_fmt_group_cfg *cfg = (void *)fg->fg_cfg;
198  struct m0_be_fmt_content_payloads *payloads =
200  struct m0_be_fmt_content_reg_area *reg_area =
202  int i;
203 
204  for (i = 0; i < payloads->fcp_nr; ++i)
205  m0_buf_init(&payloads->fcp_payload[i], NULL,
206  cfg->fgc_payload_size_max);
207 
208  for (i = 0; i < reg_area->cra_nr; ++i)
209  m0_buf_init(&reg_area->cra_reg[i], NULL,
210  cfg->fgc_reg_size_max);
211 }
212 
213 M0_INTERNAL void m0_be_fmt_type_trace_end(const struct m0_xcode_cursor *it)
214 {
215  M0_LOG(M0_DEBUG, "last");
216 }
217 
218 M0_INTERNAL int m0_be_fmt_type_trace(const struct m0_xcode_cursor *it)
219 {
220  struct m0_xcode_obj *obj;
221  void *ptr;
223 
224  M0_PRE(it != NULL);
225 
226  obj = &m0_xcode_cursor_top((struct m0_xcode_cursor *)it)->s_obj;
227  ptr = obj->xo_ptr;
228  size = obj->xo_type->xct_sizeof;
229 
230  M0_LOG(M0_DEBUG, "name: %s, type:%d, depth:%d, ptr: %p, size: %"PRId64,
231  obj->xo_type->xct_name, obj->xo_type->xct_aggr, it->xcu_depth,
232  ptr, size);
233 
234  return 0;
235 }
236 
237 M0_INTERNAL int m0_be_fmt_group_init(struct m0_be_fmt_group *fg,
238  const struct m0_be_fmt_group_cfg *cfg)
239 {
240  struct m0_be_fmt_content_header *cheader = &fg->fg_content_header;
241  struct m0_be_fmt_content *content = &fg->fg_content;
242 
243  fg->fg_cfg = (uint64_t)cfg;
244 
245  cheader->fch_txs.cht_nr = cfg->fgc_tx_nr_max;
246  cheader->fch_reg_area.chr_nr = cfg->fgc_reg_nr_max;
247  content->fmc_payloads.fcp_nr = cfg->fgc_tx_nr_max;
248  content->fmc_reg_area.cra_nr = cfg->fgc_reg_nr_max;
249 
250  M0_PRE(cheader->fch_txs.cht_tx == NULL);
251  M0_PRE(cheader->fch_reg_area.chr_reg == NULL);
252  M0_PRE(content->fmc_payloads.fcp_payload == NULL);
253  M0_PRE(content->fmc_reg_area.cra_reg == NULL);
254 
255  M0_ALLOC_ARR(cheader->fch_txs.cht_tx, cfg->fgc_tx_nr_max);
256  if (cheader->fch_txs.cht_tx == NULL)
257  goto enomem;
258 
260  if (cheader->fch_reg_area.chr_reg == NULL)
261  goto enomem;
262 
264  if (content->fmc_payloads.fcp_payload == NULL)
265  goto enomem;
266 
268  if (content->fmc_reg_area.cra_reg == NULL)
269  goto enomem;
270 
272 
273  cheader->fch_txs.cht_nr = 0;
274  cheader->fch_reg_area.chr_nr = 0;
275  content->fmc_payloads.fcp_nr = 0;
276  content->fmc_reg_area.cra_nr = 0;
277  fg->fg_header.fgh_reg_nr = 0;
278  fg->fg_header.fgh_tx_nr = 0;
279 
280  return 0;
281 enomem:
283  return -ENOMEM;
284 }
285 
286 M0_INTERNAL void m0_be_fmt_group_fini(struct m0_be_fmt_group *fg)
287 {
288  struct m0_be_fmt_content_header *cheader = &fg->fg_content_header;
289  struct m0_be_fmt_content *content = &fg->fg_content;
290 
291  m0_free(content->fmc_reg_area.cra_reg);
292  m0_free(content->fmc_payloads.fcp_payload);
293  m0_free(cheader->fch_reg_area.chr_reg);
294  m0_free(cheader->fch_txs.cht_tx);
295 }
296 
297 M0_INTERNAL void m0_be_fmt_group_reset(struct m0_be_fmt_group *fg)
298 {
299  struct m0_be_fmt_content_header *cheader = &fg->fg_content_header;
300  struct m0_be_fmt_content *content = &fg->fg_content;
301 
302  cheader->fch_txs.cht_nr = 0;
303  cheader->fch_reg_area.chr_nr = 0;
304  content->fmc_payloads.fcp_nr = 0;
305  content->fmc_reg_area.cra_nr = 0;
306  fg->fg_header.fgh_reg_nr = 0;
307  fg->fg_header.fgh_tx_nr = 0;
308 
309 
310  M0_ASSERT(cheader->fch_txs.cht_tx != NULL);
311  M0_ASSERT(cheader->fch_reg_area.chr_reg != NULL);
312  M0_ASSERT(content->fmc_payloads.fcp_payload != NULL);
313  M0_ASSERT(content->fmc_reg_area.cra_reg != NULL);
314 
316 }
317 
319 {
320  return be_fmt_xcoded_size(m0_be_fmt_group_xc, fg);
321 }
322 
323 M0_INTERNAL m0_bcount_t
325 {
326  return sizeof(struct m0_be_fmt_group_header) +
327  /* m0_be_fmt_content_header */
329  sizeof(struct m0_be_fmt_content_header_tx) *
330  cfg->fgc_tx_nr_max +
332  chr_nr) +
333  sizeof(struct m0_be_fmt_content_header_reg) *
334  cfg->fgc_reg_nr_max +
335  /* m0_be_fmt_content */
337  (sizeof(struct m0_buf) - M0_MEMBER_SIZE(struct m0_buf, b_addr)) *
338  cfg->fgc_tx_nr_max +
339  cfg->fgc_payload_size_max +
341  (sizeof(struct m0_buf) - M0_MEMBER_SIZE(struct m0_buf, b_addr)) *
342  cfg->fgc_reg_nr_max +
343  cfg->fgc_reg_size_max +
345 }
346 
347 M0_INTERNAL int m0_be_fmt_group_encode(struct m0_be_fmt_group *fg,
348  struct m0_bufvec_cursor *cur)
349 {
351 
352  return be_fmt_encode(m0_be_fmt_group_xc, fg, cur);
353 }
354 
355 M0_INTERNAL int m0_be_fmt_group_decode(struct m0_be_fmt_group **fg,
356  struct m0_bufvec_cursor *cur,
357  const struct m0_be_fmt_decode_cfg *cfg)
358 {
359  return be_fmt_decode(m0_be_fmt_group_xc, (void **)fg, cur, cfg);
360 }
361 
362 M0_INTERNAL void m0_be_fmt_group_decoded_free(struct m0_be_fmt_group *fg)
363 {
364  be_fmt_decoded_free(m0_be_fmt_group_xc, fg);
365 }
366 
367 M0_INTERNAL void m0_be_fmt_group_reg_add(struct m0_be_fmt_group *fg,
368  const struct m0_be_fmt_reg *freg)
369 {
371  struct m0_be_fmt_content_reg_area *ra;
372  const struct m0_be_fmt_group_cfg *cfg = (void *)fg->fg_cfg;
373 
374  ra = &fg->fg_content.fmc_reg_area;
375  hra = &fg->fg_content_header.fch_reg_area;
376 
377  M0_ASSERT(ra->cra_nr < cfg->fgc_reg_nr_max);
378  M0_ASSERT(hra->chr_nr < cfg->fgc_reg_nr_max);
380  M0_ASSERT(hra->chr_nr == ra->cra_nr);
381  M0_ASSERT(hra->chr_nr == fg->fg_header.fgh_reg_nr);
382  M0_ASSERT(freg->fr_size <= cfg->fgc_reg_size_max);
383 
384  ra->cra_reg[ra->cra_nr++] = M0_BUF_INIT(freg->fr_size, freg->fr_buf);
385  hra->chr_reg[hra->chr_nr++] = (struct m0_be_fmt_content_header_reg) {
386  .chg_size = freg->fr_size,
387  .chg_addr = (uint64_t) freg->fr_addr,
388  };
389  fg->fg_header.fgh_reg_nr++;
390 }
391 
392 M0_INTERNAL uint32_t m0_be_fmt_group_reg_nr(const struct m0_be_fmt_group *fg)
393 {
394  return fg->fg_header.fgh_reg_nr;
395 }
396 
397 M0_INTERNAL void m0_be_fmt_group_reg_by_id(const struct m0_be_fmt_group *fg,
398  uint32_t index,
399  struct m0_be_fmt_reg *freg)
400 {
401  const struct m0_be_fmt_content_header_reg_area *hra;
402  const struct m0_be_fmt_content_reg_area *ra;
403 
405 
406  ra = &fg->fg_content.fmc_reg_area;
407  hra = &fg->fg_content_header.fch_reg_area;
408 
409  *freg = M0_BE_FMT_REG(hra->chr_reg[index].chg_size,
410  (void *)hra->chr_reg[index].chg_addr,
411  ra->cra_reg[index].b_addr);
412 }
413 
414 M0_INTERNAL void m0_be_fmt_group_tx_add(struct m0_be_fmt_group *fg,
415  const struct m0_be_fmt_tx *ftx)
416 {
417  struct m0_be_fmt_content_header_txs *ht;
418  struct m0_be_fmt_content_payloads *cp;
419  const struct m0_be_fmt_group_cfg *cfg = (void *)fg->fg_cfg;
420 
421  ht = &fg->fg_content_header.fch_txs;
422  cp = &fg->fg_content.fmc_payloads;
423 
425  M0_ASSERT(m0_reduce(i, ht->cht_nr, 0,
426  + ht->cht_tx[i].chx_payload_size) +
427  ftx->bft_payload.b_nob <= cfg->fgc_payload_size_max);
428 
429  ht->cht_tx[ht->cht_nr++] = (struct m0_be_fmt_content_header_tx) {
430  .chx_tx_id = ftx->bft_id,
431  .chx_payload_size = ftx->bft_payload.b_nob,
432  };
433 
434  cp->fcp_payload[cp->fcp_nr++] = ftx->bft_payload;
435  fg->fg_header.fgh_tx_nr++;
436 }
437 
438 M0_INTERNAL uint32_t m0_be_fmt_group_tx_nr(const struct m0_be_fmt_group *fg)
439 {
440  return fg->fg_header.fgh_tx_nr;
441 }
442 
443 M0_INTERNAL void m0_be_fmt_group_tx_by_id(const struct m0_be_fmt_group *fg,
444  uint32_t index,
445  struct m0_be_fmt_tx *ftx)
446 {
447  const struct m0_be_fmt_content_header_txs *ht;
448  const struct m0_be_fmt_content_payloads *cp;
449 
451 
452  ht = &fg->fg_content_header.fch_txs;
453  cp = &fg->fg_content.fmc_payloads;
454 
455  *ftx = M0_BE_FMT_TX(cp->fcp_payload[index],
456  ht->cht_tx[index].chx_tx_id);
457 }
458 
459 M0_INTERNAL struct m0_be_fmt_group_info *
461 {
462  return &fg->fg_header.fgh_info;
463 }
464 
465 M0_INTERNAL bool m0_be_fmt_group_sanity_check(struct m0_be_fmt_group *fg)
466 {
467  const struct m0_be_fmt_group_cfg *cfg = (void *)fg->fg_cfg;
468  const struct m0_be_fmt_content_header_txs *ht;
469  const struct m0_be_fmt_content_payloads *cp;
470  const struct m0_be_fmt_content_reg_area *ra;
471  const struct m0_be_fmt_content_header_reg_area *hra;
472  const struct m0_be_fmt_content_header *cheader;
473  const struct m0_be_fmt_content *content;
474 
475 
476  cheader = &fg->fg_content_header;
477  content = &fg->fg_content;
478 
479  ra = &fg->fg_content.fmc_reg_area;
480  hra = &fg->fg_content_header.fch_reg_area;
481 
482  cp = &fg->fg_content.fmc_payloads;
483  ht = &fg->fg_content_header.fch_txs;
484 
485  return _0C(ra->cra_nr < cfg->fgc_reg_nr_max) &&
486  _0C(hra->chr_nr < cfg->fgc_reg_nr_max) &&
487  _0C(fg->fg_header.fgh_reg_nr < cfg->fgc_reg_nr_max) &&
488  _0C(hra->chr_nr == ra->cra_nr) &&
489  _0C(hra->chr_nr == fg->fg_header.fgh_reg_nr) &&
490  _0C(cheader->fch_txs.cht_tx != NULL) &&
491  _0C(cheader->fch_reg_area.chr_reg != NULL) &&
492  _0C(content->fmc_payloads.fcp_payload != NULL) &&
493  _0C(content->fmc_reg_area.cra_reg != NULL) &&
494  _0C(ht->cht_nr < cfg->fgc_tx_nr_max) &&
495  _0C(cp->fcp_nr < cfg->fgc_tx_nr_max) &&
496  _0C(fg->fg_header.fgh_tx_nr < cfg->fgc_tx_nr_max) &&
497  _0C(ht->cht_nr == cp->fcp_nr) &&
498  _0C(ht->cht_nr == fg->fg_header.fgh_tx_nr);
499 }
500 
501 /* -------------------------------------------------------------------------- */
502 
503 #define M0_BE_FMT_DEFINE_INIT_SIMPLE(name) \
504 M0_INTERNAL int \
505 m0_be_fmt_##name##_init(struct m0_be_fmt_##name *obj, \
506  const struct m0_be_fmt_##name##_cfg *cfg) \
507 { \
508  return 0; \
509 } \
510 M0_INTERNAL void m0_be_fmt_##name##_fini(struct m0_be_fmt_##name *obj) \
511 {} \
512 M0_INTERNAL void m0_be_fmt_##name##_reset(struct m0_be_fmt_##name *obj) \
513 {} \
514 M0_INTERNAL m0_bcount_t \
515 m0_be_fmt_##name##_size_max(const struct m0_be_fmt_##name##_cfg *cfg) \
516 { \
517  return m0_be_fmt_##name##_size(NULL); \
518 }
519 
520 #define M0_BE_FMT_DEFINE_XCODE(name) \
521 M0_INTERNAL m0_bcount_t m0_be_fmt_##name##_size(struct m0_be_fmt_##name *obj) \
522 { \
523  return be_fmt_xcoded_size(m0_be_fmt_##name##_xc, obj); \
524 } \
525 M0_INTERNAL int m0_be_fmt_##name##_encode(struct m0_be_fmt_##name *obj, \
526  struct m0_bufvec_cursor *cur) \
527 { \
528  return be_fmt_encode(m0_be_fmt_##name##_xc, obj, cur); \
529 } \
530 M0_INTERNAL int m0_be_fmt_##name##_encode_buf(struct m0_be_fmt_##name *obj, \
531  struct m0_buf *buf) \
532 { \
533  struct m0_bufvec bvec; \
534  struct m0_bufvec_cursor cur; \
535  \
536  bvec = M0_BUFVEC_INIT_BUF(&buf->b_addr, &buf->b_nob); \
537  m0_bufvec_cursor_init(&cur, &bvec); \
538  return m0_be_fmt_##name##_encode(obj, &cur); \
539 } \
540 M0_INTERNAL int \
541 m0_be_fmt_##name##_decode(struct m0_be_fmt_##name **obj, \
542  struct m0_bufvec_cursor *cur, \
543  const struct m0_be_fmt_decode_cfg *cfg) \
544 { \
545  return be_fmt_decode(m0_be_fmt_##name##_xc, (void **)obj, cur, cfg); \
546 } \
547 M0_INTERNAL int \
548 m0_be_fmt_##name##_decode_buf(struct m0_be_fmt_##name **obj, \
549  struct m0_buf *buf, \
550  const struct m0_be_fmt_decode_cfg *cfg) \
551 { \
552  struct m0_bufvec bvec; \
553  struct m0_bufvec_cursor cur; \
554  \
555  bvec = M0_BUFVEC_INIT_BUF(&buf->b_addr, &buf->b_nob); \
556  m0_bufvec_cursor_init(&cur, &bvec); \
557  return m0_be_fmt_##name##_decode(obj, &cur, cfg); \
558 } \
559 M0_INTERNAL void m0_be_fmt_##name##_decoded_free(struct m0_be_fmt_##name *obj) \
560 { \
561  be_fmt_decoded_free(m0_be_fmt_##name##_xc, obj); \
562 }
563 
564 /* -------------------------------------------------------------------------- */
565 
566 M0_INTERNAL int
568  const struct m0_be_fmt_log_record_header_cfg *cfg)
569 {
570  obj->lrh_io_nr_max = cfg->lrhc_io_nr_max;
571  obj->lrh_io_size.lrhs_nr = 0;
572  M0_ALLOC_ARR(obj->lrh_io_size.lrhs_size, cfg->lrhc_io_nr_max);
573 
574  return obj->lrh_io_size.lrhs_size == NULL ? -ENOMEM : 0;
575 }
576 
577 M0_INTERNAL void
579 {
580  m0_free(obj->lrh_io_size.lrhs_size);
581 }
582 
583 M0_INTERNAL void
585 {
586  obj->lrh_io_size.lrhs_nr = 0;
587 }
588 
590  const struct m0_be_fmt_log_record_header_cfg *cfg)
591 {
593  .lrh_io_size = {
594  .lrhs_nr = cfg->lrhc_io_nr_max,
595  },
596  };
597 
598  return m0_be_fmt_log_record_header_size(&obj);
599 }
600 
601 M0_INTERNAL void
604 {
605  struct m0_be_fmt_log_record_header_io_size *io_size = &obj->lrh_io_size;
606 
607  M0_PRE(io_size->lrhs_nr < obj->lrh_io_nr_max);
608  io_size->lrhs_size[io_size->lrhs_nr++] = size;
609 }
610 
611 M0_BE_FMT_DEFINE_XCODE(log_record_header);
612 
613 /* -------------------------------------------------------------------------- */
614 
615 M0_BE_FMT_DEFINE_INIT_SIMPLE(log_record_footer);
616 M0_BE_FMT_DEFINE_XCODE(log_record_footer);
617 
618 M0_BE_FMT_DEFINE_INIT_SIMPLE(log_store_header);
619 M0_BE_FMT_DEFINE_XCODE(log_store_header);
620 
622 M0_BE_FMT_DEFINE_XCODE(cblock);
623 
624 M0_BE_FMT_DEFINE_INIT_SIMPLE(log_header);
625 M0_BE_FMT_DEFINE_XCODE(log_header);
626 
629 #undef M0_TRACE_SUBSYSTEM
630 
631 /*
632  * Local variables:
633  * c-indentation-style: "K&R"
634  * c-basic-offset: 8
635  * tab-width: 8
636  * fill-column: 80
637  * scroll-step: 1
638  * End:
639  */
640 /*
641  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
642  */
M0_INTERNAL struct m0_xcode_cursor_frame * m0_xcode_cursor_top(struct m0_xcode_cursor *it)
Definition: cursor.c:41
struct m0_xcode_cursor xcx_it
Definition: xcode.h:595
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
uint64_t fgc_payload_size_max
Definition: fmt.h:240
M0_INTERNAL uint32_t m0_be_fmt_group_reg_nr(const struct m0_be_fmt_group *fg)
Definition: fmt.c:392
M0_INTERNAL void * m0_xcode_ctx_top(const struct m0_xcode_ctx *ctx)
Definition: xcode.c:746
#define M0_PRE(cond)
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
uint64_t fg_cfg
Definition: fmt.h:224
#define NULL
Definition: misc.h:38
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
uint64_t fgh_tx_nr
Definition: fmt.h:136
M0_INTERNAL void m0_be_fmt_group_reg_add(struct m0_be_fmt_group *fg, const struct m0_be_fmt_reg *freg)
Definition: fmt.c:367
#define M0_MEMBER_SIZE(type, member)
Definition: misc.h:62
void * b_addr
Definition: buf.h:39
#define M0_LOG(level,...)
Definition: trace.h:167
uint64_t fgh_reg_nr
Definition: fmt.h:137
#define M0_BE_FMT_DEFINE_INIT_SIMPLE(name)
Definition: fmt.c:503
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
Definition: buf.c:37
M0_INTERNAL void m0_be_fmt_type_trace_end(const struct m0_xcode_cursor *it)
Definition: fmt.c:213
m0_bcount_t chg_size
Definition: fmt.h:152
static struct m0_be_emap_cursor it
Definition: extmap.c:46
M0_INTERNAL void m0_be_fmt_log_record_header_fini(struct m0_be_fmt_log_record_header *obj)
Definition: fmt.c:578
M0_INTERNAL void m0_xcode_free_obj(struct m0_xcode_obj *obj)
Definition: xcode.c:248
uint64_t fgc_tx_nr_max
Definition: fmt.h:238
Definition: xcode.c:59
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL int m0_xcode_decode(struct m0_xcode_ctx *ctx)
Definition: xcode.c:380
#define container_of(ptr, type, member)
Definition: misc.h:33
uint64_t fgh_size
Definition: fmt.h:135
M0_INTERNAL void m0_be_fmt_group_tx_by_id(const struct m0_be_fmt_group *fg, uint32_t index, struct m0_be_fmt_tx *ftx)
Definition: fmt.c:443
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL int m0_be_fmt_group_decode(struct m0_be_fmt_group **fg, struct m0_bufvec_cursor *cur, const struct m0_be_fmt_decode_cfg *cfg)
Definition: fmt.c:355
M0_INTERNAL void m0_be_fmt_log_record_header_reset(struct m0_be_fmt_log_record_header *obj)
Definition: fmt.c:584
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
Definition: xcode.c:390
#define M0_BE_FMT_TX(payload, id)
Definition: fmt.h:368
static m0_bcount_t be_fmt_xcoded_size(struct m0_xcode_type *type, void *object)
Definition: fmt.c:52
Definition: buf.h:37
m0_bcount_t fr_size
Definition: fmt.h:344
int i
Definition: dir.c:1033
struct m0_be_fmt_content_header_txs fch_txs
Definition: fmt.h:162
static void be_fmt_decoded_free(struct m0_xcode_type *type, void *object)
Definition: fmt.c:170
M0_INTERNAL void m0_be_fmt_group_decoded_free(struct m0_be_fmt_group *fg)
Definition: fmt.c:362
M0_INTERNAL void m0_be_fmt_log_record_header_io_size_add(struct m0_be_fmt_log_record_header *obj, m0_bcount_t size)
Definition: fmt.c:602
uint64_t fgc_reg_size_max
Definition: fmt.h:241
M0_INTERNAL struct m0_be_fmt_group_info * m0_be_fmt_group_info_get(struct m0_be_fmt_group *fg)
Definition: fmt.c:460
void * b_addr
Definition: buf.h:231
m0_bcount_t b_nob
Definition: buf.h:38
#define M0_ASSERT(cond)
struct m0_be_fmt_content fg_content
Definition: fmt.h:217
M0_INTERNAL m0_bcount_t m0_be_fmt_group_size_max(const struct m0_be_fmt_group_cfg *cfg)
Definition: fmt.c:324
static int be_fmt_decode(struct m0_xcode_type *type, void **object, struct m0_bufvec_cursor *cur, const struct m0_be_fmt_decode_cfg *cfg)
Definition: fmt.c:134
static void disabled_xcode_free(struct m0_xcode_cursor *it)
Definition: fmt.c:47
struct m0_be_fmt_group_header fg_header
Definition: fmt.h:215
M0_INTERNAL int m0_be_fmt_type_trace(const struct m0_xcode_cursor *it)
Definition: fmt.c:218
uint64_t fg_cfg
Definition: fmt.h:99
static void * disabled_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
Definition: fmt.c:42
M0_INTERNAL int m0_be_fmt_log_record_header_init(struct m0_be_fmt_log_record_header *obj, const struct m0_be_fmt_log_record_header_cfg *cfg)
Definition: fmt.c:567
uint32_t cht_nr
Definition: fmt.h:90
struct m0_buf bft_payload
Definition: fmt.h:364
M0_INTERNAL void * m0_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
Definition: xcode.c:444
struct m0_be_fmt_content_header_tx * cht_tx
Definition: fmt.h:148
static void * be_fmt_alloc(struct m0_xcode_cursor *it, size_t nob)
Definition: fmt.c:92
uint32_t chr_nr
Definition: fmt.h:90
#define PRId64
Definition: types.h:57
static bool m0_be_fmt_group__invariant(struct m0_be_fmt_group *fg)
Definition: fmt.c:180
struct m0_be_fmt_content_header_reg_area fch_reg_area
Definition: fmt.h:163
M0_INTERNAL m0_bcount_t m0_be_fmt_group_size(struct m0_be_fmt_group *fg)
Definition: fmt.c:318
void * fr_addr
Definition: fmt.h:345
uint64_t fgc_reg_nr_max
Definition: fmt.h:239
M0_INTERNAL void m0_be_fmt_group_fini(struct m0_be_fmt_group *fg)
Definition: fmt.c:286
#define M0_BE_FMT_DEFINE_XCODE(name)
Definition: fmt.c:520
struct m0_be_fmt_content_header fg_content_header
Definition: fmt.h:216
M0_INTERNAL void m0_be_fmt_group_reg_by_id(const struct m0_be_fmt_group *fg, uint32_t index, struct m0_be_fmt_reg *freg)
Definition: fmt.c:397
static void be_fmt_content_bufs_init(struct m0_be_fmt_group *fg)
Definition: fmt.c:195
struct m0_buf * fcp_payload
Definition: fmt.h:168
struct m0_buf * cra_reg
Definition: fmt.h:173
m0_bcount_t chx_payload_size
Definition: fmt.h:143
M0_INTERNAL m0_bcount_t m0_be_fmt_log_record_header_size_max(const struct m0_be_fmt_log_record_header_cfg *cfg)
Definition: fmt.c:589
const struct m0_be_fmt_decode_cfg * cfg
Definition: fmt.c:88
struct m0_be_fmt_content_header_reg * chr_reg
Definition: fmt.h:158
m0_bcount_t size
Definition: di.c:39
#define _0C(exp)
Definition: assert.h:311
M0_INTERNAL int m0_xcode_encode(struct m0_xcode_ctx *ctx)
Definition: xcode.c:385
static int be_fmt_encode(struct m0_xcode_type *type, void *object, struct m0_bufvec_cursor *cur)
Definition: fmt.c:65
M0_INTERNAL void m0_be_fmt_group_tx_add(struct m0_be_fmt_group *fg, const struct m0_be_fmt_tx *ftx)
Definition: fmt.c:414
uint32_t cra_nr
Definition: fmt.h:90
#define M0_XCODE_OBJ(type, ptr)
Definition: xcode.h:962
#define M0_BE_FMT_REG(size, addr, buf)
Definition: fmt.h:349
static struct m0_sns_cm_file_ctx fctx
Definition: net.c:55
struct m0_be_fmt_content_payloads fmc_payloads
Definition: fmt.h:177
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
int(* dc_iter)(const struct m0_xcode_cursor *it)
Definition: fmt.h:281
int type
Definition: dir.c:1031
M0_INTERNAL void m0_be_fmt_group_reset(struct m0_be_fmt_group *fg)
Definition: fmt.c:297
struct m0_be_fmt_group_info fgh_info
Definition: fmt.h:133
void(* dc_iter_end)(const struct m0_xcode_cursor *it)
Definition: fmt.h:282
M0_INTERNAL bool m0_be_fmt_group_sanity_check(struct m0_be_fmt_group *fg)
Definition: fmt.c:465
void m0_free(void *data)
Definition: memory.c:146
#define M0_BUF_INIT(size, data)
Definition: buf.h:64
M0_INTERNAL int m0_be_fmt_group_init(struct m0_be_fmt_group *fg, const struct m0_be_fmt_group_cfg *cfg)
Definition: fmt.c:237
M0_INTERNAL uint32_t m0_be_fmt_group_tx_nr(const struct m0_be_fmt_group *fg)
Definition: fmt.c:438
void * fr_buf
Definition: fmt.h:346
M0_INTERNAL int m0_be_fmt_group_encode(struct m0_be_fmt_group *fg, struct m0_bufvec_cursor *cur)
Definition: fmt.c:347
uint64_t bft_id
Definition: fmt.h:365
int32_t rc
Definition: trigger_fop.h:47
struct m0_be_fmt_content_reg_area fmc_reg_area
Definition: fmt.h:178
Definition: trace.h:478
#define M0_IMPOSSIBLE(fmt,...)
uint32_t fcp_nr
Definition: fmt.h:90