Motr  M0
io.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-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 #define UT
23 
24 #include "lib/finject.h"
25 #include "layout/layout.h"
26 
27 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT
28 #include "lib/trace.h" /* M0_LOG */
29 #include "lib/uuid.h" /* m0_uuid_generate */
30 
31 #include "ut/ut.h" /* M0_UT_ASSERT */
32 #include "motr/ut/client.h"
33 
34 /*
35  * Including the c files so we can replace the M0_PRE asserts
36  * in order to test them.
37  */
38 #if defined(round_down)
39 #undef round_down
40 #endif
41 #if defined(round_up)
42 #undef round_up
43 #endif
44 #include "motr/io.c"
45 #include "motr/utils.c"
46 
47 #include "layout/layout_internal.h" /* REMOVE ME */
48 
49 static struct m0_client *dummy_instance;
52 
53 #define DUMMY_PTR 0xdeafdead
54 
55 #define UT_DEFAULT_BLOCK_SIZE (1ULL << M0_DEFAULT_BUF_SHIFT)
56 
61 {
62  /* The value of addr is irrelevant */
63  uint64_t addr = (uint64_t)DUMMY_PTR;
64  bool aligned;
65 
66  /* Base cases. */
67  addr |= M0_NETBUF_MASK;
68  aligned = addr_is_network_aligned((void *)addr);
69  M0_UT_ASSERT(aligned == false);
70 
71  addr &= ~M0_NETBUF_MASK;
72  aligned = addr_is_network_aligned((void *)addr);
73  M0_UT_ASSERT(aligned == true);
74 }
75 
76 /*
77  * Tests m0__page_size().
78  */
79 static void ut_test_page_size(void)
80 {
81  struct m0_op_io *ioo;
82  struct m0_obj obj;
83  uint64_t bs;
84 
85  /* Init. */
86  M0_ALLOC_PTR(ioo);
87  ioo->ioo_obj = &obj;
88 
89  /* Base cases. */
90  obj.ob_attr.oa_bshift = 2;
91  bs = m0__page_size(ioo);
92  M0_UT_ASSERT(bs == 1ULL<<2);
93  obj.ob_attr.oa_bshift = 3;
94  bs = m0__page_size(ioo);
95  M0_UT_ASSERT(bs == 1ULL<<3);
96  obj.ob_attr.oa_bshift = 13;
97  bs = m0__page_size(ioo);
98  M0_UT_ASSERT(bs == 1ULL<<13);
99  obj.ob_attr.oa_bshift = 0;
100  bs = m0__page_size(ioo);
101  M0_UT_ASSERT(bs == 1ULL);
102 
103  m0_free(ioo);
104 }
105 
106 /*
107  * Helper function to test page_nr(). ut_test_page_nr() may
108  * invoke this function several times with different combinations of params.
109  */
111  uint64_t exp_pg)
112 {
113  struct m0_obj obj;
114  uint64_t pg;
115 
116  obj.ob_attr.oa_bshift = bshift;
117  pg = page_nr(size, &obj);
118  M0_UT_ASSERT(pg == exp_pg);
119 }
120 
121 /*
122  * Tests page_nr().
123  */
124 static void ut_test_page_nr(void)
125 {
126  /* Base case. Assume M0_MIN_BUF_SHIFT == 9 */
132  /* M0_DEFAULT_BUF_SHIFT == 12 */
133  ut_helper_page_nr(4096, M0_DEFAULT_BUF_SHIFT, 1);
134  ut_helper_page_nr(8192, M0_DEFAULT_BUF_SHIFT, 2);
135 }
136 
137 /*
138  * Tests layout_n().
139  */
140 static void ut_test_layout_n(void)
141 {
142  struct m0_pdclust_layout play;
143  uint32_t n;
144 
145  /* Base case. */
146  play.pl_attr.pa_N = 777;
147  n = layout_n(&play);
148  M0_UT_ASSERT(n == 777);
149  play.pl_attr.pa_N = 0;
150  n = layout_n(&play);
151  M0_UT_ASSERT(n == 0);
152 }
153 
154 /*
155  * Tests layout_k().
156  */
157 static void ut_test_layout_k(void)
158 {
159  struct m0_pdclust_layout play;
160  uint32_t k;
161 
162  /* Base case. */
163  play.pl_attr.pa_K = 777;
164  k = layout_k(&play);
165  M0_UT_ASSERT(k == 777);
166  play.pl_attr.pa_K = 0;
167  k = layout_k(&play);
168  M0_UT_ASSERT(k == 0);
169 }
170 
171 /*
172  * Helper function for ut_test_page_id().
173  */
175  uint64_t exp_pg)
176 {
177  struct m0_obj obj;
178  uint64_t pg;
179 
180  obj.ob_attr.oa_bshift = bshift;
181  pg = page_id(offset, &obj);
182  M0_UT_ASSERT(pg == exp_pg);
183 }
184 
185 /*
186  * Tests page_id().
187  */
188 static void ut_test_page_id(void)
189 {
190  /* Base case. Assume M0_MIN_BUF_SHIFT == 9 */
196  /* M0_DEFAULT_BUF_SHIFT == 12 */
197  ut_helper_page_id(4096, M0_DEFAULT_BUF_SHIFT, 1);
198  ut_helper_page_id(8192, M0_DEFAULT_BUF_SHIFT, 2);
199 }
200 
201 /*
202  * Tests layout_unit_size().
203  */
204 static void ut_test_layout_unit_size(void)
205 {
206  struct m0_pdclust_layout play;
207  uint64_t size;
208 
209  /* Base case. */
210  play.pl_attr.pa_unit_size = 777;
211  size = layout_unit_size(&play);
212  M0_UT_ASSERT(size == 777);
213  play.pl_attr.pa_unit_size = 0;
214  size = layout_unit_size(&play);
215  M0_UT_ASSERT(size == 0);
216 }
217 
218 /*
219  * Helper function for ut_test_rows_nr().
220  */
221 static void ut_helper_rows_nr(uint64_t size, m0_bcount_t bshift,
222  uint64_t exp_row_nr)
223 {
224  struct m0_pdclust_layout play;
225  struct m0_obj obj;
226  uint32_t row_nr;
227 
228  play.pl_attr.pa_unit_size = size;
229  obj.ob_attr.oa_bshift = bshift;
230  row_nr = rows_nr(&play, &obj);
231  M0_UT_ASSERT(row_nr == exp_row_nr);
232 }
233 
234 /*
235  * Tests rows_nr().
236  */
237 static void ut_test_rows_nr(void)
238 {
239  struct m0_pdclust_layout play;
240  struct m0_obj obj;
241 
242  /* Keep gcc quiet during debug build */
243  M0_SET0(&obj);
244  M0_SET0(&play);
245 
246  /* Base case. */
253 }
254 
258 static void ut_test_data_size(void)
259 {
260  struct m0_pdclust_layout play;
261  uint64_t ds;
262 
263  /* Base case */
264  play.pl_attr.pa_N = 2;
265  play.pl_attr.pa_unit_size = 7;
266  ds = data_size(&play);
267  M0_UT_ASSERT(ds == 14);
268 }
269 
273 static void ut_test_pdlayout_instance(void)
274 {
275  struct m0_pdclust_layout *pdl;
276  struct m0_pdclust_instance *pdi;
277 
278  /* Base case */
279  pdl = dummy_pdclust_layout;
281  pdlayout_instance(&pdi->pi_base);
282 }
283 
287 static void ut_test_layout_instance(void)
288 {
289  struct m0_op_io ioo;
290  struct m0_layout_instance linstance;
291  struct m0_layout_instance *lins;
292 
293  /* Base case. */
294  ioo.ioo_oo.oo_layout_instance = &linstance;
295  lins = layout_instance(&ioo);
296  M0_UT_ASSERT(lins == &linstance);
297 }
298 
302 static void ut_test_target_fid(void)
303 {
304 }
305 
309 static void ut_test_target_offset(void)
310 {
311  struct m0_pdclust_layout play;
312  uint64_t offset;
313 
314  /* Base cases. */
315  play.pl_attr.pa_unit_size = 10;
316  offset = target_offset(2, &play, 0);
317  M0_UT_ASSERT(offset == 20);
318  offset = target_offset(2, &play, 3);
319  M0_UT_ASSERT(offset == 23);
320  offset = target_offset(2, &play, 14);
321  M0_UT_ASSERT(offset == 24);
322 }
323 
327 static void ut_test_group_id(void)
328 {
329  uint64_t id;
330 
331  /* Base cases. */
332  id = group_id(8, 3);
333  M0_UT_ASSERT(id == 2);
334  id = group_id(9, 3);
335  M0_UT_ASSERT(id == 3);
336  id = group_id(0, 3);
337  M0_UT_ASSERT(id == 0);
338 }
339 
343 static void ut_test_seg_endpos(void)
344 {
345  struct m0_indexvec ivec;
346  m0_bcount_t pos;
347 
348  /* Base case. */
349  M0_ALLOC_ARR(ivec.iv_index, 1);
350  M0_ALLOC_ARR(ivec.iv_vec.v_count, 1);
351  ivec.iv_index[0] = 7;
352  ivec.iv_vec.v_count[0] = 13;
353  pos = seg_endpos(&ivec, 0);
354  M0_UT_ASSERT(pos == 20);
355 
356  m0_free(ivec.iv_index);
357  m0_free(ivec.iv_vec.v_count);
358 }
359 
360 static void ut_test_indexvec_page_nr(void)
361 {
362 }
363 
364 static void ut_test_iomap_page_nr(void)
365 {
366 }
367 
372 {
373  struct m0_pdclust_layout play;
374  struct m0_obj obj;
375  uint64_t pn;
376 
377  /* Base case. */
378  play.pl_attr.pa_unit_size = 2 * 512;
379  play.pl_attr.pa_K = 3;
380  obj.ob_attr.oa_bshift = M0_MIN_BUF_SHIFT;
381  pn = parity_units_page_nr(&play, &obj);
382  M0_UT_ASSERT(pn == 6);
383 }
384 
388 static void ut_test_round_down(void)
389 {
390  uint64_t ret;
391 
392  /* Base case. */
393  ret = round_down(777, 64);
394  M0_UT_ASSERT(ret == 768);
395  ret = round_down(12345, 512);
396  M0_UT_ASSERT(ret == 12288);
397  ret = round_down(12288, 512);
398  M0_UT_ASSERT(ret == 12288);
399 }
400 
404 static void ut_test_round_up(void)
405 {
406  uint64_t ret;
407 
408  /* Base case. */
409  ret = round_up(777, 64);
410  M0_UT_ASSERT(ret == 832);
411  ret = round_up(12345, 512);
412  M0_UT_ASSERT(ret == 12800);
413  ret = round_up(12800, 512);
414  M0_UT_ASSERT(ret == 12800);
415 }
416 
420 static void ut_test_pdlayout_get(void)
421 {
423  struct m0_op_io *ioo;
424  struct m0_pdclust_layout *pl;
425  struct m0_pdclust_layout *aux;
426 
427  /* init */
428  ioo = ut_dummy_ioo_create(instance, 1);
429 
430  /* Base case. */
432  aux = pdlayout_get(ioo);
433  M0_UT_ASSERT(aux == pl);
434 
435  /* fini */
437 }
438 
442 static void ut_test_page_pos_get(void)
443 {
444 }
445 
449 static void ut_test_io_desc_size(void)
450 {
451 }
452 
456 static void ut_test_io_seg_size(void)
457 {
458  uint32_t size;
459 
460  /* Base case. */
461  size = io_seg_size();
462  M0_UT_ASSERT(size == sizeof(struct m0_ioseg));
463 }
464 
465 static struct m0_reqh_service *ut_service; /* discarded */
472 {
473  struct m0_uint128 uuid;
474  int rc;
475 
477  /* now force it be a service fid */
480  NULL, (struct m0_fid *) &uuid);
481  M0_UT_ASSERT(rc == 0);
482  M0_ALLOC_PTR(instance->m0c_pools_common.pc_rm_ctx);
483 }
484 
489 {
491  m0_free(instance->m0c_pools_common.pc_rm_ctx);
492 }
493 
497 static void ut_test_rm_domain_get(void)
498 {
499  struct m0_rm_domain *dom;
501 
502  /* Base case. */
504  M0_UT_ASSERT(dom != NULL);
505 }
506 
510 static int ut_mock_io_launch_prepare(struct m0_op_io *ioo)
511 {
512  return 0;
513 }
514 
518 static int
520 {
521  return 0; // -1; /* if we don't want obj_io_cb_launch do the ast */
522 }
523 
525  struct m0_sm_ast *ast)
526 {
527  return;
528 }
529 
533 static void ut_test_obj_io_cb_launch(void)
534 {
535  struct m0_op_common *oc;
536  struct m0_op_io *ioo;
538  struct m0_realm realm;
539  struct nw_xfer_ops *nxr_ops;
540  struct m0_op_io_ops *op_io_ops;
541 
542  /* Base case. */
543  ioo = ut_dummy_ioo_create(instance, 1);
545  instance);
546  oc = &ioo->ioo_oo.oo_oc;
547 
548  /* Base case. Set different callbacks. */
549  M0_ALLOC_PTR(op_io_ops);
550  op_io_ops->iro_iomaps_prepare =
552  op_io_ops->iro_iosm_handle_launch =
554  ioo->ioo_ops = op_io_ops;
555 
556  M0_ALLOC_PTR(nxr_ops);
558  ioo->ioo_nwxfer.nxr_ops = nxr_ops;
559 
560  obj_io_cb_launch(oc);
561 
562  /* The CB should be enqueued by now. Force its execution. */
565 
566  m0_free(nxr_ops);
567  m0_free(op_io_ops);
570 }
571 
572 static void ut_test_obj_io_ast_fini(void)
573 {
574 }
575 
576 static void ut_test_obj_io_cb_fini(void)
577 {
578 }
579 
583 static void ut_test_m0_op_io_invariant(void)
584 {
585  struct m0_op_io *ioo;
587  bool ret;
588 
589  //ut_layout_domain_fill(instance);
590 
591  /* Base case. */
592  ioo = ut_dummy_ioo_create(instance, 1);
593  ret = m0_op_io_invariant(ioo);
594  M0_UT_ASSERT(ret == true);
596 
597  /* Finalise client. */
598  //ut_layout_domain_empty(instance);
599 }
600 
607 static void ut_helper_sort_init(struct m0_indexvec *ivec, uint32_t *arr,
608  uint32_t len)
609 {
610  uint32_t i;
611  for (i = 0; i < len; ++i) {
612  INDEX(ivec, i) = arr[i];
613  COUNT(ivec, i) = arr[i];
614  }
615 }
616 
623 static bool ut_helper_sort_is_sorted(struct m0_indexvec *ivec)
624 {
625  uint32_t i;
626  m0_bindex_t prev_ind = 0;
627 
628  for (i = 0; i < SEG_NR(ivec); ++i) {
629  if (prev_ind > INDEX(ivec, i))
630  return false;
631  prev_ind = INDEX(ivec, i);
632  }
633  return true;
634 }
635 
644 static void ut_helper_sort(struct m0_indexvec *ivec, uint32_t *arr, uint32_t len)
645 {
646  struct m0_bufvec bvec;
647  struct m0_bufvec bvec_attr;
648 
649  M0_UT_ASSERT(m0_bufvec_alloc(&bvec, len, 1) == 0);
650  M0_UT_ASSERT(m0_bufvec_alloc(&bvec_attr, len, 1) == 0);
651 
652  ut_helper_sort_init(ivec, arr, len);
653  segments_sort(ivec, &bvec, &bvec_attr);
655 
657  m0_bufvec_free(&bvec_attr);
658 }
659 
663 static void ut_test_segments_sort(void)
664 {
665  struct m0_indexvec ext;
666  int rc;
667 
668  uint32_t vecs[3][10] = { {1, 9, 8, 7, 2, 3, 4, 6, 5, 10},
669  {10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
670  {1, 400, 34, 399, 2, 33, 13, 14, 1, 10}};
671 
672  /* Base case. */
673  rc = m0_indexvec_alloc(&ext, 10);
674  M0_UT_ASSERT(rc == 0);
675  ut_helper_sort(&ext, vecs[0], 10);
676  ut_helper_sort(&ext, vecs[1], 10);
677  ut_helper_sort(&ext, vecs[2], 10);
678  m0_indexvec_free(&ext);
679 }
680 
684 static void ut_test_obj_io_cb_free(void)
685 {
686  struct m0_op_io *ioo;
687 
688  /* Base case. */
689  M0_ALLOC_PTR(ioo);
690  ioo->ioo_oo.oo_oc.oc_op.op_size = sizeof *ioo;
691  obj_io_cb_free(&ioo->ioo_oo.oo_oc);
692 }
693 
697 static void ut_test_m0_obj_op(void)
698 {
699  int rc;
700  struct m0_obj obj;
701  struct m0_realm realm;
702  struct m0_indexvec ext;
703  struct m0_bufvec data;
704  struct m0_bufvec attr;
705  struct m0_op *op = NULL;
707  struct m0_op_io *ioop;
708 
709  /* auxiliary structs */
710  rc = m0_indexvec_alloc(&ext, 1);
711  M0_UT_ASSERT(rc == 0);
712  ext.iv_vec.v_count[0] = 512;
713  rc = m0_bufvec_alloc(&data, 1, 512);
714  M0_UT_ASSERT(rc == 0);
715  rc = m0_bufvec_alloc(&attr, 1, 1);
716  M0_UT_ASSERT(rc == 0);
717 
718  M0_SET0(&obj);
719  ut_realm_entity_setup(&realm, &obj.ob_entity, instance);
720  obj.ob_attr.oa_bshift = M0_MIN_BUF_SHIFT;
721  obj.ob_attr.oa_pver = instance->m0c_pools_common.pc_cur_pver->pv_id;
722 
723  m0_fi_enable_once("m0__obj_layout_id_get", "fake_obj_layout_id");
724  m0_fi_enable("tolerance_of_level", "fake_tolerance_of_level");
725 
726  /* Base case: no assert for READ */
727  rc = m0_obj_op(&obj, M0_OC_READ, &ext, &data, &attr, 0, 0, &op);
728  M0_UT_ASSERT(rc == 0);
729  M0_UT_ASSERT(op->op_size >= sizeof *ioop);
730 
731  m0_fi_disable("tolerance_of_level", "fake_tolerance_of_level");
732 
733  /* XXX container_of || bob_of */
734  ioop = (struct m0_op_io *)op;
735  m0_op_io_bob_init(ioop);
736  m0_op_obj_bob_init(&ioop->ioo_oo);
737  m0_op_common_bob_init(&ioop->ioo_oo.oo_oc);
738  m0_op_bob_init(&ioop->ioo_oo.oo_oc.oc_op);
739 
740  M0_UT_ASSERT(op->op_code == M0_OC_READ);
744  M0_UT_ASSERT(ioop->ioo_obj == &obj);
745  M0_UT_ASSERT(ioop->ioo_attr_mask == 0);
746 
747  m0_op_fini(op);
748  m0_op_free(op);
749 
750  /* Free the {index,buf}vec that we have used for these tests. */
753  m0_indexvec_free(&ext);
754 
755  m0_entity_fini(&obj.ob_entity);
756 }
757 
758 M0_INTERNAL int m0_io_ut_init(void)
759 {
760  int rc;
761 
762 #ifndef __KERNEL__
764 #endif
765 
767 
769  M0_UT_ASSERT(rc == 0);
770 
774 
776 
777  return 0;
778 }
779 
780 M0_INTERNAL int m0_io_ut_fini(void)
781 {
785 
786  return 0;
787 }
788 
789 struct m0_ut_suite ut_suite_io = {
790  .ts_name = "io-ut",
791  .ts_init = m0_io_ut_init,
792  .ts_fini = m0_io_ut_fini,
793  .ts_tests = {
794 
795  { "addr_is_network_aligned",
797  { "page_size",
799  { "test_page_nr",
800  &ut_test_page_nr},
801  { "layout_n",
803  { "layout_k",
805  { "page_id",
806  &ut_test_page_id},
807  { "layout_unit_size",
809  { "rows_nr",
810  &ut_test_rows_nr},
811  { "data_size",
813  { "pdlayout_instance",
815  { "layout_instance",
817  { "target_fid",
819  { "target_offset",
821  { "group_id",
823  { "seg_endpos",
825  { "indexvec_page_nr",
827  { "iomap_page_nr",
829  { "parity_units_page_nr",
831  { "round_down",
833  { "round_up",
835  { "pdlayout_get",
837  { "page_pos_get",
839  { "io_desc_size",
841  { "io_seg_size",
843  { "rm_domain_get",
845  { "obj_io_cb_launch",
847  { "obj_io_ast_fini",
849  { "obj_io_cb_fini",
851  { "m0_op_io_invariant",
853  { "segments_sort",
855  { "obj_io_cb_free",
857  { "m0_obj_op",
859  { NULL, NULL },
860  }
861 };
862 
863 #undef M0_TRACE_SUBSYSTEM
864 
865 /*
866  * Local variables:
867  * c-indentation-style: "K&R"
868  * c-basic-offset: 8
869  * tab-width: 8
870  * fill-column: 80
871  * scroll-step: 1
872  * End:
873  */
uint64_t id
Definition: cob.h:2380
void ut_layout_domain_empty(struct m0_client *cinst)
Definition: obj.c:218
static void ut_test_layout_unit_size(void)
Definition: io.c:204
void(* iro_iosm_handle_launch)(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: pg.h:613
struct m0_uint128 uuid[1000]
Definition: uuid.c:73
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
M0_INTERNAL int m0_io_ut_fini(void)
Definition: io.c:780
void m0_entity_fini(struct m0_entity *entity)
Definition: client.c:438
#define COUNT(ivec, i)
Definition: file.c:392
Definition: client.h:788
M0_INTERNAL int m0_indexvec_alloc(struct m0_indexvec *ivec, uint32_t len)
Definition: vec.c:532
static int ut_mock_io_launch_prepare(struct m0_op_io *ioo)
Definition: io.c:510
static void ut_test_page_size(void)
Definition: io.c:79
static m0_bcount_t seg_endpos(const struct m0_indexvec *ivec, uint32_t i)
Definition: file.c:420
#define NULL
Definition: misc.h:38
uint64_t pa_unit_size
Definition: pdclust.h:118
static void ut_test_layout_n(void)
Definition: io.c:140
static void obj_io_cb_launch(struct m0_op_common *oc)
Definition: io.c:234
M0_INTERNAL void m0_uuid_generate(struct m0_uint128 *u)
Definition: uuid.c:44
void m0_op_fini(struct m0_op *op)
Definition: client.c:847
uint32_t pa_N
Definition: pdclust.h:104
static struct m0_sm_group * grp
Definition: bytecount.c:38
const struct m0_op_io_ops * ioo_ops
static void ut_test_page_nr(void)
Definition: io.c:124
static void ut_test_m0_op_io_invariant(void)
Definition: io.c:583
const struct m0_conf_obj_type M0_CONF_SERVICE_TYPE
Definition: service.c:156
static uint32_t layout_k(const struct m0_pdclust_layout *play)
Definition: file.c:520
struct m0_sm_group * oo_sm_grp
static void ut_test_layout_k(void)
Definition: io.c:157
struct m0_layout_instance pi_base
Definition: pdclust.h:173
static void ut_test_obj_io_cb_launch(void)
Definition: io.c:533
uint32_t pa_K
Definition: pdclust.h:107
struct m0_bufvec data
Definition: di.c:40
static uint32_t io_seg_size(void)
Definition: file.c:6449
static int ut_mock_io_launch_distribute(struct nw_xfer_request *xfer)
Definition: io.c:519
uint64_t ioo_attr_mask
struct m0_op oc_op
M0_INTERNAL void m0_indexvec_free(struct m0_indexvec *ivec)
Definition: vec.c:553
static void obj_io_cb_free(struct m0_op_common *oc)
Definition: io.c:442
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
static void ut_test_target_offset(void)
Definition: io.c:309
Definition: sm.h:504
void ut_layout_domain_fill(struct m0_client *cinst)
Definition: obj.c:208
static uint64_t round_up(uint64_t val, uint64_t size)
Definition: file.c:711
#define M0_SET0(obj)
Definition: misc.h:64
static void ut_test_addr_is_network_aligned(void)
Definition: io.c:60
Definition: ut.h:77
M0_INTERNAL int ut_m0_client_init(struct m0_client **instance)
Definition: client.c:265
struct m0_pdclust_attr pl_attr
Definition: pdclust.h:150
static struct foo * obj
Definition: tlist.c:302
static struct m0_pdclust_layout * dummy_pdclust_layout
Definition: io.c:50
static void ut_disable_resource_manager(struct m0_client *instance)
Definition: io.c:488
static void ut_test_round_up(void)
Definition: io.c:404
#define SEG_NR(ivec)
Definition: file.c:393
M0_INTERNAL int m0_bufvec_alloc(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size)
Definition: vec.c:220
struct m0_vec iv_vec
Definition: vec.h:139
op
Definition: libdemo.c:64
int m0_obj_op(struct m0_obj *obj, enum m0_obj_opcode opcode, struct m0_indexvec *ext, struct m0_bufvec *data, struct m0_bufvec *attr, uint64_t mask, uint32_t flags, struct m0_op **op)
Definition: io.c:717
static void ut_mock_iosm_handle_launch(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: io.c:524
static struct m0_sm_ast ast[NR]
Definition: locality.c:44
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
Definition: vec.c:395
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
m0_bindex_t * iv_index
Definition: vec.h:141
Definition: vec.h:625
static void ut_test_obj_io_cb_free(void)
Definition: io.c:684
int i
Definition: dir.c:1033
static void ut_test_iomap_page_nr(void)
Definition: io.c:364
size_t op_size
Definition: client.h:664
Definition: client.h:641
M0_INTERNAL void ut_realm_entity_setup(struct m0_realm *realm, struct m0_entity *ent, struct m0_client *cinst)
Definition: client.c:60
static uint32_t rows_nr(struct m0_pdclust_layout *play)
Definition: file.c:691
struct nw_xfer_request ioo_nwxfer
int(* nxo_distribute)(struct nw_xfer_request *xfer)
M0_INTERNAL struct m0_pdclust_instance * ut_dummy_pdclust_instance_create(struct m0_pdclust_layout *pdl)
Definition: io_dummy.c:118
M0_INTERNAL struct m0_pdclust_layout * ut_get_pdclust_layout_from_ioo(struct m0_op_io *ioo)
Definition: io_dummy.c:456
void(* oc_cb_free)(struct m0_op_common *oc)
struct m0_op_obj ioo_oo
static void ut_helper_page_nr(m0_bcount_t size, m0_bcount_t bshift, uint64_t exp_pg)
Definition: io.c:110
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
M0_INTERNAL void ut_dummy_ioo_delete(struct m0_op_io *ioo, struct m0_client *instance)
Definition: io_dummy.c:463
static void ut_test_parity_units_page_nr(void)
Definition: io.c:371
M0_INTERNAL void m0_fi_disable(const char *fp_func, const char *fp_tag)
Definition: finject.c:485
const struct m0_fid_type cot_ftype
Definition: obj.h:314
static void m0_fi_enable(const char *func, const char *tag)
Definition: finject.h:276
M0_INTERNAL bool m0_op_io_invariant(const struct m0_op_io *ioo)
Definition: io.c:161
static uint64_t page_nr(m0_bcount_t size)
Definition: file.c:492
static uint64_t page_id(m0_bindex_t offset)
Definition: file.c:686
M0_INTERNAL void m0_reqh_service_quit(struct m0_reqh_service *svc)
Definition: reqh_service.c:588
M0_INTERNAL void ut_m0_client_fini(struct m0_client **instance)
Definition: client.c:354
struct m0_ut_suite ut_suite_io
Definition: io.c:51
static void ut_test_round_down(void)
Definition: io.c:388
static struct m0_pdclust_instance * pdlayout_instance(const struct m0_layout_instance *li)
Definition: file.c:504
const struct nw_xfer_ops * nxr_ops
static struct m0_bufvec bvec
Definition: xcode.c:169
static struct m0_stob_domain * dom
Definition: storage.c:38
static void ut_test_layout_instance(void)
Definition: io.c:287
struct m0_obj * ioo_obj
static void ut_test_seg_endpos(void)
Definition: io.c:343
static uint64_t layout_unit_size(const struct m0_pdclust_layout *play)
Definition: file.c:525
M0_INTERNAL struct m0_rm_domain * rm_domain_get(struct m0_client *cinst)
Definition: io.c:59
M0_INTERNAL void ut_shuffle_test_order(struct m0_ut_suite *suite)
Definition: client.c:1205
static void ut_test_rm_domain_get(void)
Definition: io.c:497
Definition: xcode.h:73
M0_INTERNAL int m0_io_ut_init(void)
Definition: io.c:758
M0_INTERNAL void m0_client_init_io_op(void)
Definition: io.c:815
static m0_bindex_t offset
Definition: dump.c:173
void(* oc_cb_fini)(struct m0_op_common *oc)
m0_bcount_t * v_count
Definition: vec.h:53
M0_INTERNAL int m0_reqh_service_setup(struct m0_reqh_service **out, struct m0_reqh_service_type *stype, struct m0_reqh *reqh, struct m0_reqh_context *rctx, const struct m0_fid *fid)
Definition: reqh_service.c:565
struct m0_op_common oo_oc
static void obj_io_cb_fini(struct m0_op_common *oc)
Definition: io.c:395
static uint64_t data_size(const struct m0_pdclust_layout *play)
Definition: file.c:550
M0_INTERNAL bool addr_is_network_aligned(void *addr)
Definition: utils.c:29
static uint64_t round_down(uint64_t val, uint64_t size)
Definition: file.c:697
static void ut_helper_sort_init(struct m0_indexvec *ivec, uint32_t *arr, uint32_t len)
Definition: io.c:607
static uint32_t layout_n(const struct m0_pdclust_layout *play)
Definition: file.c:515
static struct m0_pdclust_layout * pdlayout_get(const struct io_request *req)
Definition: file.c:510
static void ut_test_pdlayout_instance(void)
Definition: io.c:273
struct m0_reqh_service_type m0_rms_type
Definition: rm_service.c:69
const char * ts_name
Definition: ut.h:99
static void ut_helper_page_id(m0_bindex_t offset, m0_bcount_t bshift, uint64_t exp_pg)
Definition: io.c:174
uint64_t n
Definition: fops.h:107
M0_INTERNAL struct m0_pdclust_layout * ut_dummy_pdclust_layout_create(struct m0_client *instance)
Definition: io_dummy.c:79
static void segments_sort(struct m0_indexvec *ivec, struct m0_bufvec *data, struct m0_bufvec *attr)
Definition: io.c:124
M0_INTERNAL struct m0_op_io * ut_dummy_ioo_create(struct m0_client *instance, int num_io_maps)
Definition: io_dummy.c:366
Definition: fid.h:38
static void ut_test_m0_obj_op(void)
Definition: io.c:697
static void ut_test_target_fid(void)
Definition: io.c:302
static void ut_test_obj_io_cb_fini(void)
Definition: io.c:576
static struct m0_layout_instance * layout_instance(const struct io_request *req)
Definition: file.c:498
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static void ut_test_pdlayout_get(void)
Definition: io.c:420
static struct m0_realm realm
Definition: sync.c:87
struct m0_entity * op_entity
Definition: client.h:660
m0_bcount_t size
Definition: di.c:39
static uint64_t parity_units_page_nr(const struct m0_pdclust_layout *play)
Definition: file.c:530
static void ut_test_data_size(void)
Definition: io.c:258
int(* iro_iomaps_prepare)(struct m0_op_io *ioo)
Definition: pg.h:567
static struct m0 instance
Definition: main.c:78
static void ut_test_io_desc_size(void)
Definition: io.c:449
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
static void ut_test_page_id(void)
Definition: io.c:188
static void m0_fi_enable_once(const char *func, const char *tag)
Definition: finject.h:301
static uint64_t group_id(m0_bindex_t index, m0_bcount_t dtsize)
Definition: file.c:560
static void ut_test_indexvec_page_nr(void)
Definition: io.c:360
static void ut_test_segments_sort(void)
Definition: io.c:663
static bool ut_helper_sort_is_sorted(struct m0_indexvec *ivec)
Definition: io.c:623
static void ut_helper_sort(struct m0_indexvec *ivec, uint32_t *arr, uint32_t len)
Definition: io.c:644
static struct m0_reqh_service * ut_service
Definition: io.c:465
void m0_op_free(struct m0_op *op)
Definition: client.c:885
M0_INTERNAL uint64_t m0__page_size(const struct m0_op_io *ioo)
Definition: utils.c:41
struct m0_layout_instance * oo_layout_instance
static void ut_enable_resource_manager(struct m0_client *instance)
Definition: io.c:471
void(* oc_cb_launch)(struct m0_op_common *oc)
static void ut_test_rows_nr(void)
Definition: io.c:237
static void ut_test_obj_io_ast_fini(void)
Definition: io.c:572
void m0_free(void *data)
Definition: memory.c:146
static void ut_test_page_pos_get(void)
Definition: io.c:442
static void ut_test_group_id(void)
Definition: io.c:327
static int ds
Definition: pool_trigger.c:54
int32_t rc
Definition: trigger_fop.h:47
static struct m0_client * dummy_instance
Definition: io.c:49
#define M0_UT_ASSERT(a)
Definition: ut.h:46
static uint64_t target_offset(uint64_t frame, struct m0_pdclust_layout *play, m0_bindex_t gob_offset)
Definition: file.c:571
#define DUMMY_PTR
Definition: io.c:53
Definition: vec.h:145
static void ut_helper_rows_nr(uint64_t size, m0_bcount_t bshift, uint64_t exp_row_nr)
Definition: io.c:221
static void ut_test_io_seg_size(void)
Definition: io.c:456
M0_INTERNAL void m0_fid_tassume(struct m0_fid *fid, const struct m0_fid_type *ft)
Definition: fid.c:146