23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_BE 27 #include "be/fmt_xc.h" 44 M0_IMPOSSIBLE(
"Xcode allocate shouldn't be called from be/fmt/decode");
49 M0_IMPOSSIBLE(
"Xcode free shouldn't be called from be/fmt/decode");
99 uint64_t group_size_max =
fctx->cfg->dc_group_size_max;
106 if (M0_IN(
top->s_obj.xo_type, (m0_be_fmt_content_header_reg_xc,
107 m0_be_fmt_content_header_tx_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,
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;
121 err = nob >= group_size_max;
127 top->s_obj.xo_type->xct_name,
128 top->s_obj.xo_type->xct_sizeof,
204 for (
i = 0;
i < payloads->fcp_nr; ++
i)
208 for (
i = 0;
i < reg_area->cra_nr; ++
i)
228 size =
obj->xo_type->xct_sizeof;
231 obj->xo_type->xct_name,
obj->xo_type->xct_aggr,
it->xcu_depth,
243 fg->
fg_cfg = (uint64_t)cfg;
387 .chg_addr = (uint64_t) freg->
fr_addr,
488 _0C(hra->chr_nr == ra->cra_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) &&
497 _0C(ht->cht_nr == cp->fcp_nr) &&
503 #define M0_BE_FMT_DEFINE_INIT_SIMPLE(name) \ 505 m0_be_fmt_##name##_init(struct m0_be_fmt_##name *obj, \ 506 const struct m0_be_fmt_##name##_cfg *cfg) \ 510 M0_INTERNAL void m0_be_fmt_##name##_fini(struct m0_be_fmt_##name *obj) \ 512 M0_INTERNAL void m0_be_fmt_##name##_reset(struct m0_be_fmt_##name *obj) \ 514 M0_INTERNAL m0_bcount_t \ 515 m0_be_fmt_##name##_size_max(const struct m0_be_fmt_##name##_cfg *cfg) \ 517 return m0_be_fmt_##name##_size(NULL); \ 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) \ 523 return be_fmt_xcoded_size(m0_be_fmt_##name##_xc, obj); \ 525 M0_INTERNAL int m0_be_fmt_##name##_encode(struct m0_be_fmt_##name *obj, \ 526 struct m0_bufvec_cursor *cur) \ 528 return be_fmt_encode(m0_be_fmt_##name##_xc, obj, cur); \ 530 M0_INTERNAL int m0_be_fmt_##name##_encode_buf(struct m0_be_fmt_##name *obj, \ 531 struct m0_buf *buf) \ 533 struct m0_bufvec bvec; \ 534 struct m0_bufvec_cursor cur; \ 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); \ 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) \ 545 return be_fmt_decode(m0_be_fmt_##name##_xc, (void **)obj, cur, cfg); \ 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) \ 552 struct m0_bufvec bvec; \ 553 struct m0_bufvec_cursor cur; \ 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); \ 559 M0_INTERNAL void m0_be_fmt_##name##_decoded_free(struct m0_be_fmt_##name *obj) \ 561 be_fmt_decoded_free(m0_be_fmt_##name##_xc, obj); \ 571 obj->lrh_io_size.lrhs_nr = 0;
574 return obj->lrh_io_size.lrhs_size ==
NULL ? -ENOMEM : 0;
586 obj->lrh_io_size.lrhs_nr = 0;
598 return m0_be_fmt_log_record_header_size(&
obj);
629 #undef M0_TRACE_SUBSYSTEM
M0_INTERNAL struct m0_xcode_cursor_frame * m0_xcode_cursor_top(struct m0_xcode_cursor *it)
struct m0_xcode_cursor xcx_it
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
uint64_t fgc_payload_size_max
M0_INTERNAL uint32_t m0_be_fmt_group_reg_nr(const struct m0_be_fmt_group *fg)
M0_INTERNAL void * m0_xcode_ctx_top(const struct m0_xcode_ctx *ctx)
#define M0_ALLOC_ARR(arr, nr)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
M0_INTERNAL void m0_be_fmt_group_reg_add(struct m0_be_fmt_group *fg, const struct m0_be_fmt_reg *freg)
#define M0_MEMBER_SIZE(type, member)
#define M0_LOG(level,...)
#define M0_BE_FMT_DEFINE_INIT_SIMPLE(name)
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
M0_INTERNAL void m0_be_fmt_type_trace_end(const struct m0_xcode_cursor *it)
static struct m0_be_emap_cursor it
M0_INTERNAL void m0_be_fmt_log_record_header_fini(struct m0_be_fmt_log_record_header *obj)
M0_INTERNAL void m0_xcode_free_obj(struct m0_xcode_obj *obj)
M0_INTERNAL int m0_xcode_decode(struct m0_xcode_ctx *ctx)
#define container_of(ptr, type, member)
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)
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)
M0_INTERNAL void m0_be_fmt_log_record_header_reset(struct m0_be_fmt_log_record_header *obj)
M0_INTERNAL int m0_xcode_length(struct m0_xcode_ctx *ctx)
#define M0_BE_FMT_TX(payload, id)
static m0_bcount_t be_fmt_xcoded_size(struct m0_xcode_type *type, void *object)
static void be_fmt_decoded_free(struct m0_xcode_type *type, void *object)
M0_INTERNAL void m0_be_fmt_group_decoded_free(struct m0_be_fmt_group *fg)
M0_INTERNAL void m0_be_fmt_log_record_header_io_size_add(struct m0_be_fmt_log_record_header *obj, m0_bcount_t size)
uint64_t fgc_reg_size_max
M0_INTERNAL struct m0_be_fmt_group_info * m0_be_fmt_group_info_get(struct m0_be_fmt_group *fg)
struct m0_be_fmt_content fg_content
M0_INTERNAL m0_bcount_t m0_be_fmt_group_size_max(const struct m0_be_fmt_group_cfg *cfg)
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)
static void disabled_xcode_free(struct m0_xcode_cursor *it)
struct m0_be_fmt_group_header fg_header
M0_INTERNAL int m0_be_fmt_type_trace(const struct m0_xcode_cursor *it)
static void * disabled_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
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)
struct m0_buf bft_payload
M0_INTERNAL void * m0_xcode_alloc(struct m0_xcode_cursor *it, size_t nob)
static void * be_fmt_alloc(struct m0_xcode_cursor *it, size_t nob)
static bool m0_be_fmt_group__invariant(struct m0_be_fmt_group *fg)
M0_INTERNAL m0_bcount_t m0_be_fmt_group_size(struct m0_be_fmt_group *fg)
M0_INTERNAL void m0_be_fmt_group_fini(struct m0_be_fmt_group *fg)
#define M0_BE_FMT_DEFINE_XCODE(name)
struct m0_be_fmt_content_header fg_content_header
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)
static void be_fmt_content_bufs_init(struct m0_be_fmt_group *fg)
struct m0_buf * fcp_payload
M0_INTERNAL m0_bcount_t m0_be_fmt_log_record_header_size_max(const struct m0_be_fmt_log_record_header_cfg *cfg)
const struct m0_be_fmt_decode_cfg * cfg
M0_INTERNAL int m0_xcode_encode(struct m0_xcode_ctx *ctx)
static int be_fmt_encode(struct m0_xcode_type *type, void *object, struct m0_bufvec_cursor *cur)
M0_INTERNAL void m0_be_fmt_group_tx_add(struct m0_be_fmt_group *fg, const struct m0_be_fmt_tx *ftx)
#define M0_XCODE_OBJ(type, ptr)
#define M0_BE_FMT_REG(size, addr, buf)
static struct m0_sns_cm_file_ctx fctx
struct m0_be_fmt_content_payloads fmc_payloads
M0_INTERNAL void m0_xcode_ctx_init(struct m0_xcode_ctx *ctx, const struct m0_xcode_obj *obj)
int(* dc_iter)(const struct m0_xcode_cursor *it)
M0_INTERNAL void m0_be_fmt_group_reset(struct m0_be_fmt_group *fg)
void(* dc_iter_end)(const struct m0_xcode_cursor *it)
M0_INTERNAL bool m0_be_fmt_group_sanity_check(struct m0_be_fmt_group *fg)
#define M0_BUF_INIT(size, data)
M0_INTERNAL int m0_be_fmt_group_init(struct m0_be_fmt_group *fg, const struct m0_be_fmt_group_cfg *cfg)
M0_INTERNAL uint32_t m0_be_fmt_group_tx_nr(const struct m0_be_fmt_group *fg)
M0_INTERNAL int m0_be_fmt_group_encode(struct m0_be_fmt_group *fg, struct m0_bufvec_cursor *cur)
struct m0_be_fmt_content_reg_area fmc_reg_area
#define M0_IMPOSSIBLE(fmt,...)