Motr  M0
log_store.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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT
24 #include "lib/trace.h"
25 
26 #include "be/log_store.h"
27 
28 #include "be/op.h" /* M0_BE_OP_SYNC */
29 #include "be/log_sched.h" /* m0_be_log_io */
30 
31 #include "lib/misc.h" /* M0_SET0 */
32 #include "lib/errno.h" /* EINVAL */
33 #include "lib/memory.h" /* M0_ALLOC_ARR */
34 #include "lib/string.h" /* m0_strdup */
35 #include "ut/ut.h" /* M0_UT_ASSERT */
36 #include "ut/stob.h" /* m0_ut_stob_linux_get */
37 #include "be/op.h" /* M0_BE_OP_SYNC */
38 
39 #include "stob/domain.h" /* m0_stob_domain_create */
40 #include "stob/stob.h" /* m0_stob_id_make */
41 
42 #if 0
43 /* DEAD CODE BEGIN */
44 struct m0_be_log_store_io {
45  struct m0_be_log_store *lsi_ls;
46  struct m0_be_io *lsi_io;
47  struct m0_be_io *lsi_io_cblock;
48  m0_bindex_t lsi_pos;
49  m0_bindex_t lsi_end;
50 };
51 /* DEAD CODE END */
52 
53 enum {
54  BE_UT_LOG_STOR_SIZE = 0x100,
55  BE_UT_LOG_STOR_STEP = 0xF,
56  BE_UT_LOG_STOR_ITER = 0x200,
57  BE_UT_LOG_STOR_CR_NR = 0x7,
58 };
59 
60 static char be_ut_log_store_pre[BE_UT_LOG_STOR_SIZE];
61 static char be_ut_log_store_post[BE_UT_LOG_STOR_SIZE];
62 static uint64_t be_ut_log_store_seed;
63 static m0_bindex_t be_ut_log_store_pos;
64 
65 /* this random may have non-uniform distribution */
66 static int be_ut_log_store_rand(int mod)
67 {
68  return m0_rnd64(&be_ut_log_store_seed) % mod;
69 }
70 
71 static void
72 be_ut_log_store_io_read(struct m0_be_log_store *ls, char *buf, m0_bcount_t size)
73 {
74  struct m0_be_io bio = {};
75  int rc;
76 
77  rc = m0_be_io_init(&bio);
78  M0_UT_ASSERT(rc == 0);
79  rc = m0_be_io_allocate(&bio, &M0_BE_IO_CREDIT(1, size, 1));
80  M0_UT_ASSERT(rc == 0);
81  m0_be_io_add(&bio, ls->ls_stob, buf, 0, size);
83 
84  rc = M0_BE_OP_SYNC(op, m0_be_io_launch(&bio, &op));
85  M0_UT_ASSERT(rc == 0);
86 
87  m0_be_io_deallocate(&bio);
88  m0_be_io_fini(&bio);
89 }
90 
91 static void
92 be_ut_log_store_rand_cr(struct m0_be_io_credit *cr, m0_bcount_t size)
93 {
94  int buf[BE_UT_LOG_STOR_CR_NR];
95  m0_bcount_t i;
96 
97  M0_SET0(cr);
99  for (i = 0; i < size; ++i)
100  ++buf[be_ut_log_store_rand(ARRAY_SIZE(buf))];
101  for (i = 0; i < ARRAY_SIZE(buf); ++i) {
102  if (buf[i] != 0)
104  }
105  /* wrap credit */
106  m0_be_io_credit_add(cr, &M0_BE_IO_CREDIT(1, 0, 0));
107 }
108 
109 static void be_ut_log_store_io_write_sync(struct m0_be_io *bio)
110 {
111  int rc;
112 
114  rc = M0_BE_OP_SYNC(op, m0_be_io_launch(bio, &op));
115  M0_UT_ASSERT(rc == 0);
116 }
117 
118 static void
119 be_ut_log_store_io_check(struct m0_be_log_store *ls, m0_bcount_t size)
120 {
121  struct m0_be_log_store_io lsi;
122  struct m0_be_io_credit io_cr_log;
123  struct m0_be_io_credit io_cr_log_cblock;
124  struct m0_be_io io_log = {};
125  struct m0_be_io io_log_cblock = {};
126  m0_bcount_t cblock_size;
128  int cmp;
129  int rc;
130  int i;
131  char rbuf[BE_UT_LOG_STOR_SIZE];
132 
133  M0_PRE(size <= ARRAY_SIZE(rbuf));
134 
135  for (i = 0; i < size; ++i)
136  rbuf[i] = be_ut_log_store_rand(0x100);
137 
138  cblock_size = be_ut_log_store_rand(size - 1) + 1;
139  data_size = size - cblock_size;
140  M0_ASSERT(cblock_size > 0);
141  M0_ASSERT(data_size > 0);
142 
143  be_ut_log_store_rand_cr(&io_cr_log, data_size);
144  m0_be_log_store_cblock_io_credit(&io_cr_log_cblock, cblock_size);
145 
146  rc = m0_be_io_init(&io_log);
147  M0_UT_ASSERT(rc == 0);
148  rc = m0_be_io_allocate(&io_log, &io_cr_log);
149  M0_UT_ASSERT(rc == 0);
150  rc = m0_be_io_init(&io_log_cblock);
151  M0_UT_ASSERT(rc == 0);
152  rc = m0_be_io_allocate(&io_log_cblock, &io_cr_log_cblock);
153  M0_UT_ASSERT(rc == 0);
154 
155  m0_be_log_store_io_init(&lsi, ls, &io_log, &io_log_cblock, size);
156 
157  /* save */
158  be_ut_log_store_io_read(ls, be_ut_log_store_pre,
159  ARRAY_SIZE(be_ut_log_store_pre));
160  /* log storage io */
161  m0_be_log_store_io_add(&lsi, rbuf, data_size);
162  m0_be_log_store_io_add_cblock(&lsi, &rbuf[data_size], cblock_size);
163  m0_be_log_store_io_sort(&lsi);
164  m0_be_log_store_io_fini(&lsi);
165  be_ut_log_store_io_write_sync(&io_log);
166  be_ut_log_store_io_write_sync(&io_log_cblock);
167  /* do operation in saved memory representation of the log storage */
168  for (i = 0; i < size; ++i) {
169  be_ut_log_store_pre[(be_ut_log_store_pos + i) %
170  BE_UT_LOG_STOR_SIZE] = rbuf[i];
171  }
172  be_ut_log_store_pos += size;
173  /* check if it was done in log */
174  be_ut_log_store_io_read(ls, be_ut_log_store_post,
175  ARRAY_SIZE(be_ut_log_store_post));
176  cmp = memcmp(be_ut_log_store_pre, be_ut_log_store_post, size);
177  M0_UT_ASSERT(cmp == 0);
178 
179  m0_be_io_deallocate(&io_log_cblock);
180  m0_be_io_fini(&io_log_cblock);
181  m0_be_io_deallocate(&io_log);
182  m0_be_io_fini(&io_log);
183 }
184 
185 static void be_ut_log_store_io_check_nop(struct m0_be_log_store *ls,
187 {
188  struct m0_be_log_store_io lsi = {};
189  struct m0_be_io io_log = {};
190  struct m0_be_io io_log_cblock = {};
191  int rc;
192 
193  rc = m0_be_io_init(&io_log);
194  M0_UT_ASSERT(rc == 0);
195  rc = m0_be_io_allocate(&io_log, &M0_BE_IO_CREDIT(1, 1, 1));
196  M0_UT_ASSERT(rc == 0);
197  rc = m0_be_io_init(&io_log_cblock);
198  M0_UT_ASSERT(rc == 0);
199  rc = m0_be_io_allocate(&io_log_cblock, &M0_BE_IO_CREDIT(1, 1, 1));
200  M0_UT_ASSERT(rc == 0);
201 
202  m0_be_log_store_io_init(&lsi, ls, &io_log, &io_log_cblock, size);
203  m0_be_log_store_io_fini(&lsi);
204 
205  m0_be_io_deallocate(&io_log_cblock);
206  m0_be_io_fini(&io_log_cblock);
207  m0_be_io_deallocate(&io_log);
208  m0_be_io_fini(&io_log);
209 }
210 
211 static void be_ut_log_store(bool fake_io)
212 {
213  struct m0_be_log_store ls;
214  struct m0_stob *stob;
215  const m0_bcount_t log_size = BE_UT_LOG_STOR_SIZE;
217  m0_bcount_t step;
218  int rc;
219  int i;
220 
222  M0_SET0(&ls);
223  m0_be_log_store_init(&ls, stob);
224 
225  rc = m0_be_log_store_create(&ls, log_size);
226  M0_UT_ASSERT(rc == 0);
227 
228  used = 0;
229  be_ut_log_store_seed = 0;
230  be_ut_log_store_pos = 0;
231  for (step = 2; step <= BE_UT_LOG_STOR_STEP; ++step) {
232  for (i = 0; i < BE_UT_LOG_STOR_ITER; ++i) {
233  M0_UT_ASSERT(0 <= used && used <= BE_UT_LOG_STOR_SIZE);
234  if (used + step <= log_size) {
235  rc = m0_be_log_store_reserve(&ls, step);
236  M0_UT_ASSERT(rc == 0);
237  used += step;
238  if (fake_io) {
239  be_ut_log_store_io_check_nop(&ls, step);
240  } else {
241  be_ut_log_store_io_check(&ls, step);
242  }
243  } else {
244  rc = m0_be_log_store_reserve(&ls, step);
245  M0_UT_ASSERT(rc != 0);
246  m0_be_log_store_discard(&ls, step);
247  used -= step;
248  }
249  }
250  }
251  m0_be_log_store_discard(&ls, used);
252 
254  m0_be_log_store_fini(&ls);
255  m0_ut_stob_put(stob, true);
256 }
257 #endif
258 
259 enum {
266 };
267 
268 #define BE_UT_LOG_STORE_SDOM_INIT_CFG "directio=true"
269 
270 static const char *be_ut_log_store_sdom_location = "linuxstob:./log_store";
271 static const char *be_ut_log_store_sdom_init_cfg =
273 static const char *be_ut_log_store_sdom_create_cfg = "";
274 
276  /* temporary solution BEGIN */
277  .lsc_stob_domain_location = "linuxstob:./log_store-tmp",
278  .lsc_stob_domain_init_cfg = BE_UT_LOG_STORE_SDOM_INIT_CFG,
279  .lsc_stob_domain_key = 0x1000,
280  .lsc_stob_domain_create_cfg = NULL,
281  /* temporary solution END */
282  .lsc_size = BE_UT_LOG_STORE_SIZE,
283  .lsc_stob_create_cfg = NULL,
284  .lsc_rbuf_nr = BE_UT_LOG_STORE_RBUF_NR,
285  .lsc_rbuf_size = BE_UT_LOG_STORE_RBUF_SIZE,
286 };
287 #undef BE_UT_LOG_STORE_SDOM_INIT_CFG
288 
290 {
291  int rc;
292 
294  M0_UT_ASSERT(rc == 0);
299  sdom);
300  M0_UT_ASSERT(rc == 0);
301 }
302 
304 {
305  int rc;
306 
308  M0_UT_ASSERT(rc == 0);
309 }
310 
312 {
318  struct m0_be_log_store ls;
319  struct m0_stob_domain *sdom;
320  int rc;
321 
323 
326 
327  M0_SET0(&ls);
328  M0_LOG(M0_DEBUG, "open() should fail for non-existent log_store");
329  rc = m0_be_log_store_open(&ls, &ls_cfg);
330  M0_UT_ASSERT(rc != 0);
331 
332  M0_SET0(&ls);
333  M0_LOG(M0_DEBUG, "create() should succeed for non-existent log_store");
334  rc = m0_be_log_store_create(&ls, &ls_cfg);
335  M0_UT_ASSERT(rc == 0);
336  M0_LOG(M0_DEBUG, "destroy() after successful create()");
338 
339  M0_SET0(&ls);
340  M0_LOG(M0_DEBUG, "create() + close()");
341  rc = m0_be_log_store_create(&ls, &ls_cfg);
342  M0_UT_ASSERT(rc == 0);
344 
345 #if 0
346  M0_SET0(&ls);
347  M0_LOG(M0_DEBUG, "create() should fail after successful create()");
348  rc = m0_be_log_store_create(&ls, &ls_cfg);
349  M0_UT_ASSERT(rc != 0);
350 #endif
351 
352  M0_SET0(&ls);
353  M0_LOG(M0_DEBUG, "open() + close()");
354  rc = m0_be_log_store_open(&ls, &ls_cfg);
355  M0_UT_ASSERT(rc == 0);
357 
358  M0_SET0(&ls);
359  M0_LOG(M0_DEBUG, "open() + destroy()");
360  rc = m0_be_log_store_open(&ls, &ls_cfg);
361  M0_UT_ASSERT(rc == 0);
363 
364  M0_SET0(&ls);
365  M0_LOG(M0_DEBUG, "open() should fail after destroy()");
366  rc = m0_be_log_store_open(&ls, &ls_cfg);
367  M0_UT_ASSERT(rc != 0);
368 
370 }
371 
373 {
376  struct m0_stob_domain *sdom;
377  char *location;
378  int rc;
379  int i;
380 
382 
383  for (i = 0; i < ARRAY_SIZE(ls_cfg); ++i) {
384  ls_cfg[i] = be_ut_log_store_cfg;
387  &ls_cfg[i].lsc_stob_id);
388  /* temporary solution BEGIN */
389  location = m0_strdup(ls_cfg[i].lsc_stob_domain_location);
390  M0_ASSERT(i <= 'Z' - 'A');
391  location[strlen(location) - 1] = 'A' + i; /* XXX Workaroud */
393  ls_cfg[i].lsc_stob_domain_key += i;
394  /* temporary solution END */
395  }
396 
397  for (i = 0; i < ARRAY_SIZE(ls); ++i) {
398  rc = m0_be_log_store_create(&ls[i], &ls_cfg[i]);
399  M0_UT_ASSERT(rc == 0);
400  }
401  for (i = 0; i < ARRAY_SIZE(ls); ++i)
403 
404  /* temporary solution BEGIN */
405  for (i = 0; i < ARRAY_SIZE(ls_cfg); ++i)
406  m0_free(ls_cfg[i].lsc_stob_domain_location);
407  /* temporary solution END */
408 
410 }
411 
412 static void
414  bool first_run))
415 {
417  struct m0_be_log_store ls = {};
418  struct m0_stob_domain *sdom;
419  int rc;
420  int i;
421 
423 
426 
427  rc = m0_be_log_store_create(&ls, &ls_cfg);
428  M0_UT_ASSERT(rc == 0);
429 
430  for (i = 0; i < 2; ++i) {
431  func(&ls, i == 0);
433  m0_be_log_store_open(&ls, &ls_cfg);
434  }
435 
437 
439 }
440 
441 enum {
444 };
445 
446 /* Check I/O windows ordering. */
448  bool first_run)
449 {
450  m0_bindex_t offset = 0;
451  m0_bcount_t length;
452  m0_bindex_t offset1 = 0;
453  m0_bcount_t length1 = 0;
454  int rc;
455  int i;
456 
457  for (i = 0; i < BE_UT_LOG_STORE_IO_WINDOW_STEP_NR; ++i) {
458  rc = m0_be_log_store_io_window(ls, offset, &length);
459  M0_UT_ASSERT(rc == 0);
460  M0_UT_ASSERT(length != 0);
461  M0_UT_ASSERT(length1 + offset1 <= length + offset);
462  offset1 = offset;
463  length1 = length;
464 
466  }
467 }
468 
470 {
472 }
473 
474 enum {
477 };
478 
480  bool first_run)
481 {
482  m0_bindex_t offset = 0;
483  m0_bcount_t length;
484  int rc;
485  int i;
486 
487  for (i = 0; i < BE_UT_LOG_STORE_IO_DISCARD_STEP_NR; ++i) {
488  rc = m0_be_log_store_io_window(ls, offset, &length);
489  M0_UT_ASSERT(rc == 0);
491  rc = m0_be_log_store_io_window(ls, offset, &length);
492  M0_UT_ASSERT(M0_IN(rc, (0, -EINVAL)));
493  M0_UT_ASSERT(ergo(rc == 0, length != 0));
494 
496  }
497 }
498 
500 {
502 }
503 
504 enum {
508 };
509 
511  unsigned nr,
512  uint64_t *seed)
513 {
514  m0_bcount_t delta;
515  unsigned i;
516  unsigned index;
517 
518  for (i = 1; i < nr; ++i) {
519  /* find a number to split */
520  do {
521  index = m0_rnd64(seed) % i;
522  } while (io_length[index] < 2);
523  /* split it into two non-zero numbers */
524  delta = m0_rnd64(seed) % (io_length[index] - 1) + 1;
525  io_length[index] -= delta;
526  io_length[i] = delta;
527  M0_UT_ASSERT(io_length[index] > 0);
528  M0_UT_ASSERT(io_length[i] > 0);
529  }
530 }
531 
533  unsigned nr)
534 {
535  struct m0_be_io *bio1;
536  struct m0_be_io *bio2;
537  bool intersect;
538  int i;
539  int j;
540 
541  for (i = 0; i < nr; ++i)
542  for (j = i + 1; j < nr; ++j) {
543  bio1 = m0_be_log_io_be_io(lio[i]);
544  bio2 = m0_be_log_io_be_io(lio[j]);
545  intersect = m0_be_io_intersect(bio1, bio2);
546  M0_UT_ASSERT(!intersect);
547  }
548 }
549 
551  bool first_run)
552 {
553  struct m0_be_io_credit iocred = {};
554  struct m0_be_log_io *lio;
555  struct m0_be_log_io **lio_arr;
556  struct m0_be_io *bio;
557  unsigned char *field;
560  m0_bindex_t offset = 0;
561  m0_bcount_t length;
562  m0_bcount_t length1;
563  m0_bcount_t field_length;
565  uint32_t bshift = m0_be_log_store_bshift(ls);
566  uint64_t alignment = 1ULL << bshift;
567  uint64_t seed = 42;
568  int rc;
569  int i;
570  int j;
571 
573  M0_UT_ASSERT(lio != NULL);
575  M0_UT_ASSERT(lio_arr != NULL);
576  for (i = 0; i < BE_UT_LOG_STORE_IO_NR; ++i)
577  lio_arr[i] = &lio[i];
578  rc = m0_be_log_store_io_window(ls, 0, &field_length);
579  M0_UT_ASSERT(rc == 0);
580  field = m0_alloc_aligned(field_length, bshift);
581  for (i = 0; i < field_length; ++i)
582  field[i] = m0_rnd64(&seed) & 0xFF;
583  m0_be_log_store_io_credit(ls, &iocred);
584  m0_be_io_credit_add(&iocred, &M0_BE_IO_CREDIT(1, field_length, 0));
585  for (i = 0; i < BE_UT_LOG_STORE_IO_NR; ++i) {
586  rc = m0_be_log_io_init(&lio[i]);
587  M0_UT_ASSERT(rc == 0);
588  rc = m0_be_log_io_allocate(&lio[i], &iocred, bshift);
589  M0_UT_ASSERT(rc == 0);
590  }
591  for (i = 0; i < BE_UT_LOG_STORE_IO_TRANSLATE_STEP_NR; ++i) {
592  rc = m0_be_log_store_io_window(ls, offset, &length);
593  M0_UT_ASSERT(rc == 0);
594  length = m0_round_down(length, alignment);
595  M0_UT_ASSERT(length > 0);
596  /*
597  * Temporary solution. If log store can expand then field_length
598  * should be increased here (field allocated size should be
599  * increased too).
600  */
601  M0_UT_ASSERT(length <= field_length);
602 
603  io_length[0] = length / alignment;
604  be_ut_log_store_length_generate(&io_length[0],
605  ARRAY_SIZE(io_length), &seed);
606  for (j = 0; j < ARRAY_SIZE(io_length); ++j)
607  io_length[j] *= alignment;
608  length1 = m0_reduce(k, ARRAY_SIZE(io_length),
609  0, + io_length[k]);
610  M0_UT_ASSERT(length == length1);
611 
612  io_offset[0] = 0;
613  for (j = 1; j < ARRAY_SIZE(io_length); ++j)
614  io_offset[j] = io_offset[j - 1] + io_length[j - 1];
615 
616  for (j = 0; j < ARRAY_SIZE(io_length); ++j) {
617  m0_be_log_io_reset(&lio[j]);
618  bio = m0_be_log_io_be_io(&lio[j]);
619  m0_be_io_add_nostob(bio, field, 0, io_length[j]);
620  }
621  for (j = 0; j < ARRAY_SIZE(io_length); ++j) {
622  bio = m0_be_log_io_be_io(&lio[j]);
623  m0_be_log_store_io_translate(ls, offset + io_offset[j],
624  bio);
625  }
626  for (j = 0; j < ARRAY_SIZE(io_length); ++j) {
628  M0_UT_ASSERT(size == io_length[j]);
629  }
632 
634  rc = m0_be_log_store_io_window(ls, offset, &length);
635  M0_UT_ASSERT(M0_IN(rc, (0, -EINVAL)));
636  M0_UT_ASSERT(ergo(rc == 0, length != 0));
637 
639  }
640  for (i = 0; i < BE_UT_LOG_STORE_IO_NR; ++i) {
641  m0_be_log_io_deallocate(&lio[i]);
642  m0_be_log_io_fini(&lio[i]);
643  }
644  m0_free_aligned(field, field_length, bshift);
645  m0_free(lio_arr);
646  m0_free(lio);
647 }
648 
650 {
652 }
653 
655  bool first_run)
656 {
657  enum m0_be_log_store_io_type io_type;
658  struct m0_be_log_io *lio;
659  struct m0_be_log_io **lio_arr;
660  struct m0_be_log_io *lio_r;
661  struct m0_be_log_io *lio_w;
662  struct m0_be_log_io *lio_w0;
663  unsigned nr;
664  unsigned nr_lio_read = 0;
665  unsigned nr_lio_write;
666  unsigned iter;
667  unsigned iter_r;
668  unsigned iter_w;
669  int i;
670  bool eq;
671 
672  /* number of redundant buffer IOs is the same for read and write */
673  for (i = 0; i < 2; ++i) {
674  io_type = i == 0 ?
676  nr = 0;
677  for (lio = m0_be_log_store_rbuf_io_first(ls, io_type,
678  NULL, &iter);
679  lio != NULL;
680  lio = m0_be_log_store_rbuf_io_next(ls, io_type,
681  NULL, &iter))
682  ++nr;
683  if (i == 0)
684  nr_lio_read = nr;
685  else
686  nr_lio_write = nr;
687  }
688  M0_UT_ASSERT(nr_lio_read == nr_lio_write);
689  M0_UT_ASSERT(nr_lio_read == BE_UT_LOG_STORE_RBUF_NR);
690  /* read and write IOs point to the same place in backing store */
692  NULL, &iter_r);
694  NULL, &iter_w);
695  do {
697  m0_be_log_io_be_io(lio_w));
698  M0_UT_ASSERT(eq);
701  NULL, &iter_r);
704  NULL, &iter_w);
705  } while (lio_r != NULL || lio_w != NULL);
706  M0_UT_ASSERT(lio_r == NULL && lio_w == NULL);
707  /* all write IOs are done from the same place in memory */
708  io_type = M0_BE_LOG_STORE_IO_WRITE;
709  lio_w0 = m0_be_log_store_rbuf_io_first(ls, io_type, NULL, &iter_w);
710  while (1) {
711  lio_w = m0_be_log_store_rbuf_io_next(ls, io_type,
712  NULL, &iter_w);
713  if (lio_w == NULL)
714  break;
716  m0_be_log_io_be_io(lio_w));
717  M0_UT_ASSERT(eq);
718  }
719  /* all read I/Os doesn't intersect in backing storage */
720  M0_ALLOC_ARR(lio_arr, nr_lio_read);
721  M0_UT_ASSERT(lio_arr != NULL);
722  io_type = M0_BE_LOG_STORE_IO_READ;
723  i = 0;
724  for (lio = m0_be_log_store_rbuf_io_first(ls, io_type, NULL, &iter_r);
725  lio != NULL;
726  lio = m0_be_log_store_rbuf_io_next(ls, io_type, NULL, &iter_r)) {
727  lio_arr[i++] = lio;
728  }
729  M0_UT_ASSERT(i == nr_lio_read);
730  be_ut_log_store_io_intersect_check(lio_arr, nr_lio_read);
731  m0_free(lio_arr);
732 }
733 
735 {
737 }
738 
739 /* @todo test rbuf and cbuf intersections on a backing storage */
740 
741 #undef M0_TRACE_SUBSYSTEM
742 
743 /*
744  * Local variables:
745  * c-indentation-style: "K&R"
746  * c-basic-offset: 8
747  * tab-width: 8
748  * fill-column: 80
749  * scroll-step: 1
750  * End:
751  */
752 /*
753  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
754  */
static void be_ut_log_store_stob_domain_fini(struct m0_stob_domain *sdom)
Definition: log_store.c:303
static size_t nr
Definition: dump.c:1505
#define M0_PRE(cond)
M0_INTERNAL void m0_be_log_store_io_discard(struct m0_be_log_store *ls, m0_bindex_t offset, struct m0_be_op *op)
Definition: log_store.c:619
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
M0_INTERNAL m0_bcount_t m0_be_io_size(struct m0_be_io *bio)
Definition: io.c:500
static void be_ut_log_store_length_generate(m0_bcount_t *io_length, unsigned nr, uint64_t *seed)
Definition: log_store.c:510
M0_INTERNAL void m0_be_log_store_close(struct m0_be_log_store *ls)
Definition: log_store.c:586
static void be_ut_log_store_stob_domain_init(struct m0_stob_domain **sdom)
Definition: log_store.c:289
#define m0_strdup(s)
Definition: string.h:43
#define NULL
Definition: misc.h:38
Definition: io.h:230
M0_INTERNAL int m0_be_log_store_open(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
Definition: log_store.c:569
char * lsc_stob_domain_location
Definition: log_store.h:144
#define ergo(a, b)
Definition: misc.h:293
static void be_ut_log_store_test(void(*func)(struct m0_be_log_store *ls, bool first_run))
Definition: log_store.c:413
#define M0_LOG(level,...)
Definition: trace.h:167
static void be_ut_log_store_io_translate(struct m0_be_log_store *ls, bool first_run)
Definition: log_store.c:550
M0_INTERNAL const struct m0_fid * m0_stob_domain_id_get(const struct m0_stob_domain *dom)
Definition: domain.c:300
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
Definition: domain.c:227
#define M0_BE_OP_SYNC(op_obj, action)
Definition: op.h:190
M0_INTERNAL void m0_free_aligned(void *data, size_t size, unsigned shift)
Definition: memory.c:192
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
#define M0_SET0(obj)
Definition: misc.h:64
#define BE_UT_LOG_STORE_SDOM_INIT_CFG
Definition: log_store.c:268
Definition: sock.c:887
const char * location
Definition: storage.c:50
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_first(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
Definition: log_store.c:692
M0_INTERNAL uint64_t m0_round_down(uint64_t val, uint64_t size)
Definition: misc.c:187
uint64_t lsc_stob_domain_key
Definition: log_store.h:161
op
Definition: libdemo.c:64
M0_INTERNAL struct m0_be_io * m0_be_log_io_be_io(struct m0_be_log_io *lio)
Definition: log_sched.c:164
M0_INTERNAL void m0_be_io_configure(struct m0_be_io *bio, enum m0_stob_io_opcode opcode)
Definition: io.c:516
static void be_ut_log_store_io_intersect_check(struct m0_be_log_io **lio, unsigned nr)
Definition: log_store.c:532
M0_INTERNAL void m0_be_log_store_io_translate(struct m0_be_log_store *ls, m0_bindex_t position, struct m0_be_io *bio)
Definition: log_store.c:637
int i
Definition: dir.c:1033
M0_INTERNAL struct m0_stob * m0_ut_stob_linux_get(void)
Definition: stob.c:169
M0_INTERNAL void m0_be_io_add_nostob(struct m0_be_io *bio, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
Definition: io.c:313
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 void m0_be_io_fini(struct m0_be_io *bio)
Definition: io.c:224
#define M0_SET_ARR0(arr)
Definition: misc.h:72
Definition: stob.h:163
static struct m0_stob * stob
Definition: storage.c:39
#define M0_ASSERT(cond)
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
Definition: parser.c:84
M0_INTERNAL void m0_be_io_credit_add(struct m0_be_io_credit *iocred0, const struct m0_be_io_credit *iocred1)
Definition: io.c:779
M0_INTERNAL void m0_be_log_io_deallocate(struct m0_be_log_io *lio)
Definition: log_sched.c:150
M0_INTERNAL struct m0_be_log_io * m0_be_log_store_rbuf_io_next(struct m0_be_log_store *ls, enum m0_be_log_store_io_type io_type, struct m0_be_op **op, unsigned *iter)
Definition: log_store.c:702
M0_INTERNAL bool m0_be_io_offset_stob_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:764
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
static void be_ut_log_store_io_discard(struct m0_be_log_store *ls, bool first_run)
Definition: log_store.c:479
M0_INTERNAL int m0_be_io_init(struct m0_be_io *bio)
Definition: io.c:175
static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
Definition: ut.c:654
M0_INTERNAL bool m0_be_io_intersect(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:732
void m0_be_ut_log_store_io_discard(void)
Definition: log_store.c:499
static m0_bindex_t offset
Definition: dump.c:173
void m0_be_ut_log_store_create_random(void)
Definition: log_store.c:372
static void be_ut_log_store_io_window(struct m0_be_log_store *ls, bool first_run)
Definition: log_store.c:447
void m0_be_ut_log_store_rbuf(void)
Definition: log_store.c:734
#define M0_BE_IO_CREDIT(reg_nr, reg_size, part_nr)
Definition: io.h:76
static uint64_t data_size(const struct m0_pdclust_layout *play)
Definition: file.c:550
M0_INTERNAL void m0_ut_stob_put(struct m0_stob *stob, bool destroy)
Definition: stob.c:185
static int used
Definition: base.c:304
static void be_ut_log_store_rbuf(struct m0_be_log_store *ls, bool first_run)
Definition: log_store.c:654
static const char * be_ut_log_store_sdom_create_cfg
Definition: log_store.c:273
M0_INTERNAL int m0_be_log_io_allocate(struct m0_be_log_io *lio, struct m0_be_io_credit *iocred, uint32_t log_bshift)
Definition: log_sched.c:114
M0_INTERNAL int m0_stob_domain_destroy_location(const char *location)
Definition: domain.c:242
M0_INTERNAL int m0_be_log_io_init(struct m0_be_log_io *lio)
Definition: log_sched.c:97
void m0_be_ut_log_store_io_translate(void)
Definition: log_store.c:649
M0_INTERNAL bool m0_be_io_ptr_user_is_eq(const struct m0_be_io *bio1, const struct m0_be_io *bio2)
Definition: io.c:748
M0_INTERNAL uint64_t m0_rnd64(uint64_t *seed)
Definition: misc.c:100
M0_INTERNAL int m0_be_io_allocate(struct m0_be_io *bio, struct m0_be_io_credit *iocred)
Definition: io.c:180
static struct m0_be_log_store_cfg be_ut_log_store_cfg
Definition: log_store.c:275
M0_INTERNAL void m0_be_io_deallocate(struct m0_be_io *bio)
Definition: io.c:215
M0_INTERNAL int m0_be_log_store_create(struct m0_be_log_store *ls, struct m0_be_log_store_cfg *ls_cfg)
Definition: log_store.c:575
m0_bcount_t size
Definition: di.c:39
Definition: io.h:87
static const char * be_ut_log_store_sdom_init_cfg
Definition: log_store.c:271
M0_INTERNAL void m0_be_log_store_io_credit(struct m0_be_log_store *ls, struct m0_be_io_credit *accum)
Definition: log_store.c:601
static bool ls
Definition: mt.c:44
M0_INTERNAL void * m0_alloc_aligned(size_t size, unsigned shift)
Definition: memory.c:168
Definition: io.h:229
M0_INTERNAL int m0_be_log_store_io_window(struct m0_be_log_store *ls, m0_bindex_t offset, m0_bcount_t *length)
Definition: log_store.c:607
M0_INTERNAL void m0_be_log_io_fini(struct m0_be_log_io *lio)
Definition: log_sched.c:102
m0_be_log_store_io_type
Definition: log_store.h:125
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL void m0_be_io_add(struct m0_be_io *bio, struct m0_stob *stob, void *ptr_user, m0_bindex_t offset_stob, m0_bcount_t size)
Definition: io.c:280
M0_INTERNAL void m0_be_io_launch(struct m0_be_io *bio, struct m0_be_op *op)
Definition: io.c:599
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
M0_INTERNAL void m0_be_log_store_destroy(struct m0_be_log_store *ls)
Definition: log_store.c:581
#define M0_UT_ASSERT(a)
Definition: ut.h:46
static const char * be_ut_log_store_sdom_location
Definition: log_store.c:270
void m0_be_ut_log_store_create_simple(void)
Definition: log_store.c:311
M0_INTERNAL void m0_be_log_io_reset(struct m0_be_log_io *lio)
Definition: log_sched.c:106
void m0_be_ut_log_store_io_window(void)
Definition: log_store.c:469
struct m0_stob_id lsc_stob_id
Definition: log_store.h:135
static struct m0_stob_domain * sdom
Definition: reqh_fom_ut.c:73
M0_INTERNAL uint32_t m0_be_log_store_bshift(struct m0_be_log_store *ls)
Definition: log_store.c:591