Motr  M0
tx_group_format.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 #include <string.h>
24 
25 #include "be/tx_group_format.h"
26 
27 #include "ut/stob.h"
28 #include "ut/ut.h"
29 #include "be/ut/helper.h"
30 #include "be/seg.h"
31 #include "be/op.h" /* M0_BE_OP_SYNC */
32 #include "be/log_discard.h" /* m0_be_log_discard */
33 #include "be/pd.h" /* m0_be_pd */
34 #include "lib/arith.h"
35 #include "lib/memory.h"
36 #include "stob/stob.h"
37 #include "stob/domain.h"
38 
39 struct be_ut_tgf_tx {
42  uint64_t tgft_id;
43 };
44 
45 struct be_ut_tgf_reg {
48  void *tgfr_buf;
49 };
50 
58 };
59 
60 struct be_ut_tgf_ctx {
65  struct m0_be_pd tgfc_pd;
73 };
74 
75 /* TODO move initialisation of log to be ut helper */
76 enum {
77  BE_UT_TGF_SEG_ADDR = 0x300000000000ULL,
78  BE_UT_TGF_SEG_SIZE = 1024 * 1024,
79 
80  BE_UT_TGF_LOG_SIZE = 1024 * 1024,
84 
86 
87  BE_UT_TGF_MAGIC = 0xfffe,
88 };
89 
90 static const char *be_ut_tgf_log_sdom_location = "linuxstob:./log";
91 static const char *be_ut_tgf_log_sdom_init_cfg = "directio=true";
92 static const char *be_ut_tgf_log_sdom_create_cfg = "";
94 
95 static void be_ut_tgf_log_got_space_cb(struct m0_be_log *log)
96 {
97 }
98 
99 static void be_ut_tgf_log_cfg_set(struct m0_be_log_cfg *log_cfg,
100  struct m0_stob_domain *sdom,
101  struct m0_mutex *lock)
102 {
103  *log_cfg = (struct m0_be_log_cfg){
104  .lc_store_cfg = {
105  /* temporary solution BEGIN */
106  .lsc_stob_domain_location = "linuxstob:./log_store-tmp",
107  .lsc_stob_domain_init_cfg = "directio=true",
108  .lsc_stob_domain_key = 0x1000,
109  .lsc_stob_domain_create_cfg = NULL,
110  /* temporary solution END */
111  .lsc_size = BE_UT_TGF_LOG_SIZE,
112  .lsc_stob_create_cfg = NULL,
113  .lsc_rbuf_nr = BE_UT_TGF_LOG_RBUF_NR,
114  },
115  .lc_got_space_cb = &be_ut_tgf_log_got_space_cb,
116  .lc_lock = lock,
117  };
120  &log_cfg->lc_store_cfg.lsc_stob_id);
121 }
122 
124 {
125  struct m0_be_log_cfg log_cfg;
126  int rc;
127 
128  m0_mutex_init(&ctx->tgfc_lock);
133  &ctx->tgfc_sdom);
134  M0_UT_ASSERT(rc == 0);
135  be_ut_tgf_log_cfg_set(&log_cfg, ctx->tgfc_sdom, &ctx->tgfc_lock);
136  rc = m0_be_log_create(&ctx->tgfc_log, &log_cfg);
137  M0_UT_ASSERT(rc == 0);
138 }
139 
141 {
142  int rc;
143 
144  m0_be_log_destroy(&ctx->tgfc_log);
145  rc = m0_stob_domain_destroy(ctx->tgfc_sdom);
146  M0_UT_ASSERT(rc == 0);
147  m0_mutex_fini(&ctx->tgfc_lock);
148 }
149 
151 {
152  struct m0_be_log_cfg log_cfg;
153  int rc;
154 
155  M0_SET0(&ctx->tgfc_log);
156  be_ut_tgf_log_cfg_set(&log_cfg, ctx->tgfc_sdom, &ctx->tgfc_lock);
157  rc = m0_be_log_open(&ctx->tgfc_log, &log_cfg);
158  M0_UT_ASSERT(rc == 0);
159 }
160 
162 {
163  m0_be_log_close(&ctx->tgfc_log);
164 }
165 
167 {
168  struct m0_be_seg *seg = &ctx->tgfc_seg;
169  int rc;
170 
171  ctx->tgfc_seg_stob = m0_ut_stob_linux_get();
172  M0_UT_ASSERT(ctx->tgfc_seg_stob != NULL);
173  m0_be_seg_init(seg, ctx->tgfc_seg_stob, NULL, M0_BE_SEG_FAKE_ID);
175  (void *)BE_UT_TGF_SEG_ADDR);
176  M0_UT_ASSERT(rc == 0);
177  rc = m0_be_seg_open(seg);
178  M0_UT_ASSERT(rc == 0);
179  ctx->tgfc_seg_addr = (char*)seg->bs_addr + seg->bs_reserved;
180 }
181 
183 {
184  int rc;
185 
186  m0_be_seg_close(&ctx->tgfc_seg);
187  rc = m0_be_seg_destroy(&ctx->tgfc_seg);
188  M0_UT_ASSERT(rc == 0);
189  m0_be_seg_fini(&ctx->tgfc_seg);
190  m0_ut_stob_put(ctx->tgfc_seg_stob, true);
191 }
192 
193 static void be_ut_tgf_rnd_fill(void *buf, size_t size)
194 {
195  static uint64_t seed;
196  size_t i;
197 
198  for (i = 0; i < size; ++i) {
199  ((unsigned char *)buf)[i] = (m0_rnd64(&seed) >> 16) & 0xffULL;
200  }
201 }
202 
204  struct be_ut_tgf_group *group)
205 {
206  struct be_ut_tgf_reg *reg;
207  struct be_ut_tgf_tx *tx;
208  struct m0_be_seg *seg = &ctx->tgfc_seg;
209  void *addr = ctx->tgfc_seg_addr;
210  m0_bcount_t payload_max = 0;
211  m0_bcount_t ra_size_max = 0;
212  int rc;
213  int i;
214 
215  for (i = 0; i < group->tgfg_tx_nr; ++i) {
216  tx = &group->tgfg_txs[i];
218  M0_UT_ASSERT(rc == 0);
219  payload_max += tx->tgft_payload_size;
221  tx->tgft_payload.b_nob);
222  }
223  for (i = 0; i < group->tgfg_reg_nr; ++i) {
224  reg = &group->tgfg_regs[i];
225  reg->tgfr_buf = m0_alloc(reg->tgfr_size);
226  M0_UT_ASSERT(reg->tgfr_buf != NULL);
227  reg->tgfr_seg_addr = addr;
228  addr = (char *)addr + reg->tgfr_size;
229  ra_size_max += reg->tgfr_size;
231  }
232  M0_UT_ASSERT((char*)addr - (char*)seg->bs_addr <= seg->bs_size);
233  ctx->tgfc_seg_addr = addr;
234 
235  group->tgfg_cfg = (struct m0_be_group_format_cfg) {
236  .gfc_fmt_cfg = {
237  .fgc_tx_nr_max = group->tgfg_tx_nr,
238  .fgc_reg_nr_max = group->tgfg_reg_nr,
239  .fgc_payload_size_max = payload_max,
240  .fgc_reg_size_max = ra_size_max,
241  .fgc_seg_nr_max = BE_UT_TGF_SEG_NR_MAX,
242  },
243  .gfc_log = &ctx->tgfc_log,
244  .gfc_log_discard = &ctx->tgfc_log_discard,
245  .gfc_pd = &ctx->tgfc_pd,
246  };
247 }
248 
250  struct be_ut_tgf_group *group)
251 {
252  int i;
253 
254  for (i = 0; i < group->tgfg_tx_nr; ++i) {
255  m0_buf_free(&group->tgfg_txs[i].tgft_payload);
256  }
257  for (i = 0; i < group->tgfg_reg_nr; ++i) {
258  m0_free(group->tgfg_regs[i].tgfr_buf);
259  }
260 }
261 
263  struct be_ut_tgf_group *group)
264 {
265  int rc;
266 
267  M0_SET0(&group->tgfg_gft);
268  rc = m0_be_group_format_init(&group->tgfg_gft, &group->tgfg_cfg, NULL,
269  &ctx->tgfc_log);
270  M0_UT_ASSERT(rc == 0);
271  rc = m0_be_group_format_allocate(&group->tgfg_gft);
272  M0_UT_ASSERT(rc == 0);
273 }
274 
276  struct be_ut_tgf_group *group)
277 {
279  m0_be_group_format_fini(&group->tgfg_gft);
280 }
281 
283  struct be_ut_tgf_group *group,
284  bool seg_write)
285 {
286  struct be_ut_tgf_tx *tx;
287  struct m0_be_fmt_tx ftx;
288  struct be_ut_tgf_reg *reg;
289  struct m0_be_reg_d regd;
290  struct m0_be_fmt_group_info *info;
291  struct m0_be_seg *seg = &ctx->tgfc_seg;
292  struct m0_be_group_format *gft = &group->tgfg_gft;
293  struct m0_be_fmt_group_cfg *cfg = &group->tgfg_cfg.gfc_fmt_cfg;
294  m0_bcount_t reserved_size;
295  int rc;
296  int i;
297 
298  reserved_size = m0_be_group_format_log_reserved_size(&ctx->tgfc_log,
299  &M0_BE_TX_CREDIT(group->tgfg_reg_nr,
300  cfg->fgc_reg_size_max),
301  cfg->fgc_payload_size_max);
302  reserved_size *= group->tgfg_tx_nr;
303  m0_mutex_lock(&ctx->tgfc_lock);
304  rc = m0_be_log_reserve(&ctx->tgfc_log, reserved_size);
305  M0_UT_ASSERT(rc == 0);
306  m0_mutex_unlock(&ctx->tgfc_lock);
307 
310  for (i = 0; i < group->tgfg_tx_nr; ++i) {
311  tx = &group->tgfg_txs[i];
312  ftx = M0_BE_FMT_TX(tx->tgft_payload, tx->tgft_id);
313  m0_be_group_format_tx_add(gft, &ftx);
314  }
315  for (i = 0; i < group->tgfg_reg_nr; ++i) {
316  reg = &group->tgfg_regs[i];
317  regd = M0_BE_REG_D(M0_BE_REG(seg, reg->tgfr_size,
318  reg->tgfr_seg_addr),
319  reg->tgfr_buf);
320  m0_be_group_format_reg_log_add(gft, &regd);
321  m0_be_group_format_reg_seg_add(gft, &regd);
322  }
323  info = m0_be_group_format_group_info(gft);
324  info->gi_unknown = BE_UT_TGF_MAGIC;
325 
326  m0_mutex_lock(&ctx->tgfc_lock);
327  m0_be_group_format_log_use(gft, reserved_size);
328  m0_mutex_unlock(&ctx->tgfc_lock);
332  bo_sm.sm_rc);
333  M0_UT_ASSERT(rc == 0);
334 
335  m0_mutex_lock(&ctx->tgfc_lock);
337  m0_mutex_unlock(&ctx->tgfc_lock);
338 
339  if (seg_write) {
343  bo_sm.sm_rc);
344  M0_UT_ASSERT(rc == 0);
345  }
346 }
347 
349  struct be_ut_tgf_group *group,
350  bool seg_check)
351 {
352  struct be_ut_tgf_tx *tx;
353  struct m0_be_fmt_tx ftx;
354  struct be_ut_tgf_reg *reg;
355  struct m0_be_reg_d regd;
356  struct m0_be_fmt_group_info *info;
357  struct m0_be_group_format *gft = &group->tgfg_gft;
358  bool available;
359  int rc;
360  int nr;
361  int i;
362 
365  available = m0_be_log_recovery_record_available(&ctx->tgfc_log);
366  M0_UT_ASSERT(available);
367  m0_mutex_lock(&ctx->tgfc_lock);
368  m0_be_group_format_recovery_prepare(gft, &ctx->tgfc_log);
369  m0_mutex_unlock(&ctx->tgfc_lock);
372  bo_sm.sm_rc);
373  M0_UT_ASSERT(rc == 0);
375  M0_UT_ASSERT(rc == 0);
376  info = m0_be_group_format_group_info(gft);
379  M0_UT_ASSERT(nr == group->tgfg_tx_nr);
380  for (i = 0; i < nr; ++i) {
381  tx = &group->tgfg_txs[i];
382  ftx = (struct m0_be_fmt_tx){};
383  m0_be_group_format_tx_get(gft, i, &ftx);
384  M0_UT_ASSERT(ftx.bft_id == tx->tgft_id);
386  M0_UT_ASSERT(memcmp(ftx.bft_payload.b_addr,
387  tx->tgft_payload.b_addr,
388  tx->tgft_payload_size) == 0);
389  }
391  M0_UT_ASSERT(nr == group->tgfg_reg_nr);
392  for (i = 0; i < nr; ++i) {
393  reg = &group->tgfg_regs[i];
394  regd = (struct m0_be_reg_d){};
395  m0_be_group_format_reg_get(gft, i, &regd);
396  M0_UT_ASSERT(regd.rd_reg.br_size == reg->tgfr_size);
398  M0_UT_ASSERT(memcmp(regd.rd_buf, reg->tgfr_buf,
399  reg->tgfr_size) == 0);
400  }
401 
402  m0_mutex_lock(&ctx->tgfc_lock);
403  // XXX m0_be_group_format_log_discard(gft);
404  m0_mutex_unlock(&ctx->tgfc_lock);
405 
406  if (seg_check) {
407  m0_be_seg_close(&ctx->tgfc_seg);
408  m0_be_seg_fini(&ctx->tgfc_seg);
409  M0_SET0(&ctx->tgfc_seg);
410  m0_be_seg_init(&ctx->tgfc_seg, ctx->tgfc_seg_stob, NULL,
412  rc = m0_be_seg_open(&ctx->tgfc_seg);
413  M0_UT_ASSERT(rc == 0);
415  for (i = 0; i < nr; ++i) {
416  reg = &group->tgfg_regs[i];
417  M0_UT_ASSERT(memcmp(reg->tgfr_seg_addr, reg->tgfr_buf,
418  reg->tgfr_size) == 0);
419  }
420  }
424  bo_sm.sm_rc);
425  M0_UT_ASSERT(rc == 0);
426 }
427 
428 static void be_ut_tgf_ldsc_sync(struct m0_be_log_discard *ld,
429  struct m0_be_op *op,
430  struct m0_be_log_discard_item *ldi)
431 {
433  m0_be_op_done(op);
434 }
435 
437  struct m0_be_log_discard_item *ldi)
438 {
441 }
442 
443 static void be_ut_tgf_test(int group_nr, struct be_ut_tgf_group *groups)
444 {
445  struct m0_be_group_format_cfg gfc_cfg;
446  struct be_ut_tgf_ctx ctx;
447  int rc;
448  int i;
449 
450  ctx = (struct be_ut_tgf_ctx) {
451  .tgfc_group_nr = group_nr,
452  .tgfc_groups = groups,
453  .tgfc_log_discard_cfg = {
454  .ldsc_items_max = group_nr,
455  .ldsc_items_threshold = group_nr,
456  .ldsc_items_pending_max = group_nr,
457  .ldsc_loc = m0_locality0_get(),
458  .ldsc_sync_timeout = M0_TIME_ONE_SECOND,
459  .ldsc_sync = &be_ut_tgf_ldsc_sync,
460  .ldsc_discard = &be_ut_tgf_ldsc_discard,
461  },
462  .tgfc_pd_cfg = {
463  .bpdc_seg_io_nr = group_nr,
464  .bpdc_sched = {
465  .bisc_pos_start = 0,
466  }
467  },
468  };
469 
472 
473  for (i = 0; i < group_nr; ++i)
474  be_ut_tgf_buf_init(&ctx, &groups[i]);
475 
476  gfc_cfg = groups[0].tgfg_cfg;
477  for (i = 1; i < group_nr; ++i) {
478  gfc_cfg.gfc_fmt_cfg.fgc_reg_nr_max =
481  gfc_cfg.gfc_fmt_cfg.fgc_reg_size_max =
484  gfc_cfg.gfc_fmt_cfg.fgc_seg_nr_max =
487  }
488 
490  &ctx.tgfc_pd_cfg.bpdc_io_credit);
491  rc = m0_be_log_discard_init(&ctx.tgfc_log_discard,
492  &ctx.tgfc_log_discard_cfg);
493  M0_UT_ASSERT(rc == 0);
494  rc = m0_be_pd_init(&ctx.tgfc_pd, &ctx.tgfc_pd_cfg);
495  M0_UT_ASSERT(rc == 0);
496 
497  be_ut_tgf_do_discard = false;
498  for (i = 0; i < group_nr; ++i) {
499  be_ut_tgf_group_init(&ctx, &groups[i]);
500  be_ut_tgf_group_write(&ctx, &groups[i], true);
501  m0_mutex_lock(&ctx.tgfc_lock);
502  be_ut_tgf_group_fini(&ctx, &groups[i]);
503  m0_mutex_unlock(&ctx.tgfc_lock);
504  }
506 
507  M0_BE_OP_SYNC(op, m0_be_log_discard_flush(&ctx.tgfc_log_discard, &op));
508  m0_be_pd_fini(&ctx.tgfc_pd);
509  m0_be_log_discard_fini(&ctx.tgfc_log_discard);
510  M0_SET0(&ctx.tgfc_log_discard);
511  rc = m0_be_log_discard_init(&ctx.tgfc_log_discard,
512  &ctx.tgfc_log_discard_cfg);
513  M0_UT_ASSERT(rc == 0);
514  rc = m0_be_pd_init(&ctx.tgfc_pd, &ctx.tgfc_pd_cfg);
515  M0_UT_ASSERT(rc == 0);
516 
518  for (i = 0; i < group_nr; ++i) {
519  be_ut_tgf_group_init(&ctx, &groups[i]);
520  }
521  be_ut_tgf_do_discard = true;
522  for (i = 0; i < group_nr; ++i) {
523  be_ut_tgf_group_read_check(&ctx, &groups[i], true);
524  be_ut_tgf_group_fini(&ctx, &groups[i]);
525  }
526 
527  for (i = 0; i < group_nr; ++i)
528  be_ut_tgf_buf_fini(&ctx, &groups[i]);
529  M0_BE_OP_SYNC(op, m0_be_log_discard_flush(&ctx.tgfc_log_discard, &op));
530  m0_be_pd_fini(&ctx.tgfc_pd);
531  m0_be_log_discard_fini(&ctx.tgfc_log_discard);
534 }
535 
536 static struct be_ut_tgf_tx be_ut_tgf_txs0[] = {
537  { .tgft_payload_size = 1024, .tgft_id = 1, },
538 };
539 static struct be_ut_tgf_reg be_ut_tgf_regs0[] = {
540  { .tgfr_size = 1024, },
541  { .tgfr_size = 1024, },
542  { .tgfr_size = 1024, },
543 };
544 static struct be_ut_tgf_tx be_ut_tgf_txs1[] = {
545  { .tgft_payload_size = 1024, .tgft_id = 1, },
546  { .tgft_payload_size = 513, .tgft_id = 2, },
547  { .tgft_payload_size = 100, .tgft_id = 3, },
548 };
549 static struct be_ut_tgf_reg be_ut_tgf_regs1[] = {
550  { .tgfr_size = 1024, },
551  { .tgfr_size = 1023, },
552 };
553 static struct be_ut_tgf_tx be_ut_tgf_txs2[] = {
554  { .tgft_payload_size = 1000, .tgft_id = 1ULL << 63, },
555  { .tgft_payload_size = 500, .tgft_id = 1ULL << 62, },
556 };
557 static struct be_ut_tgf_reg be_ut_tgf_regs2[] = {
558  { .tgfr_size = 512, },
559  { .tgfr_size = 100, },
560  { .tgfr_size = 1000, },
561 };
562 
564  {
566  .tgfg_txs = be_ut_tgf_txs0,
567  .tgfg_reg_nr = ARRAY_SIZE(be_ut_tgf_regs0),
568  .tgfg_regs = be_ut_tgf_regs0,
569  },
570  {
571  .tgfg_tx_nr = ARRAY_SIZE(be_ut_tgf_txs1),
572  .tgfg_txs = be_ut_tgf_txs1,
573  .tgfg_reg_nr = ARRAY_SIZE(be_ut_tgf_regs1),
574  .tgfg_regs = be_ut_tgf_regs1,
575  },
576  {
577  .tgfg_tx_nr = ARRAY_SIZE(be_ut_tgf_txs2),
578  .tgfg_txs = be_ut_tgf_txs2,
579  .tgfg_reg_nr = ARRAY_SIZE(be_ut_tgf_regs2),
580  .tgfg_regs = be_ut_tgf_regs2,
581  },
582 };
583 
585 {
587 }
588 
589 /*
590  * Local variables:
591  * c-indentation-style: "K&R"
592  * c-basic-offset: 8
593  * tab-width: 8
594  * fill-column: 80
595  * scroll-step: 1
596  * End:
597  */
598 /*
599  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
600  */
static void be_ut_tgf_group_write(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group, bool seg_write)
struct m0_be_log_record gft_log_record
static struct m0_mutex lock
Definition: transmit.c:326
void * bs_addr
Definition: seg.h:71
static const char * be_ut_tgf_log_sdom_create_cfg
uint64_t fgc_payload_size_max
Definition: fmt.h:240
static size_t nr
Definition: dump.c:1505
static struct be_ut_tgf_tx be_ut_tgf_txs2[]
static void be_ut_tgf_group_init(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group)
M0_INTERNAL void m0_be_group_format_prepare(struct m0_be_group_format *gft, struct m0_be_op *op)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
void m0_be_ut_group_format(void)
M0_INTERNAL void m0_be_group_format_log_read(struct m0_be_group_format *gft, struct m0_be_op *op)
M0_INTERNAL int m0_be_pd_init(struct m0_be_pd *pd, struct m0_be_pd_cfg *pd_cfg)
Definition: pd.c:86
static const char * be_ut_tgf_log_sdom_location
struct m0_be_log_discard_cfg tgfc_log_discard_cfg
M0_INTERNAL void m0_be_group_format_seg_io_credit(struct m0_be_group_format_cfg *gft_cfg, struct m0_be_io_credit *io_cred)
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_be_group_format_reg_get(const struct m0_be_group_format *gft, uint32_t index, struct m0_be_reg_d *rd)
M0_INTERNAL void m0_be_seg_fini(struct m0_be_seg *seg)
Definition: stubs.c:128
M0_INTERNAL void m0_be_group_format_recovery_prepare(struct m0_be_group_format *gft, struct m0_be_log *log)
char * lsc_stob_domain_location
Definition: log_store.h:144
struct m0_mutex tgfc_lock
M0_INTERNAL bool m0_be_log_recovery_record_available(struct m0_be_log *log)
Definition: log.c:1214
M0_INTERNAL void m0_be_group_format_reset(struct m0_be_group_format *gft)
static void be_ut_tgf_log_got_space_cb(struct m0_be_log *log)
void * b_addr
Definition: buf.h:39
struct m0_be_log tgfc_log
M0_INTERNAL const struct m0_fid * m0_stob_domain_id_get(const struct m0_stob_domain *dom)
Definition: domain.c:300
M0_INTERNAL void m0_be_log_discard_flush(struct m0_be_log_discard *ld, struct m0_be_op *op)
Definition: log_discard.c:374
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
Definition: domain.c:227
static void be_ut_tgf_log_fini(struct be_ut_tgf_ctx *ctx)
M0_INTERNAL void m0_be_seg_init(struct m0_be_seg *seg, struct m0_stob *stob, struct m0_be_domain *dom, uint64_t seg_id)
Definition: stubs.c:118
M0_INTERNAL int m0_be_seg_create(struct m0_be_seg *seg, m0_bcount_t size, void *addr)
Definition: seg.c:224
static void be_ut_tgf_ldsc_sync(struct m0_be_log_discard *ld, struct m0_be_op *op, struct m0_be_log_discard_item *ldi)
m0_bcount_t bs_size
Definition: seg.h:69
#define max_check(a, b)
Definition: arith.h:95
#define M0_BE_OP_SYNC(op_obj, action)
Definition: op.h:190
M0_INTERNAL int m0_be_log_open(struct m0_be_log *log, struct m0_be_log_cfg *log_cfg)
Definition: log.c:281
M0_INTERNAL void m0_be_group_format_encode(struct m0_be_group_format *gft)
struct m0_be_pd_cfg tgfc_pd_cfg
m0_bcount_t br_size
Definition: seg.h:144
M0_INTERNAL int m0_be_group_format_allocate(struct m0_be_group_format *gft)
uint64_t m0_bcount_t
Definition: types.h:77
static void be_ut_tgf_ldsc_discard(struct m0_be_log_discard *ld, struct m0_be_log_discard_item *ldi)
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
static bool be_ut_tgf_do_discard
#define M0_BE_REG(seg, size, addr)
Definition: seg.h:148
Definition: sock.c:887
M0_INTERNAL void m0_be_group_format_discard(struct m0_be_log_discard *ld, struct m0_be_log_discard_item *ldi)
M0_INTERNAL int m0_be_log_discard_init(struct m0_be_log_discard *ld, struct m0_be_log_discard_cfg *ld_cfg)
Definition: log_discard.c:85
#define M0_BE_REG_D(reg, buf)
Definition: tx_regmap.h:67
m0_bcount_t bs_reserved
Definition: seg.h:74
M0_INTERNAL void m0_be_seg_close(struct m0_be_seg *seg)
Definition: stubs.c:140
struct m0_be_reg rd_reg
Definition: tx_regmap.h:53
op
Definition: libdemo.c:64
struct m0_buf tgft_payload
M0_INTERNAL void m0_be_group_format_reg_seg_add(struct m0_be_group_format *gft, const struct m0_be_reg_d *rd)
#define M0_BE_TX_CREDIT(nr, size)
Definition: tx_credit.h:94
static struct be_ut_tgf_group be_ut_tgf_groups[]
#define M0_BE_FMT_TX(payload, id)
Definition: fmt.h:368
Definition: buf.h:37
struct m0_be_seg tgfc_seg
static char * addr
Definition: node_k.c:37
static void be_ut_tgf_rnd_fill(void *buf, size_t size)
int i
Definition: dir.c:1033
struct m0_be_log_store_cfg lc_store_cfg
Definition: log.h:250
M0_INTERNAL struct m0_stob * m0_ut_stob_linux_get(void)
Definition: stob.c:169
M0_INTERNAL int m0_stob_domain_create(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
Definition: domain.c:217
M0_INTERNAL uint32_t m0_be_group_format_reg_nr(const struct m0_be_group_format *gft)
static struct be_ut_tgf_reg be_ut_tgf_regs0[]
uint64_t fgc_reg_size_max
Definition: fmt.h:241
M0_INTERNAL void m0_be_log_close(struct m0_be_log *log)
Definition: log.c:287
#define M0_BE_OP_SYNC_RET(op_obj, action, member)
Definition: op.h:243
static void be_ut_tgf_log_close(struct be_ut_tgf_ctx *ctx)
struct m0_be_fmt_group_cfg gfc_fmt_cfg
m0_bcount_t tgfr_size
Definition: stob.h:163
uint64_t gi_unknown
Definition: fmt.h:129
m0_bcount_t b_nob
Definition: buf.h:38
M0_INTERNAL void m0_be_group_format_seg_place(struct m0_be_group_format *gft, struct m0_be_op *op)
M0_INTERNAL void m0_be_group_format_log_write(struct m0_be_group_format *gft, struct m0_be_op *op)
M0_INTERNAL void m0_be_group_format_tx_add(struct m0_be_group_format *gft, struct m0_be_fmt_tx *ftx)
uint64_t tgft_id
struct m0_stob * tgfc_seg_stob
M0_INTERNAL void m0_stob_id_make(uint64_t container, uint64_t key, const struct m0_fid *dom_id, struct m0_stob_id *stob_id)
Definition: stob.c:343
M0_INTERNAL void m0_be_group_format_log_use(struct m0_be_group_format *gft, m0_bcount_t size_reserved)
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
Definition: buf.c:43
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_be_group_format_reg_log_add(struct m0_be_group_format *gft, const struct m0_be_reg_d *rd)
M0_INTERNAL int m0_be_log_create(struct m0_be_log *log, struct m0_be_log_cfg *log_cfg)
Definition: log.c:292
static void be_ut_tgf_seg_fini(struct be_ut_tgf_ctx *ctx)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
struct be_ut_tgf_group * tgfc_groups
void * tgfc_seg_addr
static struct be_ut_tgf_tx be_ut_tgf_txs0[]
Definition: xcode.h:73
static void be_ut_tgf_log_init(struct be_ut_tgf_ctx *ctx)
static void be_ut_tgf_log_cfg_set(struct m0_be_log_cfg *log_cfg, struct m0_stob_domain *sdom, struct m0_mutex *lock)
M0_INTERNAL void m0_be_op_done(struct m0_be_op *op)
Definition: stubs.c:104
static void group(void)
Definition: sm.c:386
static void be_ut_tgf_test(int group_nr, struct be_ut_tgf_group *groups)
M0_INTERNAL void m0_buf_free(struct m0_buf *buf)
Definition: buf.c:55
M0_INTERNAL int m0_be_group_format_init(struct m0_be_group_format *gft, struct m0_be_group_format_cfg *gft_cfg, struct m0_be_tx_group *group, struct m0_be_log *log)
struct m0_buf bft_payload
Definition: fmt.h:364
Definition: seg.h:66
static struct be_ut_tgf_reg be_ut_tgf_regs2[]
M0_INTERNAL void m0_ut_stob_put(struct m0_stob *stob, bool destroy)
Definition: stob.c:185
uint64_t fgc_seg_nr_max
Definition: fmt.h:242
M0_INTERNAL void m0_be_log_discard_fini(struct m0_be_log_discard *ld)
Definition: log_discard.c:135
static void be_ut_tgf_buf_init(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group)
M0_INTERNAL int m0_be_log_reserve(struct m0_be_log *log, m0_bcount_t size)
Definition: log.c:850
struct m0_be_group_format tgfg_gft
static struct be_ut_tgf_tx be_ut_tgf_txs1[]
M0_INTERNAL void m0_be_group_format_deallocate(struct m0_be_group_format *gft)
static struct be_ut_tgf_reg be_ut_tgf_regs1[]
M0_INTERNAL void m0_be_group_format_seg_place_prepare(struct m0_be_group_format *gft)
uint64_t fgc_reg_nr_max
Definition: fmt.h:239
M0_INTERNAL void m0_be_group_format_fini(struct m0_be_group_format *gft)
struct be_ut_tgf_tx * tgfg_txs
struct m0_be_log_discard tgfc_log_discard
M0_INTERNAL void m0_be_op_active(struct m0_be_op *op)
Definition: stubs.c:100
M0_INTERNAL uint64_t m0_rnd64(uint64_t *seed)
Definition: misc.c:100
M0_INTERNAL void m0_be_pd_fini(struct m0_be_pd *pd)
Definition: pd.c:127
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
M0_INTERNAL uint32_t m0_be_group_format_tx_nr(const struct m0_be_group_format *gft)
static void be_ut_tgf_group_read_check(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group, bool seg_check)
static void be_ut_tgf_group_fini(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group)
M0_INTERNAL void m0_be_log_destroy(struct m0_be_log *log)
Definition: log.c:298
static const char * be_ut_tgf_log_sdom_init_cfg
Definition: pd.h:64
m0_bcount_t tgft_payload_size
void * rd_buf
Definition: tx_regmap.h:58
M0_INTERNAL int m0_be_seg_destroy(struct m0_be_seg *seg)
Definition: seg.c:243
m0_bcount_t size
Definition: di.c:39
static void be_ut_tgf_buf_fini(struct be_ut_tgf_ctx *ctx, struct be_ut_tgf_group *group)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL m0_bcount_t m0_be_group_format_log_reserved_size(struct m0_be_log *log, struct m0_be_tx_credit *cred, m0_bcount_t cred_payload)
M0_INTERNAL int m0_be_seg_open(struct m0_be_seg *seg)
Definition: stubs.c:132
void * tgfr_seg_addr
static struct m0_be_seg * seg
Definition: btree.c:40
M0_INTERNAL int m0_be_group_format_decode(struct m0_be_group_format *gft)
struct be_ut_tgf_reg * tgfg_regs
Definition: nucleus.c:42
Definition: log.h:261
Definition: op.h:74
M0_INTERNAL void m0_be_log_record_skip_discard(struct m0_be_log_record *record)
Definition: log.c:505
static void be_ut_tgf_seg_init(struct be_ut_tgf_ctx *ctx)
void m0_free(void *data)
Definition: memory.c:146
Definition: mutex.h:47
M0_INTERNAL struct m0_be_fmt_group_info * m0_be_group_format_group_info(struct m0_be_group_format *gft)
void * br_addr
Definition: seg.h:145
struct m0_be_pd tgfc_pd
uint64_t bft_id
Definition: fmt.h:365
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
#define M0_UT_ASSERT(a)
Definition: ut.h:46
M0_INTERNAL void m0_be_group_format_tx_get(const struct m0_be_group_format *gft, uint32_t index, struct m0_be_fmt_tx *ftx)
struct m0_be_group_format_cfg tgfg_cfg
struct m0_stob_id lsc_stob_id
Definition: log_store.h:135
struct m0_stob_domain * tgfc_sdom
static struct m0_stob_domain * sdom
Definition: reqh_fom_ut.c:73
static void be_ut_tgf_log_open(struct be_ut_tgf_ctx *ctx)