Motr  M0
extmap.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2011-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_EXTMAP
24 #include "lib/trace.h"
25 #include "lib/arith.h" /* M0_3WAY, m0_uint128 */
26 #include "lib/errno.h" /* ENOENT */
27 #include "lib/vec.h"
28 #include "lib/types.h"
29 #include "lib/ub.h"
30 #include "lib/misc.h"
31 #include "lib/finject.h"
32 #include "ut/ut.h"
33 #include "be/ut/helper.h"
34 #include "be/extmap.h"
35 
36 #define EXTMAP_UT_UNIT_SIZE 10
37 #define EXTMAP_UT_CS_SIZE 16
38 
41 
42 static struct m0_be_tx tx1;
43 static struct m0_be_tx tx2;
44 static struct m0_be_emap *emap;
45 static struct m0_uint128 prefix;
46 static struct m0_be_emap_cursor it;
47 static struct m0_be_emap_seg *seg; /* cursor segment */
48 static struct m0_be_seg *be_seg;
49 static struct m0_be_op *it_op;
50 
51 static void emap_be_alloc(struct m0_be_tx *tx)
52 {
53  struct m0_be_tx_credit cred = {};
54  int rc;
55 
57 
59  m0_be_tx_prep(tx, &cred);
60 
61  rc = m0_be_tx_open_sync(tx);
62  M0_UT_ASSERT(rc == 0);
63 
66 
68  m0_be_tx_fini(tx);
69 }
70 
71 static void emap_be_free(struct m0_be_tx *tx)
72 {
73  struct m0_be_tx_credit cred = {};
74  int rc;
75 
77 
79  m0_be_tx_prep(tx, &cred);
80 
81  rc = m0_be_tx_open_sync(tx);
82  M0_UT_ASSERT(rc == 0);
83 
85 
87  m0_be_tx_fini(tx);
88 }
89 
90 /* XXX DELETEME? */
91 static void checkpoint(void)
92 {
93 }
94 
95 static void test_obj_init(struct m0_be_tx *tx)
96 {
98  checkpoint();
99 }
100 
101 static void test_obj_fini(struct m0_be_tx *tx)
102 {
103  int rc;
104 
106  op,
108  bo_u.u_emap.e_rc);
109  M0_UT_ASSERT(rc == 0);
110  checkpoint();
111 }
112 
113 static void test_init(void)
114 {
115  struct m0_be_domain_cfg *cfg;
116  struct m0_be_tx_credit cred = {};
117  int rc;
118 
119  M0_ENTRY();
120 
121  /* Init BE */
123  M0_ALLOC_PTR(cfg);
124  M0_UT_ASSERT(cfg != NULL);
125  M0_SET0(cfg);
128 
130  cfg->bc_engine.bec_tx_size_max = M0_BE_TX_CREDIT(1 << 21, 1 << 26);
132  M0_BE_TX_CREDIT(1 << 22, 1 << 27);
134  M0_UT_ASSERT(rc == 0);
137 
138  emap_be_alloc(&tx1);
140 
145  m0_forall(i, 5, m0_be_emap_credit(emap, M0_BEO_SPLIT, 3, &cred), true);
146  m0_be_emap_credit(emap, M0_BEO_MERGE, 5 * 3, &cred);
147  m0_be_emap_credit(emap, M0_BEO_PASTE, 3 * 5, &cred);
148 
150  m0_be_tx_prep(&tx2, &cred);
152  M0_UT_ASSERT(rc == 0);
153 
155  &M0_FID_INIT(0,1)));
156 
157  m0_uint128_init(&prefix, "some random iden");
159  it_op = m0_be_emap_op(&it);
160 
162 
163  m0_free(cfg);
164 
165  M0_LEAVE();
166 }
167 
168 static void test_fini(void)
169 {
171 
173  m0_be_tx_fini(&tx2);
174 
175  emap_be_free(&tx1);
176 
179 }
180 
181 static int be_emap_lookup(struct m0_be_emap *map,
182  const struct m0_uint128 *prefix,
184  struct m0_be_emap_cursor *it)
185 {
186  int rc;
187 
188  M0_SET0(&it->ec_op);
192  rc = it->ec_op.bo_u.u_emap.e_rc;
194 
195  return rc;
196 }
197 
198 static void test_lookup(void)
199 {
200  int rc;
201 
202  rc = be_emap_lookup(emap, &prefix, 0, &it);
203  M0_UT_ASSERT(rc == 0);
206  M0_UT_ASSERT(seg->ee_val == 42);
208 
210 
211  rc = be_emap_lookup(emap, &prefix, 1000000, &it);
212  M0_UT_ASSERT(rc == 0);
215  M0_UT_ASSERT(seg->ee_val == 42);
217 
219 
220  ++prefix.u_lo;
221  rc = be_emap_lookup(emap, &prefix, 0, &it);
222  M0_UT_ASSERT(rc == -ENOENT);
223  --prefix.u_lo;
224 
226 
227  checkpoint();
228 }
229 
230 static void split(m0_bindex_t offset, int nr, bool commit)
231 {
232  int i;
233  int rc;
234  m0_bcount_t len[] = { 100, 50, 0, 0 };
235  uint64_t val[] = { 1, 2, 3, 4 };
236  struct m0_indexvec vec = {
237  .iv_vec = {
238  .v_nr = ARRAY_SIZE(len),
239  .v_count = len
240  },
241  .iv_index = val
242  };
243 
244  struct m0_buf cksum[4] = { {0, NULL},
245  {0, NULL},
246  {0, NULL},
247  {0, NULL}};
248 
250  M0_UT_ASSERT(rc == 0);
251 
252  m0_buf_alloc(&cksum[0], (EXTMAP_UT_CS_SIZE * len[0])/EXTMAP_UT_UNIT_SIZE);
253  m0_buf_alloc(&cksum[1], (EXTMAP_UT_CS_SIZE * len[1])/EXTMAP_UT_UNIT_SIZE);
254 
255  memset(cksum[0].b_addr, 'A', cksum[0].b_nob);
256  memset(cksum[1].b_addr, 'B', cksum[1].b_nob);
257 
258  M0_LOG(M0_INFO, "off=%lu nr=%d", (unsigned long)offset, nr);
259  for (i = 0; i < nr; ++i) {
260  m0_bcount_t seglen;
262 
263  seglen = m0_ext_length(&seg->ee_ext);
264  M0_LOG(M0_DEBUG, "%3i: seglen=%llx", i,
265  (unsigned long long)seglen);
266  total = len[0]+len[1]; /* 100 + 50, the sum of elements in len[]. */
267  M0_UT_ASSERT(seglen > total);
268  len[ARRAY_SIZE(len) - 1] = seglen - total;
269  M0_SET0(it_op);
271  m0_be_emap_split(&it, &tx2, &vec, cksum);
273  M0_UT_ASSERT(it.ec_op.bo_u.u_emap.e_rc == 0);
276  len[ARRAY_SIZE(len) - 1]);
277  }
278 
280  m0_buf_free(&cksum[0]);
281  m0_buf_free(&cksum[1]);
282  if (commit)
283  checkpoint();
284 }
285 
286 static void test_split(void)
287 {
288  split(0, 5, true);
289 }
290 
291 static int test_print(void)
292 {
293  int i, j;
294  int rc;
295 
296  rc = be_emap_lookup(emap, &prefix, 0, &it);
297  M0_UT_ASSERT(rc == 0);
298 
300  for (i = 0; ; ++i) {
301  M0_LOG(M0_DEBUG, "\t%5.5i %16lx .. %16lx: %16lx %10lx", i,
302  (unsigned long)seg->ee_ext.e_start,
303  (unsigned long)seg->ee_ext.e_end,
304  (unsigned long)m0_ext_length(&seg->ee_ext),
305  (unsigned long)seg->ee_val);
306 
307  M0_LOG(M0_DEBUG,"Number of bytes for checksum %lu", (unsigned long)seg->ee_cksum_buf.b_nob);
308 
309  if (seg->ee_cksum_buf.b_nob > 0) {
310  char array[seg->ee_cksum_buf.b_nob + 1];
311  for (j = 0; j < seg->ee_cksum_buf.b_nob; j++) {
312  array[j] = *(char *)(seg->ee_cksum_buf.b_addr + j);
313  }
314  array[j] = '\0';
315  M0_LOG(M0_DEBUG, "checksum value %s", (char *)array);
316  }
317 
319  break;
320  M0_SET0(it_op);
324  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
326  }
328 
329  return i;
330 }
331 
332 static void test_next_prev(void)
333 {
334  int i;
335  int rc;
336  int n;
337 
338  n = test_print();
339 
340  rc = be_emap_lookup(emap, &prefix, 0, &it);
341  M0_UT_ASSERT(rc == 0);
342 
343  m0_fi_enable_once("be_emap_changed", "yes");
344  for (i = 0; ; ++i) {
346  break;
347  M0_SET0(it_op);
351  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
353  }
354  M0_UT_ASSERT(i == n);
355 
356  m0_fi_enable_once("be_emap_changed", "yes");
357  for (i = 0; ; ++i) {
359  break;
360  M0_SET0(it_op);
364  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
366  }
367  M0_UT_ASSERT(i == n);
369 
370 }
371 
372 static void test_merge(void)
373 {
374  int rc;
375 
376  M0_LOG(M0_INFO, "Merge all segments...");
377  rc = be_emap_lookup(emap, &prefix, 0, &it);
378  M0_UT_ASSERT(rc == 0);
379 
380  while (!m0_be_emap_ext_is_last(&seg->ee_ext)) {
381  M0_SET0(it_op);
385  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
387  }
389  checkpoint();
390 }
391 
392 static void test_paste(void)
393 {
394  int rc, e_val;
395  struct m0_ext e3, e2, e1, e;
396  struct m0_buf cksum = {};
397 
398  rc = be_emap_lookup(emap, &prefix, 0, &it);
399  M0_UT_ASSERT(rc == 0);
400 
401  e.e_start = 10;
402  e.e_end = 20;
403  e1 = e;
404  e_val = 12;
405 
407  memset(cksum.b_addr, 'C', cksum.b_nob);
409  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
410  M0_SET0(it_op);
412  m0_buf_init(&it.ec_app_cksum_buf, cksum.b_addr, cksum.b_nob);
413  m0_be_emap_paste(&it, &tx2, &e1, e_val, NULL, NULL, NULL);
415  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
417 
420 
421  test_print();
422 
423  rc = be_emap_lookup(emap, &prefix, 0, &it);
424  M0_UT_ASSERT(rc == 0);
425 
429 
431  M0_UT_ASSERT(rc == 0);
433  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum.b_addr, cksum.b_nob) == 0);
434 
437  M0_UT_ASSERT(seg->ee_val == e_val);
438 
439  rc = be_emap_lookup(emap, &prefix, e.e_end, &it);
440  M0_UT_ASSERT(rc == 0);
441 
445 
446  rc = be_emap_lookup(emap, &prefix, 0, &it);
447  M0_UT_ASSERT(rc == 0);
448 
449  m0_buf_free(&cksum);
452 
453  e.e_start = 5;
454  e.e_end = 25;
455  e2 = e;
456  e_val = 11;
457 
458  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
459  M0_SET0(it_op);
461  m0_be_emap_paste(&it, &tx2, &e2, e_val, NULL, NULL, NULL);
463  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
465 
468 
469  test_print();
470 
471  rc = be_emap_lookup(emap, &prefix, 0, &it);
472  M0_UT_ASSERT(rc == 0);
473 
476 
478  M0_UT_ASSERT(rc == 0);
479 
482  M0_UT_ASSERT(seg->ee_val == e_val);
483 
484  rc = be_emap_lookup(emap, &prefix, e.e_end, &it);
485  M0_UT_ASSERT(rc == 0);
486 
489 
490  rc = be_emap_lookup(emap, &prefix, 0, &it);
491  M0_UT_ASSERT(rc == 0);
492 
493  e.e_start = 0;
494  e.e_end = M0_BINDEX_MAX + 1;
495  e3 = e;
496 
497  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
498  M0_SET0(it_op);
500  m0_be_emap_paste(&it, &tx2, &e3, 0, NULL, NULL, NULL);
502  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
504 
505  test_print();
506 
508 }
509 
510 /* This UT will write :
511  * 1. 50 - 100 with CS = A
512  * 2.100 - 150 with CS = B
513  * 3. 80 - 130 with CS = P
514  * Validate the segement written along with checksum value
515  * Using this as reference other cases can be created e.g.
516  * - 50 - 100 with CS = A and then 70 - 90 with CS = P
517  * - 50 - 100 with CS = A and then 90 - 120 with CS = P
518  * - 50 - 100 with CS = A and then 20 - 70 with CS = P
519  */
521 {
522  int rc;
523  int idx;
524  int e_val[3];
525  struct m0_ext e_temp[3], e;
526  struct m0_ext es[3];
527  struct m0_buf cksum[3] = {};
528 
529  rc = be_emap_lookup(emap, &prefix, 0, &it);
530  M0_UT_ASSERT(rc == 0);
533 
534  idx = 0;
535  e.e_start = 50;
536  e.e_end = 100;
537  es[idx] = e_temp[idx] = e;
538  e_val[idx] = 12;
539 
540  m0_buf_alloc(&cksum[idx], (EXTMAP_UT_CS_SIZE *
542  memset(cksum[idx].b_addr, 'A', cksum[idx].b_nob);
544 
545  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
546  M0_SET0(it_op);
548  m0_buf_init(&it.ec_app_cksum_buf, cksum[idx].b_addr, cksum[idx].b_nob);
549  m0_be_emap_paste(&it, &tx2, &e_temp[idx], e_val[idx], NULL, NULL, NULL);
551  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
555 
556  test_print();
557 
558  /* Segment 0 lookup */
559  rc = be_emap_lookup(emap, &prefix, 0, &it);
560  M0_UT_ASSERT(rc == 0);
564 
565  /* Segment 1 - Pasted Chunk lookup */
567  M0_UT_ASSERT(rc == 0);
570  M0_UT_ASSERT(seg->ee_val == e_val[idx]);
571  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == cksum[idx].b_nob);
572  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[idx].b_addr, cksum[idx].b_nob) == 0);
573 
574  /* Segment 2 - End Chunk lookup */
575  rc = be_emap_lookup(emap, &prefix, e.e_end, &it);
576  M0_UT_ASSERT(rc == 0);
580 
581  /*
582  * New segment paste operation 1
583  */
584  idx = 1;
585  e.e_start = 100;
586  e.e_end = 150;
587  es[idx] = e_temp[idx] = e;
588  e_val[idx] = 11;
589 
590  m0_buf_alloc(&cksum[idx], (EXTMAP_UT_CS_SIZE *
592  memset(cksum[idx].b_addr, 'B', cksum[idx].b_nob);
594 
595  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
596  M0_SET0(it_op);
598  it.ec_app_cksum_buf = cksum[idx];
599  m0_be_emap_paste(&it, &tx2, &e_temp[idx], e_val[idx], NULL, NULL, NULL);
601  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
605 
606  /* Segment 0 lookup : Hole */
607  rc = be_emap_lookup(emap, &prefix, 0, &it);
608  M0_UT_ASSERT(rc == 0);
610  M0_UT_ASSERT(seg->ee_ext.e_end == es[0].e_start );
612 
613  /* Segment 1 - Pasted Chunk lookup : CS = A */
614  rc = be_emap_lookup(emap, &prefix, es[0].e_start, &it);
615  M0_UT_ASSERT(rc == 0);
617  M0_UT_ASSERT(seg->ee_ext.e_end == es[0].e_end );
618  M0_UT_ASSERT(seg->ee_val == e_val[0]);
619  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == cksum[0].b_nob);
620  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[0].b_addr, cksum[0].b_nob) == 0);
621 
622  /* Segment 2 - Pasted Chunk lookup : CS = B */
624  M0_UT_ASSERT(rc == 0);
627  M0_UT_ASSERT(seg->ee_val == e_val[idx]);
628  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == cksum[idx].b_nob);
629  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[idx].b_addr, cksum[idx].b_nob) == 0);
630 
631  /* Segment 3 - End Chunk lookup */
632  rc = be_emap_lookup(emap, &prefix, e.e_end, &it);
633  M0_UT_ASSERT(rc == 0);
637 
638  /*
639  * New segment overwrite paste operation
640  */
641  idx = 2;
642  e.e_start = 80;
643  e.e_end = 130;
644  es[idx] = e_temp[idx] = e;
645  e_val[idx] = 13;
646 
647  m0_buf_alloc(&cksum[idx], (EXTMAP_UT_CS_SIZE *
649  memset(cksum[idx].b_addr, 'P', cksum[idx].b_nob);
651 
653  M0_UT_ASSERT(rc == 0);
654 
655  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
656  M0_SET0(it_op);
658  it.ec_app_cksum_buf = cksum[idx];
659  m0_be_emap_paste(&it, &tx2, &e_temp[idx], e_val[idx], NULL, NULL, NULL);
661  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
664  M0_UT_ASSERT(seg->ee_ext.e_end == es[1].e_end );
665 
666  /* Segment 0 lookup : Hole */
667  rc = be_emap_lookup(emap, &prefix, 0, &it);
668  M0_UT_ASSERT(rc == 0);
670  M0_UT_ASSERT(seg->ee_ext.e_end == es[0].e_start );
672 
673  /* Segment 1 - Pasted Chunk lookup : CS = A */
674  rc = be_emap_lookup(emap, &prefix, es[0].e_start, &it);
675  M0_UT_ASSERT(rc == 0);
677  M0_UT_ASSERT(seg->ee_ext.e_end == es[2].e_start );
678  M0_UT_ASSERT(seg->ee_val == e_val[0]);
679  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == ((cksum[0].b_nob)* (es[2].e_start - es[0].e_start))/(es[0].e_end - es[0].e_start) );
680  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[0].b_addr, seg->ee_cksum_buf.b_nob) == 0);
681 
682  /* Segment 2 - Pasted Chunk lookup : CS = P */
684  M0_UT_ASSERT(rc == 0);
687  M0_UT_ASSERT(seg->ee_val == e_val[idx]);
688  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == cksum[idx].b_nob);
689  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[idx].b_addr, cksum[idx].b_nob) == 0);
690 
691  /* Segment 3 - Pasted Chunk lookup : CS = B */
692  rc = be_emap_lookup(emap, &prefix, es[2].e_end, &it);
693  M0_UT_ASSERT(rc == 0);
694  M0_UT_ASSERT(seg->ee_ext.e_start == es[2].e_end );
695  M0_UT_ASSERT(seg->ee_ext.e_end == es[1].e_end );
696  M0_UT_ASSERT(seg->ee_val == e_val[1]);
697  M0_UT_ASSERT(seg->ee_cksum_buf.b_nob == ((cksum[1].b_nob)* (es[1].e_end - es[2].e_end))/(es[1].e_end - es[1].e_start) );
698  M0_UT_ASSERT(memcmp(seg->ee_cksum_buf.b_addr, cksum[1].b_addr, seg->ee_cksum_buf.b_nob) == 0);
699 
700  /* Segment 4 - End Chunk lookup */
701  rc = be_emap_lookup(emap, &prefix, es[1].e_end, &it);
702  M0_UT_ASSERT(rc == 0);
703  M0_UT_ASSERT(seg->ee_ext.e_start == es[1].e_end );
706 
707  /* Cleanup code otherwise object delete code gives assert */
708  rc = be_emap_lookup(emap, &prefix, 0, &it);
709  M0_UT_ASSERT(rc == 0);
710 
711  e.e_start = 0;
712  e.e_end = M0_BINDEX_MAX + 1;
713 
714  M0_LOG(M0_INFO, "Paste [%d, %d)...", (int)e.e_start, (int)e.e_end);
715  M0_SET0(it_op);
720  M0_UT_ASSERT(it_op->bo_u.u_emap.e_rc == 0);
722 
723  M0_UT_ASSERT(seg->ee_ext.e_start == 0 );
726 
727  m0_buf_free( &cksum[0] );
728  m0_buf_free( &cksum[1] );
729  m0_buf_free( &cksum[2] );
731 }
732 
733 void m0_be_ut_emap(void)
734 {
735  test_init();
736  test_obj_init(&tx2);
737  test_lookup();
738  test_split();
739  test_print();
740  test_next_prev();
741  test_merge();
742  test_paste();
744  test_obj_fini(&tx2);
745  test_fini();
746 }
747 
748 #if 0 /* XXX RESTOREME */
749 struct m0_ut_suite m0_be_ut_emap = {
750  .ts_name = "be-emap-ut",
751  .ts_tests = {
752  { "emap-init", test_init },
753  { "obj-init", test_obj_init },
754  { "lookup", test_lookup },
755  { "split", test_split },
756  { "print", test_print },
757  { "merge", test_merge },
758  { "obj-fini", test_obj_fini },
759  { "emap-fini", test_fini },
760  { NULL, NULL }
761  }
762 };
763 #endif
764 
765 /*
766  * UB
767  */
768 //
769 //enum {
770 // UB_ITER = 100000,
771 // UB_ITER_TX = 10000
772 //};
773 //
774 //static int ub_init(const char *opts M0_UNUSED)
775 //{
776 // test_init();
777 // return 0;
778 //}
779 //
780 //static void ub_fini(void)
781 //{
782 // test_fini();
783 //}
784 //
785 //static struct m0_uint128 p;
786 //
787 //static void ub_obj_init(int i)
788 //{
789 // p = prefix;
790 //
791 // p.u_hi += i;
792 // p.u_lo -= i*i;
793 //
794 // m0_be_emap_obj_insert(emap, &tx, &op, &p, 42);
795 // M0_ASSERT(m0_be_op_is_done(&op));
796 // checkpoint();
797 //}
798 //
799 //static void ub_obj_fini(int i)
800 //{
801 // p = prefix;
802 //
803 // p.u_hi += i;
804 // p.u_lo -= i*i;
805 //
806 // m0_be_emap_obj_delete(emap, &tx, &op, &p);
807 // M0_ASSERT(m0_be_op_is_done(&op));
808 // checkpoint();
809 //}
810 //
811 //static void ub_obj_init_same(int i)
812 //{
813 // p = prefix;
814 //
815 // p.u_hi += i;
816 // p.u_lo -= i*i;
817 //
818 // m0_be_emap_obj_insert(emap, &tx, &op, &p, 42);
819 // M0_ASSERT(m0_be_op_is_done(&op));
820 //}
821 //
822 //static void ub_obj_fini_same(int i)
823 //{
824 // p = prefix;
825 //
826 // p.u_hi += i;
827 // p.u_lo -= i*i;
828 //
829 // m0_be_emap_obj_delete(emap, &tx, &op, &p);
830 // M0_ASSERT(m0_be_op_is_done(&op));
831 //}
832 //
833 //static void ub_split(int i)
834 //{
835 // split(5000, 1, false);
836 //}
837 //
838 //struct m0_ub_set m0_be_emap_ub = {
839 // .us_name = "emap-ub",
840 // .us_init = ub_init,
841 // .us_fini = ub_fini,
842 // .us_run = {
843 // { .ub_name = "obj-init",
844 // .ub_iter = UB_ITER,
845 // .ub_round = ub_obj_init },
846 //
847 // { .ub_name = "obj-fini",
848 // .ub_iter = UB_ITER,
849 // .ub_round = ub_obj_fini },
850 //
851 // { .ub_name = "obj-init-same-tx",
852 // .ub_iter = UB_ITER_TX,
853 // .ub_round = ub_obj_init_same },
854 //
855 // { .ub_name = "obj-fini-same-tx",
856 // .ub_iter = UB_ITER_TX,
857 // .ub_round = ub_obj_fini_same },
858 //
859 // { .ub_name = "split",
860 // .ub_iter = UB_ITER/5,
861 // .ub_init = test_obj_init,
862 // .ub_round = ub_split },
863 //
864 // { .ub_name = NULL }
865 // }
866 //};
867 
868 #undef M0_TRACE_SUBSYSTEM
869 
870 /*
871  * Local variables:
872  * c-indentation-style: "K&R"
873  * c-basic-offset: 8
874  * tab-width: 8
875  * fill-column: 80
876  * scroll-step: 1
877  * End:
878  */
879 
#define EXTMAP_UT_CS_SIZE
Definition: extmap.c:37
void m0_be_ut_seg_fini(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:267
#define M0_BE_ALLOC_CREDIT_PTR(ptr, seg, accum)
Definition: alloc.h:355
static size_t nr
Definition: dump.c:1505
#define M0_BE_ALLOC_PTR_SYNC(ptr, seg, tx)
Definition: alloc.h:339
static void split(m0_bindex_t offset, int nr, bool commit)
Definition: extmap.c:230
M0_INTERNAL m0_bcount_t m0_ext_length(const struct m0_ext *ext)
Definition: ext.c:42
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
M0_INTERNAL void m0_be_emap_next(struct m0_be_emap_cursor *it)
Definition: extmap.c:377
m0_bindex_t e_end
Definition: ext.h:40
#define NULL
Definition: misc.h:38
map
Definition: processor.c:112
Definition: idx_mock.c:52
static void test_fini(void)
Definition: extmap.c:168
void * b_addr
Definition: buf.h:39
static void test_paste(void)
Definition: extmap.c:392
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
m0_bindex_t e_start
Definition: ext.h:96
uint64_t ee_val
Definition: extmap.h:193
struct m0_be_seg * bus_seg
Definition: helper.h:119
#define M0_FID_INIT(container, key)
Definition: fid.h:84
M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
Definition: stubs.c:163
M0_INTERNAL void m0_uint128_init(struct m0_uint128 *u128, const char *magic)
Definition: misc.c:150
static void checkpoint(void)
Definition: extmap.c:91
static struct m0_uint128 prefix
Definition: extmap.c:45
#define M0_BE_OP_SYNC(op_obj, action)
Definition: op.h:190
void m0_be_ut_emap(void)
Definition: extmap.c:733
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
Definition: buf.c:37
M0_INTERNAL void m0_be_emap_destroy(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op)
Definition: extmap.c:300
M0_INTERNAL void m0_be_emap_obj_insert(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_uint128 *prefix, uint64_t val)
Definition: extmap.c:744
M0_INTERNAL void m0_be_emap_prev(struct m0_be_emap_cursor *it)
Definition: extmap.c:391
M0_INTERNAL void m0_be_emap_close(struct m0_be_emap_cursor *it)
Definition: extmap.c:360
static void test_init(void)
Definition: extmap.c:113
static struct m0_be_emap_cursor it
Definition: extmap.c:46
static int be_emap_lookup(struct m0_be_emap *map, const struct m0_uint128 *prefix, m0_bindex_t offset, struct m0_be_emap_cursor *it)
Definition: extmap.c:181
M0_INTERNAL void m0_be_tx_prep(struct m0_be_tx *tx, const struct m0_be_tx_credit *credit)
Definition: stubs.c:175
uint64_t m0_bindex_t
Definition: types.h:80
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
uint64_t m0_bcount_t
Definition: types.h:77
m0_bindex_t ec_unit_size
Definition: extmap.h:214
#define M0_SET0(obj)
Definition: misc.h:64
Definition: ut.h:77
M0_INTERNAL void m0_be_emap_split(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, struct m0_indexvec *vec, struct m0_buf *cksum)
Definition: extmap.c:464
struct m0_be_tx_credit bec_tx_size_max
Definition: engine.h:73
M0_INTERNAL bool m0_be_emap_ext_is_first(const struct m0_ext *ext)
Definition: extmap.c:323
M0_INTERNAL void m0_be_emap_merge(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, m0_bindex_t delta)
Definition: extmap.c:432
static void emap_be_free(struct m0_be_tx *tx)
Definition: extmap.c:71
struct m0_buf ee_cksum_buf
Definition: extmap.h:194
M0_INTERNAL struct m0_be_op * m0_be_emap_op(struct m0_be_emap_cursor *it)
Definition: extmap.c:328
op
Definition: libdemo.c:64
#define M0_BE_TX_CREDIT(nr, size)
Definition: tx_credit.h:94
static void test_merge(void)
Definition: extmap.c:372
#define M0_ENTRY(...)
Definition: trace.h:170
Definition: buf.h:37
int i
Definition: dir.c:1033
void m0_be_ut_backend_cfg_default(struct m0_be_domain_cfg *cfg)
Definition: stubs.c:227
static void test_obj_fini(struct m0_be_tx *tx)
Definition: extmap.c:101
M0_INTERNAL void m0_be_emap_paste(struct m0_be_emap_cursor *it, struct m0_be_tx *tx, struct m0_ext *ext, uint64_t val, void(*del)(struct m0_be_emap_seg *), void(*cut_left)(struct m0_be_emap_seg *, struct m0_ext *, uint64_t), void(*cut_right)(struct m0_be_emap_seg *, struct m0_ext *, uint64_t))
Definition: extmap.c:517
#define M0_BE_OP_SYNC_RET(op_obj, action, member)
Definition: op.h:243
void * b_addr
Definition: buf.h:231
M0_INTERNAL void m0_be_emap_init(struct m0_be_emap *map, struct m0_be_seg *db)
Definition: extmap.c:258
Definition: trace.h:482
static void test_lookup(void)
Definition: extmap.c:198
static void * vec
Definition: xcode.c:168
m0_bcount_t b_nob
Definition: buf.h:38
struct m0_be_tx_credit tgc_size_max
Definition: tx_group.h:61
static struct m0_be_op * it_op
Definition: extmap.c:49
#define U128_P(x)
Definition: types.h:45
static struct m0_be_seg * be_seg
Definition: extmap.c:48
M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
Definition: stubs.c:199
M0_INTERNAL bool m0_be_emap_ext_is_last(const struct m0_ext *ext)
Definition: extmap.c:318
struct m0_be_op ec_op
Definition: extmap.h:217
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
Definition: buf.c:43
struct m0_be_op::@39::@40 u_emap
static struct m0_be_tx tx2
Definition: extmap.c:43
M0_INTERNAL void m0_be_emap_lookup(struct m0_be_emap *map, const struct m0_uint128 *prefix, m0_bindex_t offset, struct m0_be_emap_cursor *it)
Definition: extmap.c:344
static m0_bindex_t offset
Definition: dump.c:173
M0_INTERNAL void m0_be_emap_obj_delete(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_uint128 *prefix)
Definition: extmap.c:774
M0_INTERNAL void m0_buf_free(struct m0_buf *buf)
Definition: buf.c:55
static void test_split(void)
Definition: extmap.c:286
#define M0_BE_FREE_PTR_SYNC(ptr, seg, tx)
Definition: alloc.h:345
Definition: seg.h:66
static struct m0_be_ut_seg be_ut_emap_seg
Definition: extmap.c:40
static struct m0_be_emap * emap
Definition: extmap.c:44
static void emap_be_alloc(struct m0_be_tx *tx)
Definition: extmap.c:51
#define U128X_F
Definition: types.h:42
#define EXTMAP_UT_UNIT_SIZE
Definition: extmap.c:36
#define m0_forall(var, nr,...)
Definition: misc.h:112
static void test_paste_checksum_validation(void)
Definition: extmap.c:520
struct m0_ext ee_ext
Definition: extmap.h:191
static int test_print(void)
Definition: extmap.c:291
uint64_t n
Definition: fops.h:107
Definition: ext.h:37
m0_bindex_t e_start
Definition: ext.h:39
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
m0_bindex_t e_end
Definition: ext.h:97
static struct m0_be_emap_seg * seg
Definition: extmap.c:47
void m0_be_ut_tx_init(struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be)
Definition: stubs.c:286
static struct m0_be_tx tx1
Definition: extmap.c:42
M0_INTERNAL void m0_be_op_fini(struct m0_be_op *op)
Definition: stubs.c:92
void m0_be_ut_backend_fini(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:242
static void m0_fi_enable_once(const char *func, const char *tag)
Definition: finject.h:301
struct m0_be_tx_group_cfg bec_group_cfg
Definition: engine.h:71
union m0_be_op::@39 bo_u
static int total
Definition: base.c:302
M0_INTERNAL void m0_be_emap_credit(struct m0_be_emap *map, enum m0_be_emap_optype optype, m0_bcount_t nr, struct m0_be_tx_credit *accum)
Definition: extmap.c:886
struct m0_buf ec_app_cksum_buf
Definition: extmap.h:216
static void test_next_prev(void)
Definition: extmap.c:332
uint64_t u_lo
Definition: types.h:37
Definition: op.h:74
M0_INTERNAL void m0_be_op_init(struct m0_be_op *op)
Definition: stubs.c:87
void m0_free(void *data)
Definition: memory.c:146
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
#define M0_UT_ASSERT(a)
Definition: ut.h:46
M0_INTERNAL void m0_be_emap_create(struct m0_be_emap *map, struct m0_be_tx *tx, struct m0_be_op *op, const struct m0_fid *fid)
Definition: extmap.c:283
#define M0_BE_FREE_CREDIT_PTR(ptr, seg, accum)
Definition: alloc.h:359
M0_INTERNAL void m0_be_op_wait(struct m0_be_op *op)
Definition: stubs.c:96
M0_INTERNAL struct m0_be_emap_seg * m0_be_emap_seg_get(struct m0_be_emap_cursor *it)
Definition: extmap.c:313
m0_bcount_t b_nob
Definition: buf.h:230
M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)
Definition: stubs.c:205
Definition: tx.h:280
static void test_obj_init(struct m0_be_tx *tx)
Definition: extmap.c:95
static struct m0_be_ut_backend be_ut_emap_backend
Definition: extmap.c:39