Motr  M0
ad.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include "lib/arith.h" /* min64u */
23 #include "lib/misc.h" /* M0_SET0 */
24 #include "lib/memory.h"
25 #include "lib/ub.h"
26 #include "lib/assert.h"
27 #include "ut/stob.h" /* m0_ut_stob_create */
28 #include "ut/ut.h"
29 
30 #include "dtm/dtm.h" /* m0_dtx */
31 #include "stob/ad.h" /* m0_stob_ad_cfg_make */
32 #include "stob/ad_private.h" /* stob_ad_domain2ad */
33 #include "stob/domain.h"
34 #include "stob/io.h"
35 #include "stob/stob.h"
36 #include "balloc/balloc.h"
37 
38 #include "be/ut/helper.h"
39 #include "lib/errno.h"
40 
46 #define AD_CS_SZ 16
47 
48 enum {
49  NR = 4,
50  MIN_BUF_SIZE = 4096,
52  SEG_SIZE = 1 << 24,
53 };
54 
55 static struct m0_stob_domain *dom_back;
56 static struct m0_stob_domain *dom_fore;
57 static struct m0_stob *obj_back;
58 static struct m0_stob *obj_fore;
59 static struct m0_stob_io io;
62 static char *user_buf[NR];
63 static char *user_cksm_buf[NR];
64 static char *read_buf[NR];
65 static char *read_cksm_buf[NR];
66 static char *zero_buf[NR];
67 static char *user_bufs[NR];
68 static char *read_bufs[NR];
70 static struct m0_clink clink;
71 static struct m0_dtx g_tx;
74 static uint32_t block_shift;
75 static uint32_t buf_size;
76 
77 struct mock_balloc {
80 };
81 
83  struct m0_be_ut_seg *ut_seg,
84  bool use_small_credits)
85 {
86  struct m0_be_domain_cfg cfg = {};
87  int rc;
88 
89  M0_SET0(ut_be);
90  M0_SET0(ut_seg);
91 
93  if (use_small_credits) {
94  /* Reduce maximum credit size of transaction
95  * to exercise transaction breaking code in
96  * stob_ad_punch_credit()
97  */
99  M0_BE_TX_CREDIT(1 << 18, 1 << 21);
100  }
101  rc = m0_be_ut_backend_init_cfg(ut_be, &cfg, true);
102  M0_UT_ASSERT(rc == 0);
104 }
105 
107  struct m0_be_ut_seg *ut_seg)
108 {
111 }
112 
113 static struct mock_balloc *b2mock(struct m0_ad_balloc *ballroom)
114 {
115  return container_of(ballroom, struct mock_balloc, mb_ballroom);
116 }
117 
118 static int mock_balloc_init(struct m0_ad_balloc *ballroom,
119  struct m0_be_seg *seg,
120  uint32_t bshift,
121  m0_bindex_t container_size,
122  m0_bcount_t groupsize,
123  m0_bcount_t spare_reserve)
124 {
125  return 0;
126 }
127 
128 static void mock_balloc_fini(struct m0_ad_balloc *ballroom)
129 {
130 }
131 
132 static int mock_balloc_alloc(struct m0_ad_balloc *ballroom, struct m0_dtx *dtx,
133  m0_bcount_t count, struct m0_ext *out,
134  uint64_t alloc_type)
135 {
136  struct mock_balloc *mb = b2mock(ballroom);
137  m0_bcount_t giveout;
138 
139  giveout = min64u(count, 500000);
140  out->e_start = mb->mb_next;
141  out->e_end = mb->mb_next + giveout;
142  m0_ext_init(out);
143  mb->mb_next += giveout + 1;
144  /* printf("allocated %8lx/%8lx bytes: [%8lx .. %8lx)\n",
145  giveout, count,
146  out->e_start, out->e_end); */
147  return 0;
148 }
149 
150 static int mock_balloc_free(struct m0_ad_balloc *ballroom, struct m0_dtx *dtx,
151  struct m0_ext *ext)
152 {
153  /* printf("freed %8lx bytes: [%8lx .. %8lx)\n", m0_ext_length(ext),
154  ext->e_start, ext->e_end); */
155  return 0;
156 }
157 
158 static int malloc_reserve_extent(struct m0_ad_balloc *ballroom,
159  struct m0_be_tx *tx, struct m0_ext *ext,
160  uint64_t alloc_zone)
161 {
162  return 0;
163 }
164 
165 static const struct m0_ad_balloc_ops mock_balloc_ops = {
167  .bo_fini = mock_balloc_fini,
168  .bo_alloc = mock_balloc_alloc,
169  .bo_free = mock_balloc_free,
170  .bo_reserve_extent = malloc_reserve_extent,
171 };
172 
173 struct mock_balloc mb = {
174  .mb_next = 0,
175  .mb_ballroom = {
176  .ab_ops = &mock_balloc_ops
177  }
178 };
179 
180 static void init_vecs()
181 {
182  int i;
183  char cs_char = 'A';
184 
185  for (i = 0; i < NR; ++i) {
190  stob_vi[i] = (buf_size * (2 * i + 1)) >> block_shift;
191  memset(user_buf[i], ('a' + i)|1, buf_size);
192  }
193 
194  // Allocate contigious buffer for i/p checksums
195  memset( user_cksm_buf[0], cs_char++, AD_CS_SZ);
196  for (i = 1; i < ARRAY_SIZE(user_cksm_buf); ++i) {
198  memset( user_cksm_buf[i], cs_char++, AD_CS_SZ);
199  }
200 
201  memset( read_cksm_buf[0], 0, AD_CS_SZ);
202  for (i = 1; i < ARRAY_SIZE(read_cksm_buf); ++i) {
204  memset( read_cksm_buf[i], 0, AD_CS_SZ);
205  }
206 }
207 
208 static int test_ad_init(bool use_small_credits)
209 {
210  char *dom_cfg;
211  char *dom_init_cfg;
212  int i;
213  int rc;
214  struct m0_stob_id stob_id;
215 
216  rc = m0_stob_domain_create("linuxstob:./__s", "directio=true",
217  0xc0de, NULL, &dom_back);
218  M0_ASSERT(rc == 0);
219 
220  m0_stob_id_make(0, 0xba5e, &dom_back->sd_id, &stob_id);
221  rc = m0_stob_find(&stob_id, &obj_back);
222  M0_ASSERT(rc == 0);
224  M0_ASSERT(rc == 0);
226  M0_ASSERT(rc == 0);
227 
228  m0_stob_ut_ad_init(&ut_be, &ut_seg, use_small_credits);
229 
232  M0_UT_ASSERT(dom_cfg != NULL);
233  m0_stob_ad_init_cfg_make(&dom_init_cfg, &ut_be.but_dom);
234  M0_UT_ASSERT(dom_init_cfg != NULL);
235 
236  rc = m0_stob_domain_create("adstob:ad", dom_init_cfg, 0xad,
237  dom_cfg, &dom_fore);
238  M0_ASSERT(rc == 0);
239  m0_free(dom_cfg);
240  m0_free(dom_init_cfg);
241 
242  m0_stob_id_make(0, 0xd15c, &dom_fore->sd_id, &stob_id);
243  rc = m0_stob_find(&stob_id, &obj_fore);
244  M0_ASSERT(rc == 0);
246  M0_ASSERT(rc == 0);
248  M0_ASSERT(rc == 0);
249 
251  /* buf_size is chosen so it would be at least MIN_BUF_SIZE in bytes
252  * or it would consist of at least MIN_BUF_SIZE_IN_BLOCKS blocks */
255 
256  for (i = 0; i < ARRAY_SIZE(user_buf); ++i) {
258  M0_ASSERT(user_buf[i] != NULL);
259  }
260 
263 
264  for (i = 0; i < ARRAY_SIZE(read_buf); ++i) {
266  M0_ASSERT(read_buf[i] != NULL);
267  }
268 
269  // Allocate contigious buffer for o/p checksums
272 
273  for (i = 0; i < ARRAY_SIZE(zero_buf); ++i) {
275  M0_ASSERT(zero_buf[i] != NULL);
276  }
277 
278  init_vecs();
279 
280  return rc;
281 }
282 
283 static int test_ad_fini(void)
284 {
285  int i;
286 
291 
293 
294  for (i = 0; i < ARRAY_SIZE(user_buf); ++i)
295  m0_free(user_buf[i]);
296 
298 
299  for (i = 0; i < ARRAY_SIZE(read_buf); ++i)
300  m0_free(read_buf[i]);
301 
303 
304  for (i = 0; i < ARRAY_SIZE(zero_buf); ++i)
305  m0_free(zero_buf[i]);
306 
307  return 0;
308 }
309 
310 static void test_write(int nr, struct m0_dtx *tx)
311 {
313  struct m0_fol_frag *fol_frag;
314  bool is_local_tx = false;
315  int rc;
316 
317  /* @Note: This Fol record part object is not freed and shows as leak,
318  * as it is passed as embedded object in other places.
319  */
320  M0_ALLOC_PTR(fol_frag);
321  M0_UB_ASSERT(fol_frag != NULL);
322 
324 
326  io.si_flags = 0;
327  io.si_fol_frag = fol_frag;
328  io.si_user.ov_vec.v_nr = nr;
330  io.si_user.ov_buf = (void **)user_bufs;
331 
332  io.si_stob.iv_vec.v_nr = nr;
335 
338  // Checksum for i buf_size blocks
340  io.si_cksum.b_nob = ( nr * AD_CS_SZ );
341 
343  M0_UT_ASSERT(rc == 0);
345 
348 
349  if (tx == NULL) {
350  tx = &g_tx;
351  M0_SET0(tx);
352  m0_dtx_init(tx, &ut_be.but_dom, grp);
353  is_local_tx = true;
354  }
356  rc = m0_dtx_open_sync(tx);
357  M0_ASSERT(rc == 0);
358 
360  M0_ASSERT(rc == 0);
361 
362  if (is_local_tx) {
363  rc = m0_dtx_done_sync(tx);
364  M0_ASSERT(rc == 0);
365  m0_dtx_fini(tx);
366  }
367 
369 
370  M0_ASSERT(io.si_rc == 0);
372 
375 
377 }
378 
379 static void test_read(int nr)
380 {
381  int rc;
382 
384 
386  io.si_flags = 0;
387  io.si_user.ov_vec.v_nr = nr;
389  io.si_user.ov_buf = (void **)read_bufs;
390 
391  io.si_stob.iv_vec.v_nr = nr;
394 
397  // Checksum for i buf_size blocks
399  io.si_cksum.b_nob = ( nr * AD_CS_SZ );
400 
403 
405  M0_ASSERT(rc == 0);
406 
408 
409  M0_ASSERT(io.si_rc == 0);
411 
414 
416 }
417 
418 static void test_punch(int nr)
419 {
421  struct m0_dtx *tx;
422  struct m0_indexvec range;
423  struct m0_indexvec want;
424  struct m0_indexvec got;
425  int rc;
426  int i;
427  bool credit_is_enough = false;
428  uint32_t idx = 0;
429 
430  rc = m0_indexvec_alloc(&range, nr);
431  M0_ASSERT(rc == 0);
432  rc = m0_indexvec_alloc(&want, 1);
433  M0_ASSERT(rc == 0);
434  rc = m0_indexvec_alloc(&got, 1);
435  M0_ASSERT(rc == 0);
436 
437  for (i = 0; i < nr; ++i) {
438  range.iv_vec.v_count[i] = stob_vc[i];
439  range.iv_index[i] = stob_vi[i];
440  }
441 
442 start_again:
443  tx = &g_tx;
444  M0_SET0(tx);
445  m0_dtx_init(tx, &ut_be.but_dom, grp);
446 
447  want.iv_vec.v_count[0] = range.iv_vec.v_count[idx];
448  want.iv_index[0] = range.iv_index[idx];
449  rc = m0_stob_punch_credit(obj_fore, &want, &got,
450  &tx->tx_betx_cred);
451  M0_ASSERT(rc == 0);
452  range.iv_index[idx] += got.iv_vec.v_count[0];
453  range.iv_vec.v_count[idx] -= got.iv_vec.v_count[0];
454  if (range.iv_vec.v_count[idx] == 0) {
455  idx++;
456  if (idx == nr)
457  credit_is_enough = true;
458  }
459  rc = m0_dtx_open_sync(tx);
460  M0_ASSERT(rc == 0);
461  rc = obj_fore->so_ops->sop_punch(obj_fore, &got, &g_tx);
462  M0_ASSERT(rc == 0);
463  rc = m0_dtx_done_sync(tx);
464  M0_ASSERT(rc == 0);
465  m0_dtx_fini(tx);
466 
467  if (!credit_is_enough)
468  goto start_again;
469 
470  m0_indexvec_free(&got);
471  m0_indexvec_free(&want);
472  m0_indexvec_free(&range);
473 
474  for (i = 0; i < nr; i++) {
475  struct m0_stob_ad_domain *adom;
476  struct m0_be_emap_cursor it = {};
477  struct m0_ext *ext;
479  rc = stob_ad_cursor(adom, obj_fore, stob_vi[i], &it);
480  M0_ASSERT(rc == 0);
481  ext = &it.ec_seg.ee_ext;
482  M0_ASSERT(ext->e_start <= stob_vi[i]);
483  M0_ASSERT(ext->e_end >= stob_vi[i] + stob_vc[i]);
488  }
489 }
490 
491 static void test_ad_rw_unordered()
492 {
493  int i;
494 
495  /* Unorderd write requests */
496  init_vecs();
497  for (i = NR/2; i < NR; ++i) {
498  stob_vi[i-(NR/2)] = (buf_size * (i + 1)) >> block_shift;
499  memset(user_buf[i-(NR/2)], ('a' + i)|1, buf_size);
500  memset(user_cksm_buf[i-(NR/2)], ('A' + i)|1, AD_CS_SZ);
501  }
502  test_write(NR/2, NULL);
503 
504  init_vecs();
505  for (i = 0; i < NR/2; ++i) {
506  stob_vi[i] = (buf_size * (i + 1)) >> block_shift;
507  memset(user_buf[i], ('a' + i)|1, buf_size);
508  memset(user_cksm_buf[i], ('A' + i)|1, AD_CS_SZ);
509  }
510  test_write(NR/2, NULL);
511 
512  init_vecs();
513  for (i = 0; i < NR; ++i) {
514  stob_vi[i] = (buf_size * (i + 1)) >> block_shift;
515  memset(user_buf[i], ('a' + i)|1, buf_size);
516  memset(user_cksm_buf[i], ('A' + i)|1, AD_CS_SZ);
517  }
518 
519  /* This generates unordered offsets for back stob io */
520  test_read(NR);
521  for (i = 0; i < NR; ++i)
522  {
523  M0_ASSERT(memcmp(user_buf[i], read_buf[i], buf_size) == 0);
524  M0_ASSERT(memcmp(user_cksm_buf[i], read_cksm_buf[i], AD_CS_SZ) == 0);
525  }
526 }
527 
531 static void test_ad(void)
532 {
533  int i;
534 
535  for (i = 1; i <= NR; ++i)
536  test_write(i, NULL);
537 
538  for (i = 1; i <= NR; ++i) {
539  int j;
540  test_read(i);
541  for (j = 0; j < i; ++j) {
542  M0_ASSERT(memcmp(user_buf[j], read_buf[j], buf_size) == 0);
543  M0_ASSERT(memcmp(user_cksm_buf[j], read_cksm_buf[j], AD_CS_SZ) == 0);
544  }
545  }
546 }
547 
551 static void punch_test(void)
552 {
553  int i;
554 
555  memset(read_cksm_buf[0], 'Z', ARRAY_SIZE(read_cksm_buf) * AD_CS_SZ);
556  for (i = 1; i <= NR; ++i) {
557  int j;
558  test_punch(i);
559  test_read(i);
560  for (j = 0; j < i; ++j) {
561  M0_ASSERT(memcmp(zero_buf[j], read_buf[j], buf_size) == 0);
562  }
563  }
564 }
565 
566 static void test_ad_undo(void)
567 {
569  struct m0_fol_frag *rfrag;
570  struct m0_dtx tx = {};
571  int rc;
572 
573  M0_SET0(&g_tx);
575  memset(user_buf[0], 'a', buf_size);
576  test_write(1, &g_tx);
578  M0_ASSERT(rc == 0);
579 
580  test_read(1);
581  M0_ASSERT(memcmp(user_buf[0], read_buf[0], buf_size) == 0);
582 
583  rfrag = m0_rec_frag_tlist_head(&g_tx.tx_fol_rec.fr_frags);
584  M0_ASSERT(rfrag != NULL);
585 
586  /* Write new data in stob */
587  m0_dtx_init(&tx, &ut_be.but_dom, grp);
588  rfrag->rp_ops->rpo_undo_credit(rfrag, &tx.tx_betx_cred);
589  memset(user_buf[0], 'b', buf_size);
590  test_write(1, &tx);
591 
592  /* Do the undo operation. */
593  rc = rfrag->rp_ops->rpo_undo(rfrag, &tx.tx_betx);
594  M0_UT_ASSERT(rc == 0);
595 
596  rc = m0_dtx_done_sync(&tx);
597  M0_ASSERT(rc == 0);
598  m0_dtx_fini(&tx);
599 
600  m0_dtx_fini(&g_tx);
601 
602  test_read(1);
603  M0_ASSERT(memcmp(user_buf[0], read_buf[0], buf_size) != 0);
604 
605 }
606 
608 {
609  int rc;
610 
611  rc = test_ad_init(false);
612  M0_ASSERT(rc == 0);
613  test_ad();
615  test_ad_undo();
616  rc = test_ad_fini();
617  M0_ASSERT(rc == 0);
618 
619  rc = test_ad_init(true);
620  M0_ASSERT(rc == 0);
621  punch_test();
622  rc = test_ad_fini();
623  M0_ASSERT(rc == 0);
624 }
625 
626 static void ub_write(int i)
627 {
628  test_write(NR - 1, NULL);
629 }
630 
631 static void ub_read(int i)
632 {
633  test_read(NR - 1);
634 }
635 
636 static int ub_init(const char *opts M0_UNUSED)
637 {
638  return test_ad_init(false);
639 }
640 
641 static void ub_fini(void)
642 {
643  (void)test_ad_fini();
644 }
645 
646 enum { UB_ITER = 100 };
647 
648 struct m0_ub_set m0_ad_ub = {
649  .us_name = "ad-ub",
650  .us_init = ub_init,
651  .us_fini = ub_fini,
652  .us_run = {
653  { .ub_name = "write-prime",
654  .ub_iter = 1,
655  .ub_round = ub_write },
656 
657  { .ub_name = "write",
658  .ub_iter = UB_ITER,
659  .ub_round = ub_write },
660 
661  { .ub_name = "read",
662  .ub_iter = UB_ITER,
663  .ub_round = ub_read },
664 
665  { .ub_name = NULL }
666  }
667 };
668 
671 /*
672  * Local variables:
673  * c-indentation-style: "K&R"
674  * c-basic-offset: 8
675  * tab-width: 8
676  * fill-column: 80
677  * scroll-step: 1
678  * End:
679  */
#define AD_CS_SZ
Definition: ad.c:46
M0_INTERNAL struct m0_stob_domain * m0_stob_dom_get(struct m0_stob *stob)
Definition: stob.c:338
void m0_be_ut_seg_fini(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:267
static size_t nr
Definition: dump.c:1505
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
Definition: chan.c:336
static char * zero_buf[NR]
Definition: ad.c:66
Definition: dtm.h:554
enum m0_stob_io_flags si_flags
Definition: io.h:290
void m0_stob_ut_adieu_ad(void)
Definition: ad.c:607
int(* sop_punch)(struct m0_stob *stob, struct m0_indexvec *range, struct m0_dtx *dtx)
Definition: stob.h:199
static void test_ad_rw_unordered()
Definition: ad.c:491
M0_INTERNAL int m0_be_ut_backend_init_cfg(struct m0_be_ut_backend *ut_be, const struct m0_be_domain_cfg *cfg, bool mkfs)
Definition: stubs.c:231
static struct m0_dtx g_tx
Definition: ad.c:71
M0_INTERNAL void m0_stob_io_fini(struct m0_stob_io *io)
Definition: io.c:122
m0_bindex_t si_unit_sz
Definition: io.h:414
M0_INTERNAL int m0_indexvec_alloc(struct m0_indexvec *ivec, uint32_t len)
Definition: vec.c:532
m0_bindex_t e_end
Definition: ext.h:40
int(* rpo_undo)(struct m0_fol_frag *frag, struct m0_be_tx *tx)
Definition: fol.h:284
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
static void punch_test(void)
Definition: ad.c:551
Definition: io.h:230
M0_INTERNAL int m0_stob_locate(struct m0_stob *stob)
Definition: stob.c:128
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
Definition: chan.c:293
static int mock_balloc_init(struct m0_ad_balloc *ballroom, struct m0_be_seg *seg, uint32_t bshift, m0_bindex_t container_size, m0_bcount_t groupsize, m0_bcount_t spare_reserve)
Definition: ad.c:118
struct m0_ub_set m0_ad_ub
Definition: ad.c:648
const struct m0_stob_ops * so_ops
Definition: stob.h:164
M0_INTERNAL void m0_stob_io_credit(const struct m0_stob_io *io, const struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
Definition: io.c:130
#define M0_UB_ASSERT(cond)
Definition: ub.h:37
const struct m0_fol_frag_ops * rp_ops
Definition: fol.h:244
void * b_addr
Definition: buf.h:39
void m0_stob_ut_ad_init(struct m0_be_ut_backend *ut_be, struct m0_be_ut_seg *ut_seg, bool use_small_credits)
Definition: ad.c:82
static struct m0_sm_group * grp
Definition: bytecount.c:38
struct m0_ad_balloc mb_ballroom
Definition: ad.c:79
static void ub_fini(void)
Definition: ad.c:641
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
Definition: domain.c:227
uint64_t ee_val
Definition: extmap.h:193
struct m0_be_seg * bus_seg
Definition: helper.h:119
static char * user_buf[NR]
Definition: ad.c:62
Definition: ad.c:49
M0_INTERNAL void m0_dtx_init(struct m0_dtx *tx, struct m0_be_domain *be_domain, struct m0_sm_group *sm_group)
Definition: dtm.c:67
Definition: ad.h:190
struct m0_vec ov_vec
Definition: vec.h:147
#define max_check(a, b)
Definition: arith.h:95
static char * read_cksm_buf[NR]
Definition: ad.c:65
int(* bo_init)(struct m0_ad_balloc *ballroom, struct m0_be_seg *db, uint32_t bshift, m0_bcount_t container_size, m0_bcount_t blocks_per_group, m0_bcount_t spare_blocks_per_group)
Definition: ad.h:77
struct m0_tl fr_frags
Definition: fol.h:201
M0_INTERNAL void m0_be_emap_close(struct m0_be_emap_cursor *it)
Definition: extmap.c:360
static struct m0_be_emap_cursor it
Definition: extmap.c:46
M0_INTERNAL void m0_indexvec_free(struct m0_indexvec *ivec)
Definition: vec.c:553
M0_INTERNAL void m0_stob_ad_balloc_set(struct m0_stob_io *io, uint64_t flags)
Definition: ad.c:2204
uint64_t m0_bindex_t
Definition: types.h:80
struct m0_be_ut_seg ut_seg
Definition: ad.c:73
void m0_be_ut_seg_init(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be, m0_bcount_t size)
Definition: stubs.c:256
struct m0_chan si_wait
Definition: io.h:318
uint64_t m0_bcount_t
Definition: types.h:77
void(* rpo_undo_credit)(const struct m0_fol_frag *frag, struct m0_be_tx_credit *accum)
Definition: fol.h:286
struct m0_be_emap_seg ec_seg
Definition: extmap.h:206
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL int stob_ad_cursor(struct m0_stob_ad_domain *adom, struct m0_stob *obj, uint64_t offset, struct m0_be_emap_cursor *it)
Definition: ad.c:1101
struct m0_be_tx_credit bec_tx_size_max
Definition: engine.h:73
static void test_ad_undo(void)
Definition: ad.c:566
M0_INTERNAL void m0_stob_ad_init_cfg_make(char **str, struct m0_be_domain *dom)
Definition: ad.c:212
static void mock_balloc_fini(struct m0_ad_balloc *ballroom)
Definition: ad.c:128
void ** ov_buf
Definition: vec.h:149
M0_INTERNAL int m0_dtx_done_sync(struct m0_dtx *tx)
Definition: dtm.c:122
static m0_bcount_t count
Definition: xcode.c:167
static struct m0_stob_domain * dom_back
Definition: ad.c:55
static void test_read(int nr)
Definition: ad.c:379
static int malloc_reserve_extent(struct m0_ad_balloc *ballroom, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t alloc_zone)
Definition: ad.c:158
static struct m0_stob * obj_fore
Definition: ad.c:58
struct m0_buf ee_cksum_buf
Definition: extmap.h:194
struct m0_vec iv_vec
Definition: vec.h:139
M0_INTERNAL uint32_t m0_stob_block_shift(struct m0_stob *stob)
Definition: stob.c:270
static void ub_read(int i)
Definition: ad.c:631
#define M0_BE_TX_CREDIT(nr, size)
Definition: tx_credit.h:94
struct m0_bufvec si_user
Definition: io.h:300
m0_bindex_t * iv_index
Definition: vec.h:141
int i
Definition: dir.c:1033
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
void m0_be_ut_backend_cfg_default(struct m0_be_domain_cfg *cfg)
Definition: stubs.c:227
struct m0_be_ut_backend ut_be
Definition: ad.c:72
static const struct m0_ad_balloc_ops mock_balloc_ops
Definition: ad.c:165
static int mock_balloc_free(struct m0_ad_balloc *ballroom, struct m0_dtx *dtx, struct m0_ext *ext)
Definition: ad.c:150
M0_INTERNAL int m0_stob_io_prepare_and_launch(struct m0_stob_io *io, struct m0_stob *obj, struct m0_dtx *tx, struct m0_io_scope *scope)
Definition: io.c:219
M0_INTERNAL const struct m0_stob_id * m0_stob_id_get(struct m0_stob *stob)
Definition: stob.c:250
static m0_bindex_t stob_vi[NR]
Definition: ad.c:69
struct m0_buf si_cksum
Definition: io.h:412
Definition: stob.h:163
struct m0_indexvec si_stob
Definition: io.h:311
int32_t si_rc
Definition: io.h:334
struct mock_balloc mb
Definition: ad.c:173
m0_bcount_t b_nob
Definition: buf.h:38
#define M0_ASSERT(cond)
const char * us_name
Definition: ub.h:76
M0_INTERNAL void m0_ext_init(struct m0_ext *ext)
Definition: ext.c:32
static void ub_write(int i)
Definition: ad.c:626
static void test_punch(int nr)
Definition: ad.c:418
static void test_ad(void)
Definition: ad.c:531
static void test_write(int nr, struct m0_dtx *tx)
Definition: ad.c:310
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_stob_addr_pack(const void *buf, uint32_t shift)
Definition: io.c:293
M0_INTERNAL struct m0_stob_ad_domain * stob_ad_domain2ad(const struct m0_stob_domain *dom)
Definition: ad.c:166
M0_INTERNAL int m0_stob_io_private_setup(struct m0_stob_io *io, struct m0_stob *obj)
Definition: io.c:49
struct m0_be_tx_credit tx_betx_cred
Definition: dtm.h:560
void * m0_alloc(size_t size)
Definition: memory.c:126
struct m0_fol_frag * si_fol_frag
Definition: io.h:390
M0_INTERNAL void m0_dtx_fini(struct m0_dtx *tx)
Definition: dtm.c:134
Definition: ad.c:52
struct m0_sm_group * m0_be_ut_backend_sm_group_lookup(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:277
uint32_t v_nr
Definition: vec.h:51
m0_bindex_t mb_next
Definition: ad.c:78
static char * user_cksm_buf[NR]
Definition: ad.c:63
Definition: io.h:285
static struct m0_stob_domain * dom_fore
Definition: ad.c:56
struct m0_fol_rec tx_fol_rec
Definition: dtm.h:561
m0_bcount_t * v_count
Definition: vec.h:53
m0_bcount_t si_cksum_sz
Definition: io.h:416
static uint64_t min64u(uint64_t a, uint64_t b)
Definition: arith.h:66
Definition: seg.h:66
static struct m0_stob_io io
Definition: ad.c:59
struct m0_be_domain but_dom
Definition: helper.h:47
m0_bcount_t si_count
Definition: io.h:340
static int test_ad_init(bool use_small_credits)
Definition: ad.c:208
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:255
struct m0_ext ee_ext
Definition: extmap.h:191
M0_INTERNAL int m0_stob_punch_credit(struct m0_stob *stob, struct m0_indexvec *want, struct m0_indexvec *got, struct m0_be_tx_credit *accum)
Definition: stob.c:223
struct m0_fid sd_id
Definition: domain.h:96
static char * read_bufs[NR]
Definition: ad.c:68
Definition: ext.h:37
m0_bindex_t e_start
Definition: ext.h:39
struct m0_be_tx tx_betx
Definition: dtm.h:559
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static int mock_balloc_alloc(struct m0_ad_balloc *ballroom, struct m0_dtx *dtx, m0_bcount_t count, struct m0_ext *out, uint64_t alloc_type)
Definition: ad.c:132
static m0_bcount_t user_vc[NR]
Definition: ad.c:60
static char * read_buf[NR]
Definition: ad.c:64
Definition: ad.c:646
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
void m0_be_ut_backend_fini(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:242
M0_INTERNAL void m0_stob_io_init(struct m0_stob_io *io)
Definition: io.c:111
M0_INTERNAL int m0_stob_find(const struct m0_stob_id *id, struct m0_stob **out)
Definition: stob.c:92
M0_INTERNAL int m0_dtx_open_sync(struct m0_dtx *tx)
Definition: dtm.c:101
static struct m0_be_seg * seg
Definition: btree.c:40
static int test_ad_fini(void)
Definition: ad.c:283
static uint32_t buf_size
Definition: ad.c:75
static char * user_bufs[NR]
Definition: ad.c:67
#define out(...)
Definition: gen.c:41
static uint32_t block_shift
Definition: ad.c:74
M0_INTERNAL int m0_ut_stob_create(struct m0_stob *stob, const char *str_cfg, struct m0_be_domain *be_dom)
Definition: stob.c:202
M0_INTERNAL void m0_stob_ad_cfg_make(char **str, const struct m0_be_seg *seg, const struct m0_stob_id *bstore_id, const m0_bcount_t size)
Definition: ad.c:220
static void init_vecs()
Definition: ad.c:180
M0_INTERNAL void * m0_alloc_aligned(size_t size, unsigned shift)
Definition: memory.c:168
Definition: io.h:229
void m0_stob_ut_ad_fini(struct m0_be_ut_backend *ut_be, struct m0_be_ut_seg *ut_seg)
Definition: ad.c:106
Definition: ad.c:77
void m0_free(void *data)
Definition: memory.c:146
static int ub_init(const char *opts M0_UNUSED)
Definition: ad.c:636
struct m0_be_engine_cfg bc_engine
Definition: domain.h:79
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
Definition: ub.h:74
#define M0_UT_ASSERT(a)
Definition: ut.h:46
static struct m0_stob * obj_back
Definition: ad.c:57
M0_INTERNAL void m0_stob_put(struct m0_stob *stob)
Definition: stob.c:291
static struct m0_clink clink
Definition: ad.c:70
static m0_bcount_t stob_vc[NR]
Definition: ad.c:61
static struct mock_balloc * b2mock(struct m0_ad_balloc *ballroom)
Definition: ad.c:113
Definition: tx.h:280
enum m0_stob_io_opcode si_opcode
Definition: io.h:286
#define M0_UNUSED
Definition: misc.h:380