Motr  M0
obj.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 
23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT
24 #include "lib/trace.h"
25 
26 #include "layout/layout.h"
27 #include "pool/pool.h"
28 
29 #include "ut/ut.h" /* M0_UT_ASSERT */
30 #include "motr/ut/client.h"
31 
32 /*
33  * Including the c files so we can replace the M0_PRE asserts
34  * in order to test them.
35  */
36 #include "motr/cob.c"
37 #include "motr/obj.c"
38 
39 /*
40  * We need to initialise the default layout domain.
41  */
42 static int t_register(struct m0_layout_domain *dom,
43  const struct m0_layout_type *lt)
44 {
45  return 0;
46 }
47 
48 static void t_unregister(struct m0_layout_domain *dom,
49  const struct m0_layout_type *lt)
50 {
51 }
52 
54 {
55  return 0;
56 }
57 
58 static const struct m0_layout_type_ops ut_layout_type_ops = {
60  .lto_unregister = t_unregister,
61  .lto_max_recsize = t_max_recsize
62 };
63 static struct m0_layout_type ut_layout_type = {
64  .lt_name = "test",
65  .lt_id = M0_DEFAULT_LAYOUT_ID,
66  .lt_ops = &ut_layout_type_ops
67 };
68 static struct m0_layout ut_layout;
69 
70 /* XXX export? */
71 struct m0_fid ut_fid;
72 static void
73 ut_layout_enum_get(const struct m0_layout_enum *e, uint32_t idx,
74  const struct m0_fid *gfid, struct m0_fid *out)
75 {
76  m0_fid_gob_make(&ut_fid, 0, 1);
78 }
79 
80 static uint32_t ut_layout_nr(const struct m0_layout_enum *e)
81 {
82  /* ut_layout_enum_get() returns always the same single id */
83  return M0T1FS_LAYOUT_P;
84 }
85 
88  .leo_nr = &ut_layout_nr,
89 };
91 
93 
94 static struct m0_layout_enum *
96 {
99  return &ut_layout_enum;
100 }
101 
102 static void ut_lio_fini(struct m0_layout_instance *li)
103 {
104 }
105 
108  .lio_fini = ut_lio_fini,
109 };
110 
112 static int ut_m0_ops_instance_build(struct m0_layout *layout,
113  const struct m0_fid *fid,
114  struct m0_layout_instance **linst)
115 {
116  struct m0_fid valid_fid;
117 
118  m0_fid_gob_make(&valid_fid, 0, 1);
119  ut_layout_instance.li_gfid = valid_fid;
120  ut_layout_instance.li_l = layout;
121  *linst = &ut_layout_instance;
122  return 0;
123 }
124 
125 void ut_m0_ops_fini(struct m0_ref *ref)
126 {
127 
128 }
129 
130 static struct m0_layout_ops ut_layout_ops = {
132  .lo_fini = ut_m0_ops_fini,
133 };
134 
135 /* Imports */
136 M0_INTERNAL void m0_layout__init(struct m0_layout *l,
137  struct m0_layout_domain *dom,
138  uint64_t lid,
139  struct m0_layout_type *lt,
140  const struct m0_layout_ops *ops);
141 M0_INTERNAL void m0_layout__populate(struct m0_layout *l, uint32_t user_count);
142 static const struct m0_bob_type enum_bob = {
143  .bt_name = "enum",
144  .bt_magix_offset = offsetof(struct m0_layout_enum, le_magic),
145  .bt_magix = M0_LAYOUT_ENUM_MAGIC,
146  .bt_check = NULL
147 };
148 M0_BOB_DEFINE(M0_INTERNAL, &enum_bob, m0_layout_enum);
149 
150 static const struct m0_bob_type layout_instance_bob = {
151  .bt_name = "layout_instance",
152  .bt_magix_offset = offsetof(struct m0_layout_instance, li_magic),
153  .bt_magix = M0_LAYOUT_INSTANCE_MAGIC,
154  .bt_check = NULL
155 };
157 
158 M0_INTERNAL void
159 ut_layout_init(struct m0_layout *layout,
160  struct m0_layout_domain *dom)
161 {
162  uint64_t layout_id;
163  struct m0_pool_version pv;
164 
165  /* Workaround: fill just the necessary stuff for motr to not complain. */
169  m0_layout_instance_bob_init(&ut_layout_instance);
170  m0_layout_enum_bob_init(&ut_layout_enum);
171 
172  M0_SET0(&pv);
173  layout_id = m0_pool_version2layout_id(&pv.pv_id, M0_DEFAULT_LAYOUT_ID);
174  m0_layout__init(layout, dom, layout_id,
176  m0_layout__populate(layout, 1);
177 }
178 
179 M0_INTERNAL void
181  struct m0_layout_domain *dom)
182 {
183  ut_layout_init(&stl->sl_base, dom);
184  stl->sl_enum = &ut_layout_enum;
187 }
188 
189 static void ut_layout_fini(struct m0_layout *l,
190  struct m0_layout_domain *dom)
191 {
192  m0_layout_put(l);
193 
194  m0_layout_enum_bob_fini(&ut_layout_enum);
195  m0_layout_instance_bob_fini(&ut_layout_instance);
199 }
200 
201 M0_INTERNAL void
203  struct m0_layout_domain *dom)
204 {
205  ut_layout_fini(&stl->sl_base, dom);
206 }
207 
209 {
210  int rc;
211  struct m0_layout_domain *dom;
212 
215  M0_UT_ASSERT(rc == 0);
216 }
217 
219 {
220  struct m0_layout_domain *dom;
221 
222  M0_UT_ASSERT(cinst != NULL);
224  M0_UT_ASSERT(dom != NULL);
225 
226  /* Cleanup all layouts in this domain */
228 
229  /* Then safely un-register our own layout type */
231 }
232 
233 /**********
234  * UTs
235  **********/
236 
241 {
242  struct m0_op_obj *oo;
243  bool rc;
244 
245  /* Base cases. */
246  M0_ALLOC_PTR(oo);
247  m0_op_obj_bob_init(oo);
248  m0_ast_rc_bob_init(&oo->oo_ar);
249  m0_op_common_bob_init(&oo->oo_oc);
250  oo->oo_oc.oc_op.op_size = sizeof *oo;
251  rc = m0_op_obj_invariant(oo);
252  M0_UT_ASSERT(rc == true);
253 
255  M0_UT_ASSERT(rc == false);
256 
257  oo->oo_oc.oc_op.op_size = sizeof *oo - 1;
258  rc = m0_op_obj_invariant(oo);
259  M0_UT_ASSERT(rc == false);
260 
261  m0_free(oo);
262 }
263 
268 {
269  struct m0_ast_rc *ar;
270  bool rc;
271 
272  /* Base cases. */
273  M0_ALLOC_PTR(ar);
274  m0_ast_rc_bob_init(ar);
276  M0_UT_ASSERT(rc == true);
277 
279  M0_UT_ASSERT(rc == false);
280 
281  m0_ast_rc_bob_fini(ar);
283  M0_UT_ASSERT(rc == false);
284 
285  m0_free(ar);
286 }
287 
291 static void ut_test_cob_req_invariant(void)
292 {
293  struct ios_cob_req *icr;
294  bool rc;
295 
296  /* Base cases. */
297  M0_ALLOC_PTR(icr);
298  ios_cob_req_bob_init(icr);
299  rc = ios_cob_req_invariant(icr);
300  M0_UT_ASSERT(rc == true);
301 
303  M0_UT_ASSERT(rc == false);
304 
305  ios_cob_req_bob_fini(icr);
306  rc = ios_cob_req_invariant(icr);
307  M0_UT_ASSERT(rc == false);
308 
309  m0_free(icr);
310 }
311 
316 {
317  struct m0_op_common *oc;
318  bool rc;
319 
320  /* Base cases. */
321  M0_ALLOC_PTR(oc);
322  m0_op_common_bob_init(oc);
324  M0_UT_ASSERT(rc == true);
325 
327  M0_UT_ASSERT(rc == false);
328 
329  m0_op_common_bob_fini(oc);
331  M0_UT_ASSERT(rc == false);
332 
333  m0_free(oc);
334 }
335 
339 static void
341 {
342  int rc = 0; /* required */
343  uint64_t lid = 0;
344  struct m0_fid fid;
345  struct m0_layout_instance *linst;
346  struct m0_client *instance = NULL;
347  struct m0_pool_version pv;
348 
349  /* init */
351  M0_UT_ASSERT(rc == 0);
353  ut_layout_init(&ut_layout, &instance->m0c_reqh.rh_ldom);
354  M0_SET0(&fid);
355  M0_SET0(&pv);
356 
357  /* base case */
358  fid.f_key = 777;
359  lid = m0_pool_version2layout_id(&pv.pv_id, M0_DEFAULT_LAYOUT_ID);
360  rc = m0__obj_layout_instance_build(instance, lid, &fid, &linst);
361  M0_UT_ASSERT(rc == 0);
362  M0_UT_ASSERT(linst == &ut_layout_instance);
363 
364  /* fini */
365  ut_layout_fini(&ut_layout, &instance->m0c_reqh.rh_ldom);
368 }
369 
373 static void ut_test_m0_fid_print(void)
374 {
375  struct m0_fid fid;
376  char name[M0_FID_STR_LEN];
377  int rc = 0; /* required */
378 
379  /* base case */
380  m0_fid_set(&fid, 0xCAFE, 0xFEED);
381  rc = m0_fid_print(name, sizeof name, &fid);
382  M0_UT_ASSERT(rc > 0);
383  M0_UT_ASSERT(!strcmp(name, "cafe:feed"));
384 }
385 
389 static void ut_test_obj_namei_op_init(void)
390 {
391  int rc = 0; /* required */
392  struct m0_realm realm;
393  struct m0_entity ent;
394  struct m0_op_obj oo;
395  struct m0_client *instance = NULL;
396  struct m0_fid pfid = { .f_container = 0, .f_key = 1 };
397  struct m0_op *op;
398 
399  /* init */
401  M0_UT_ASSERT(rc == 0);
402 
404  ut_layout_init(&ut_layout, &instance->m0c_reqh.rh_ldom);
406 
407  /* op_size < sizeof(m0_op_obj) */
408  oo.oo_oc.oc_op.op_size = sizeof oo - 1;
410  M0_UT_ASSERT(rc == -EMSGSIZE);
411 
412  /* base case */
413  ent.en_id.u_hi = 0x0;
414  ent.en_id.u_lo = 0x103000;
415  op = &oo.oo_oc.oc_op;
416  m0_op_bob_init(op);
417  oo.oo_oc.oc_op.op_entity = &ent;
418  oo.oo_oc.oc_op.op_size = sizeof oo;
419  oo.oo_pver = instance->m0c_pools_common.pc_cur_pver->pv_id;
420  instance->m0c_root_fid = pfid;
421 
422  m0_op_obj_bob_init(&oo);
423  m0_op_common_bob_init(&oo.oo_oc);
424  m0_ast_rc_bob_init(&oo.oo_ar);
425 
426  m0_fi_enable_once("m0__obj_layout_id_get", "fake_obj_layout_id");
428  M0_UT_ASSERT(rc == 0);
430 
433 
434 #ifdef CLIENT_FOR_M0T1FS
435  //M0_UT_ASSERT(oo.oo_fid.f_container == 0x0);
436  M0_UT_ASSERT(oo.oo_fid.f_key == 0x103000);
437  //M0_UT_ASSERT(!strcmp((char *)oo.oo_name.b_addr, "0:103"));
438 #endif
439 
440  m0_free(oo.oo_name.b_addr);
441  m0_ast_rc_bob_fini(&oo.oo_ar);
442  m0_op_common_bob_fini(&oo.oo_oc);
443  m0_op_obj_bob_fini(&oo);
444 
445  /* fini */
446  ut_layout_fini(&ut_layout, &instance->m0c_reqh.rh_ldom);
450 }
451 
456 {
457  bool valid;
458  struct m0_op_obj oo;
459  struct m0_realm realm;
460  struct m0_entity ent;
461  struct m0_client *instance = NULL;
462  int rc = 0; /* required */
463 
464  /* init */
466  M0_UT_ASSERT(rc == 0);
468 
469  /* base case: !invariant */
470  oo.oo_oc.oc_op.op_entity = &ent;
472  valid = obj_op_obj_invariant(&oo);
473  M0_UT_ASSERT(!valid);
474 
475  /* base case: invariant */
476  oo.oo_oc.oc_op.op_entity = &ent;
478  valid = obj_op_obj_invariant(&oo);
479  M0_UT_ASSERT(valid);
480 
481  /* fini */
484 }
485 
489 static void ut_test_obj_op_obj_init(void)
490 {
491  int rc = 0; /* required */
492  struct m0_op_obj oo;
493  struct m0_realm realm;
494  struct m0_entity ent;
495  struct m0_client *instance = NULL;
496 
497  /* init */
499  M0_UT_ASSERT(rc == 0);
501 
502  /* base case */
503  instance->m0c_pools_common.pc_cur_pver->pv_attr.pa_P = 13;
504 
505  oo.oo_oc.oc_op.op_entity = &ent;
506  oo.oo_oc.oc_op.op_size = sizeof oo;
507  oo.oo_pver = instance->m0c_pools_common.pc_cur_pver->pv_id;
509  m0_op_common_bob_init(&oo.oo_oc);
510 
511  rc = obj_op_obj_init(&oo);
512  M0_UT_ASSERT(rc == 0);
513 
514  m0_op_common_bob_fini(&oo.oo_oc);
515 
516  /* fini */
519 }
520 
524 static void ut_test_obj_op_prepare(void)
525 {
526  int rc = 0; /* required */
527  struct m0_realm realm;
528  struct m0_entity entity;
529  struct m0_obj obj;
530  struct m0_op_common *oc;
531  struct m0_op_obj *oo;
532  struct m0_op *op = NULL;
533  struct m0_client *instance = NULL;
534  struct m0_container uber_realm;
535  struct m0_uint128 id;
536 
537  /* initialise */
539  M0_UT_ASSERT(rc == 0);
541  id = M0_ID_APP;
542  id.u_lo++;
543 
544  M0_SET0(&entity);
546  M0_SET0(&obj);
547 
548  /* base case */
549  instance->m0c_pools_common.pc_cur_pver->pv_attr.pa_P = 7;
550  m0_obj_init(&obj, &uber_realm.co_realm, &id,
552 
553  /* OP Allocation fails */
554  m0_fi_enable_once("m0_alloc", "fail_allocation");
555  rc = obj_op_prepare(&obj.ob_entity, &op, M0_EO_CREATE);
556  M0_UT_ASSERT(rc != 0);
557  M0_UT_ASSERT(op == NULL);
558 
559  /* m0_op_init fails */
560  m0_fi_enable_once("m0_op_init", "fail_op_init");
561  rc = obj_op_prepare(&obj.ob_entity, &op, M0_EO_CREATE);
562  M0_UT_ASSERT(rc != 0);
563  M0_UT_ASSERT(op == NULL);
564 
565  /* we won't use 'entity' as in the error cases */
566  rc = obj_op_prepare(&obj.ob_entity,
567  &op, M0_EO_CREATE);
568  M0_UT_ASSERT(rc == 0);
569  M0_UT_ASSERT(op != NULL);
570  M0_UT_ASSERT(op->op_size == sizeof(struct m0_op_obj));
571  M0_UT_ASSERT(op->op_sm.sm_state == M0_OS_INITIALISED);
572  M0_UT_ASSERT(op->op_entity == &obj.ob_entity);
573  oc = container_of(op, struct m0_op_common, oc_op);
574  oo = container_of(oc, struct m0_op_obj, oo_oc);
575  M0_UT_ASSERT(oo->oo_mds_fop == NULL);
576 
577  /* finalise client */
578  m0_entity_fini(&entity);
580 }
581 
586 {
587  int rc = 0; /* required */
588  struct m0_op *op = NULL;
589  struct m0_obj obj;
590  struct m0_entity *ent;
591  struct m0_realm realm;
592  struct m0_uint128 id;
593  struct m0_client *instance = NULL;
594  struct m0_pool_version pv;
595  struct m0_fid pfid = { .f_container = 0, .f_key = 1 };
596  struct m0_op_obj *oo;
597  struct m0_op_common *oc;
598 
599  /* init */
601  M0_UT_ASSERT(rc == 0);
602  M0_SET0(&obj);
603  ent = &obj.ob_entity;
605  ut_layout_init(&ut_layout, &instance->m0c_reqh.rh_ldom);
607 
608  M0_SET0(&pv);
609 
610  /* we need a valid id */
611  id = M0_ID_APP;
612  id.u_lo++;
613 
614  m0_fi_enable_once("m0__obj_layout_id_get", "fake_obj_layout_id");
615 
616  /* base case: no error, then check the output */
617  ent->en_type = M0_ET_OBJ;
618  ent->en_sm.sm_state = M0_ES_INIT;
619  ent->en_id = id;
620  pv.pv_attr.pa_P = 7; /* pool width */
621  instance->m0c_pools_common.pc_cur_pver = &pv;
622  instance->m0c_root_fid = pfid;
624  /* basic: detailed checks are included in the corresponding tests */
625  M0_UT_ASSERT(rc == 0);
626  M0_UT_ASSERT(op != NULL);
627  M0_UT_ASSERT(op->op_size == sizeof(struct m0_op_obj));
628  M0_UT_ASSERT(op->op_entity == ent);
629  M0_UT_ASSERT(op->op_sm.sm_state == M0_OS_INITIALISED);
630 
631  /* free memory */
632  oc = bob_of(op, struct m0_op_common, oc_op, &oc_bobtype);
633  oo = bob_of(oc, struct m0_op_obj, oo_oc, &oo_bobtype);
634  m0_free(oo->oo_name.b_addr);
635 
636  /* fini */
638  ut_layout_fini(&ut_layout, &instance->m0c_reqh.rh_ldom);
641 
642  if (op) m0_free(op);
643 }
644 
649 {
651 }
652 
657 {
659 }
660 
661 static void ut_test_obj_lid_assign(void)
662 {
663  struct m0_obj obj;
664  struct m0_entity ent;
665  struct m0_realm realm;
666  struct m0_op *ops[1] = {NULL};
667  struct m0_client *instance = NULL;
668  int rc;
669 
670  /* init */
672  M0_UT_ASSERT(rc == 0);
673 
675  ent.en_realm = &realm;
676 
677  memset(&obj, 0, sizeof obj);
678  obj.ob_attr.oa_buf_size = 40960;
679  m0_obj_init(&obj, &realm, &ent.en_id, 0);
680 
681  rc = m0_entity_create(NULL, &obj.ob_entity, &ops[0]);
682  M0_UT_ASSERT(obj.ob_attr.oa_layout_id > 0 &&
683  obj.ob_attr.oa_layout_id < 15);
684  M0_UT_ASSERT(rc == -EINVAL);
685  M0_UT_ASSERT(ops[0] == NULL);
686 
688 }
689 
690 static void ut_test_m0_entity_create(void)
691 {
692  struct m0_obj obj;
693  struct m0_entity ent;
694  struct m0_realm realm;
695  struct m0_op *ops[1] = {NULL};
696  struct m0_client *instance = NULL;
697  int rc;
698 
699  /* init */
701  M0_UT_ASSERT(rc == 0);
702 
704  ent.en_realm = &realm;
705 
706  memset(&obj, 0, sizeof obj);
707  m0_obj_init(&obj, &realm, &ent.en_id,
709 
710  rc = m0_entity_create(NULL, &obj.ob_entity, &ops[0]);
711  /*
712  * The layouts are not initialized. So we can not find layout with the
713  * specified lid.
714  */
715  M0_UT_ASSERT(rc == -EINVAL);
716  M0_UT_ASSERT(ops[0] == NULL);
717 
719 }
720 
721 static void ut_test_m0_entity_delete(void)
722 {
723  struct m0_obj obj;
724  struct m0_entity ent;
725  struct m0_realm realm;
726  struct m0_op *ops[1] = {NULL};
727  struct m0_client *instance = NULL;
728  int rc;
729 
730  /* init */
732  M0_UT_ASSERT(rc == 0);
733 
735  ent.en_realm = &realm;
736 
737  M0_SET0(&obj);
738  m0_obj_init(&obj, &realm, &ent.en_id,
740 
741  m0_fi_enable_once("obj_namei_op_init", "fake_msg_size");
742  rc = m0_entity_delete(&obj.ob_entity, &ops[0]);
743  M0_UT_ASSERT(rc == -EMSGSIZE);
744  M0_UT_ASSERT(ops[0] == NULL);
745 
747 }
748 
753 {
754  struct m0_entity ent;
755  struct m0_realm realm;
756  struct m0_client *cins2;
757  struct m0_client *instance = NULL;
758  int rc = 0; /* required */
759 
760  /* init */
762  M0_UT_ASSERT(rc == 0);
763 
765  ent.en_realm = &realm;
766 
767  /* base case */
768  cins2 = m0__entity_instance(&ent);
769  M0_UT_ASSERT(cins2 == instance);
770 
771  /* finalise */
774 }
775 
779 static void ut_test_m0__oo_instance(void)
780 {
781  struct m0_entity ent;
782  struct m0_realm realm;
783  struct m0_client *cins2;
784  struct m0_op_obj oo;
785  struct m0_client *instance = NULL;
786  int rc = 0; /* required */
787 
788  /* initialise client */
790  M0_UT_ASSERT(rc == 0);
791 
792  /* init */
794 
795  /* base case */
796  oo.oo_oc.oc_op.op_entity = &ent;
797  cins2 = m0__oo_instance(&oo);
798  M0_UT_ASSERT(cins2 == instance);
799 
800  /* finalise */
803 }
804 
808 static void ut_test_cob_complete_op(void)
809 {
810  struct m0_entity ent;
811  struct m0_realm realm;
812  struct m0_client *instance = NULL;
813  struct m0_op_obj oo;
814  struct m0_sm_group *op_grp;
815  struct m0_sm_group *en_grp;
816  struct m0_sm_group oo_grp;
817  int rc = 0; /* required */
818 
819  /* init */
820  M0_SET0(&oo);
821  M0_SET0(&ent);
823  M0_UT_ASSERT(rc == 0);
825 
826  op_grp = &oo.oo_oc.oc_op.op_sm_group;
827  en_grp = &ent.en_sm_group;
828  m0_sm_group_init(op_grp);
829  m0_sm_group_init(en_grp);
830  m0_sm_group_init(&oo_grp);
831  oo.oo_sm_grp = &oo_grp;
833 
834  /* base case */
836  M0_OS_INITIALISED, op_grp);
837  m0_op_bob_init(&oo.oo_oc.oc_op);
838  oo.oo_oc.oc_op.op_entity = &ent;
839  oo.oo_oc.oc_op.op_size = sizeof oo;
840 
841  m0_sm_group_lock(en_grp);
842  m0_sm_move(&ent.en_sm, 0, M0_ES_CREATING);
843  m0_sm_group_unlock(en_grp);
844 
845  m0_sm_group_lock(op_grp);
847  m0_sm_group_unlock(op_grp);
848 
849  m0_sm_group_lock(&oo_grp);
850  m0_fi_enable_once("m0_op_stable", "skip_ongoing_io_ref");
852  m0_sm_group_unlock(&oo_grp);
853 
855  M0_UT_ASSERT(ent.en_sm.sm_state == M0_ES_OPEN);
857 
858  /* finalise */
859  m0_sm_group_lock(op_grp);
861  m0_sm_group_unlock(op_grp);
862  m0_sm_group_fini(op_grp);
863 
864  m0_sm_group_fini(&oo_grp);
865  m0_op_bob_fini(&oo.oo_oc.oc_op);
866 
869 }
870 
874 static void ut_test_cob_fail_op(void)
875 {
876  int rc = 0; /* required */
877  struct m0_entity ent;
878  struct m0_realm realm;
879  struct m0_client *instance = NULL;
880  struct m0_op_obj oo;
881  struct m0_sm_group *op_grp;
882  struct m0_sm_group *en_grp;
883  struct m0_sm_group oo_grp;
884 
885  /* Init. */
886  M0_SET0(&oo);
887  M0_SET0(&ent);
889  M0_UT_ASSERT(rc == 0);
891 
892  op_grp = &oo.oo_oc.oc_op.op_sm_group;
893  en_grp = &ent.en_sm_group;
894  m0_sm_group_init(op_grp);
895  m0_sm_group_init(en_grp);
896  m0_sm_group_init(&oo_grp);
897  oo.oo_sm_grp = &oo_grp;
898 
900  M0_OS_INITIALISED, op_grp);
901  oo.oo_oc.oc_op.op_entity = &ent;
902  oo.oo_oc.oc_op.op_size = sizeof oo;
903  m0_op_bob_init(&oo.oo_oc.oc_op);
904 
905  m0_sm_group_lock(en_grp);
906  m0_sm_move(&ent.en_sm, 0, M0_ES_CREATING);
907  m0_sm_group_unlock(en_grp);
908 
909  m0_sm_group_lock(op_grp);
911  m0_sm_group_unlock(op_grp);
912 
913  /* Base case. */
914  m0_sm_group_lock(&oo_grp);
915  m0_fi_enable_once("m0_op_stable", "skip_ongoing_io_ref");
916  cob_fail_op(&oo.oo_oc.oc_op, 777);
917  m0_sm_group_unlock(&oo_grp);
918 
920  M0_UT_ASSERT(ent.en_sm.sm_state == M0_ES_INIT);
921  M0_UT_ASSERT(oo.oo_oc.oc_op.op_rc == 777);
923 
924  /* finalise */
925  m0_sm_group_fini(&oo_grp);
926  m0_sm_group_lock(op_grp);
928  m0_sm_group_unlock(op_grp);
929 
930  m0_op_bob_fini(&oo.oo_oc.oc_op);
933 }
934 
935 /*
936  * Tests obj_rpc_item_to_ios_cob_req().
937  */
939 {
940  struct ios_cob_req icr;
941  struct m0_fop fop;
942  struct ios_cob_req *ret;
943 
944  /* base case */
945  fop.f_opaque = &icr;
946  ret = rpc_item_to_icr(&fop.f_item);
947  M0_UT_ASSERT(ret == &icr);
948 }
949 
953 static void ut_test_icr_ast_complete(void)
954 {
955  struct m0_client *instance = NULL;
956  struct cob_req *cr;
957  struct m0_op_obj oo;
958  struct ios_cob_req icr;
959  struct m0_sm_group *en_grp;
960  struct m0_sm_group *op_grp;
961  struct m0_sm_group locality_grp;
962  struct m0_fop fop;
963  struct m0_entity ent;
964  struct m0_realm realm;
965  uint64_t pool_width;
966  int rc = 0; /* required */
967 
968  /* initialise client */
970  M0_UT_ASSERT(rc == 0);
971  pool_width = 1;
972  instance->m0c_pools_common.pc_cur_pver->pv_attr.pa_P = pool_width;
973 
974  M0_ALLOC_PTR(cr);
975  M0_UT_ASSERT(cr != NULL);
977  M0_UT_ASSERT(cr->cr_cob_attr != NULL);
978 
979  M0_SET0(&ent);
980  M0_SET0(&oo);
981  M0_SET0(cr);
982  M0_SET0(&icr);
983  M0_SET0(&realm);
984  ios_cob_req_bob_init(&icr);
985  m0_ast_rc_bob_init(&icr.icr_ar);
986  cob_req_bob_init(cr);
987  m0_ast_rc_bob_init(&cr->cr_ar);
988  m0_op_bob_init(&oo.oo_oc.oc_op);
989 
991  op_grp = &oo.oo_oc.oc_op.op_sm_group;
992  en_grp = &ent.en_sm_group;
993  m0_sm_group_init(op_grp);
994  m0_sm_group_init(en_grp);
995  m0_sm_group_init(&locality_grp);
997  oo.oo_sm_grp = &locality_grp;
998 
999  /* base case: one single ios cob request */
1000  cr->cr_opcode = M0_EO_CREATE;
1001  cr->cr_cinst = instance;
1002  cr->cr_op = &oo.oo_oc.oc_op;
1003  cr->cr_cob_type = M0_COB_IO;
1004  cr->cr_icr_nr = pool_width;
1005  M0_ALLOC_ARR(cr->cr_ios_replied, pool_width);
1006  M0_ALLOC_ARR(cr->cr_ios_fop, pool_width);
1007  fop.f_item.ri_reply = (struct m0_rpc_item *)0xffff;
1008  fop.f_opaque = &icr;
1009  cr->cr_ios_fop[0] = &fop;
1010 
1011  icr.icr_cr = cr;
1012  icr.icr_index = 0;
1013  oo.oo_oc.oc_op.op_entity = &ent;
1014  oo.oo_oc.oc_op.op_size = sizeof oo;
1016 
1017  /* TODO ADd to cob ut*/
1019  M0_OS_INITIALISED, op_grp);
1020  m0_sm_group_lock(en_grp);
1021  m0_sm_move(&ent.en_sm, 0, M0_ES_CREATING);
1022  m0_sm_group_unlock(en_grp);
1023 
1024  m0_sm_group_lock(op_grp);
1026  m0_sm_group_unlock(op_grp);
1027 
1028  m0_fi_enable_once("icrs_complete", "skip_post_cr_ast");
1029  m0_fi_enable_once("m0_op_stable", "skip_ongoing_io_ref");
1030  m0_sm_group_lock(&locality_grp);
1031  icr_ast(&locality_grp, &icr.icr_ar.ar_ast);
1032  m0_sm_group_unlock(&locality_grp);
1033 
1035  M0_UT_ASSERT(ent.en_sm.sm_state == M0_ES_OPEN);
1037 
1038  /* finalise */
1039  m0_entity_fini(&ent);
1040 
1042  m0_ast_rc_bob_fini(&icr.icr_ar);
1043  ios_cob_req_bob_fini(&icr);
1044  m0_op_bob_fini(&oo.oo_oc.oc_op);
1045 
1046  m0_sm_group_lock(op_grp);
1047  m0_sm_fini(&oo.oo_oc.oc_op.op_sm);
1048  m0_sm_group_unlock(op_grp);
1049  m0_sm_group_fini(op_grp);
1050 
1051  m0_sm_group_fini(&locality_grp);
1053 }
1054 
1058 static void ut_test_icr_ast_fail(void)
1059 {
1060  int rc = 0; /* required */
1061  struct m0_client *instance = NULL;
1062  struct m0_entity ent;
1063  struct m0_realm realm;
1064  struct m0_op_obj oo;
1065  struct ios_cob_req icr;
1066  struct m0_sm_group oo_grp;
1067  struct m0_sm_group *op_grp;
1068  struct m0_sm_group *en_grp;
1069  struct cob_req *cr;
1070  struct m0_fop fop;
1071 
1072  /* Init. */
1073  M0_SET0(&oo);
1074  M0_SET0(&ent);
1076  M0_UT_ASSERT(rc == 0);
1077  cr = m0_alloc(sizeof *cr);
1078  M0_ASSERT(cr != NULL);
1079 
1080  cob_req_bob_init(cr);
1081  m0_ast_rc_bob_init(&cr->cr_ar);
1082  cr->cr_cinst = instance;
1084  op_grp = &oo.oo_oc.oc_op.op_sm_group;
1085  en_grp = &ent.en_sm_group;
1086  m0_sm_group_init(op_grp);
1087  m0_sm_group_init(en_grp);
1088  m0_sm_group_init(&oo_grp);
1090  oo.oo_sm_grp = &oo_grp;
1091 
1093  M0_OS_INITIALISED, op_grp);
1094  oo.oo_oc.oc_op.op_entity = &ent;
1095  oo.oo_oc.oc_op.op_size = sizeof oo;
1096 
1097  m0_sm_group_lock(en_grp);
1098  m0_sm_move(&ent.en_sm, 0, M0_ES_CREATING);
1099  m0_sm_group_unlock(en_grp);
1100 
1101  m0_sm_group_lock(op_grp);
1103  m0_sm_group_unlock(op_grp);
1104 
1105  ios_cob_req_bob_init(&icr);
1106  m0_ast_rc_bob_init(&icr.icr_ar);
1107  m0_op_bob_init(&oo.oo_oc.oc_op);
1108 
1109  /* Base case. */
1110  cr->cr_opcode = M0_EO_CREATE;
1111  cr->cr_op = &oo.oo_oc.oc_op;
1112  cr->cr_icr_nr = 1;
1114  M0_ALLOC_ARR(cr->cr_ios_fop, cr->cr_icr_nr);
1115  fop.f_item.ri_reply = (struct m0_rpc_item *)0xffff;
1116  fop.f_opaque = &icr;
1117  cr->cr_ios_fop[0] = &fop;
1118  icr.icr_cr = cr;
1119  icr.icr_ar.ar_rc = 111;
1120  icr.icr_index = 0;
1121 
1122  m0_fi_enable_once("icrs_fail", "skip_post_cr_ast");
1123  m0_fi_enable_once("m0_op_stable", "skip_ongoing_io_ref");
1124  m0_sm_group_lock(&oo_grp);
1125  icr_ast(&oo_grp, &icr.icr_ar.ar_ast);
1126  m0_sm_group_unlock(&oo_grp);
1127  M0_UT_ASSERT(oo.oo_oc.oc_op.op_rc == 111);
1128 
1129  /* finalise client */
1130  m0_ast_rc_bob_fini(&icr.icr_ar);
1131  ios_cob_req_bob_fini(&icr);
1132  m0_op_bob_fini(&oo.oo_oc.oc_op);
1133 
1135  m0_sm_group_fini(&oo_grp);
1136  m0_sm_group_lock(op_grp);
1137  m0_sm_fini(&oo.oo_oc.oc_op.op_sm);
1138  m0_sm_group_unlock(op_grp);
1139  m0_sm_group_fini(op_grp);
1140  m0_entity_fini(&ent);
1142 }
1143 
1145 {
1146 }
1147 
1149 {
1150  /* cannot avoid m0_sm_ast_post(): no base case */
1151 }
1152 
1157 {
1158  int rc = 0; /* required */
1159  struct m0_fop fop;
1160  struct m0_fid cob_fid;
1161  struct m0_op_obj *oo;
1162  struct m0_fop_cob_create *cc;
1163  struct m0_realm realm;
1164  struct m0_entity ent;
1165  struct m0_poolmach *mach;
1166  struct m0_poolmach_state state;
1167  struct m0_client *instance = NULL;
1168  struct m0_sm_group oo_grp;
1169 
1170  /* initialise */
1172  M0_UT_ASSERT(rc == 0);
1173  M0_SET0(&fop);
1174  M0_SET0(&cob_fid);
1175  M0_ALLOC_PTR(oo);
1176  M0_UT_ASSERT(oo != NULL);
1177  M0_ALLOC_PTR(cc);
1178  M0_UT_ASSERT(cc != NULL);
1179  M0_SET0(cc);
1181  m0_sm_group_init(&oo_grp);
1182  oo->oo_sm_grp = &oo_grp;
1183 
1184  /* base case */
1186  fop.f_data.fd_data = cc;
1187  m0_fid_set(&oo->oo_fid, 0xDEAF, 0xDAD);
1188  oo->oo_oc.oc_op.op_entity = &ent;
1189  m0_fid_set(&cob_fid, 0xBAD, 0xBEE);
1190 
1191  mach = &instance->m0c_pools_common.pc_cur_pver->pv_mach;
1192  mach->pm_state = &state;
1193 
1194  m0_sm_group_lock(&oo_grp);
1195  m0_rwlock_init(&mach->pm_lock);
1196  OP_OBJ2CODE(oo) = M0_EO_CREATE;
1197  m0_sm_group_unlock(&oo_grp);
1198 
1199  /*rc = cob_ios_fop_populate(oo, &fop, &cob_fid, 777);
1200  m0_rwlock_fini(&mach->pm_lock);
1201  M0_UT_ASSERT(rc == 0);*/
1202 
1203  /* fini */
1204  m0_sm_group_fini(&oo_grp);
1205  m0_free(oo);
1206  m0_entity_fini(&ent);
1208 }
1209 
1214 {
1215  int rc;
1216  struct m0_reqh_service_ctx *ctx;
1217  struct m0_rpc_session *session;
1218  struct m0_client *instance = NULL;
1219  struct m0_pool_version *pv;
1220 
1221  /* initialise client */
1223  M0_UT_ASSERT(rc == 0 && instance != NULL);
1224  pv = instance->m0c_pools_common.pc_cur_pver;
1225 
1226  /* base case */
1227  M0_ALLOC_PTR(pv->pv_pc);
1229  M0_ALLOC_PTR(ctx);
1230 
1231  ctx->sc_type = M0_CST_IOS;
1232  pv->pv_pc->pc_nr_devices = 1;
1233  pv->pv_pc->pc_dev2svc[0].pds_ctx = ctx;
1235  M0_UT_ASSERT(session == &ctx->sc_rlink.rlk_sess);
1237  m0_free(pv->pv_pc);
1238  m0_free(ctx);
1239 
1240  /* fini */
1242 }
1243 
1245 {
1246 }
1247 
1251 static void ut_test_cob_ios_send(void)
1252 {
1253 }
1254 
1258 static void ut_test_rpc_item_to_cr(void)
1259 {
1260  struct m0_fop fop;
1261  struct cob_req *cr;
1262  struct cob_req cob_req;
1263 
1264  /* base case */
1265  cob_req_bob_init(&cob_req);
1266  m0_ast_rc_bob_init(&cob_req.cr_ar);
1267  fop.f_opaque = &cob_req;
1268  cr = rpc_item_to_cr(&fop.f_item);
1269  M0_UT_ASSERT(cr == &cob_req);
1270  m0_ast_rc_bob_fini(&cob_req.cr_ar);
1271  cob_req_bob_fini(&cob_req);
1272 }
1273 
1274 static void ut_test_cob_ast_fail_oo(void)
1275 {
1276 }
1277 
1282 {
1283 }
1284 
1288 static void ut_test_cob_name_mem2wire(void)
1289 {
1290  struct m0_fop_str tgt;
1291  struct m0_buf name;
1292  char *str = "HavantFTW";
1293  int rc = 0; /* required */
1294 
1295  /* base case */
1296  M0_SET0(&tgt);
1297  m0_buf_init(&name, str, strlen(str));
1298  M0_UT_ASSERT(name.b_nob == strlen(str));
1299  rc = cob_name_mem2wire(&tgt, &name);
1300  M0_UT_ASSERT(rc == 0);
1301  M0_UT_ASSERT(tgt.s_len == name.b_nob);
1302  M0_UT_ASSERT(!strncmp((char *)tgt.s_buf, (char *)name.b_addr, tgt.s_len));
1303 
1304  m0_free(tgt.s_buf);
1305 }
1306 
1310 static void ut_test_cob_body_mem2wire(void)
1311 {
1312  int rc;
1313  struct m0_cob_attr attr;
1314  struct m0_fop_cob body;
1315  struct cob_req cr;
1316  struct m0_client *instance = NULL;
1317 
1318  /* initialise client */
1320  M0_UT_ASSERT(rc == 0);
1321 
1322  /* init */
1323  M0_SET0(&body);
1324  M0_SET0(&cr);
1325  attr.ca_nlink = 1;
1326  attr.ca_valid = M0_COB_NLINK;
1327 
1328  /* base case */
1329  m0_fid_set(&cr.cr_fid, 0x66, 0x77);
1330 #ifdef CLIENT_FOR_M0T1FS
1331  cr.cr_cinst = instance;
1332 #endif
1333 
1334  cob_body_mem2wire(&body, &attr, attr.ca_valid, &cr);
1335 
1336  M0_UT_ASSERT(body.b_nlink == 1);
1339  M0_UT_ASSERT(body.b_tfid.f_key == 0x77);
1340 #ifdef CLIENT_FOR_M0T1FS
1341  M0_UT_ASSERT(body.b_pfid.f_container == instance->m0c_root_fid.f_container);
1342  M0_UT_ASSERT(body.b_pfid.f_key == instance->m0c_root_fid.f_key);
1343 #endif
1345 }
1346 
1351 {
1352  struct m0_op_obj *oo;
1353  struct m0_fop fop;
1354  struct cob_req *cr;
1355  struct m0_fop_create create;
1356  struct m0_fop_type ft;
1357  int rc = 0;
1358 #ifdef CLIENT_FOR_M0T1FS
1359  char *str = "HavantFTW";
1360 #endif
1361  struct m0_fid fid = { .f_container = 66,
1362  .f_key = 77 };
1363  struct m0_client *instance = NULL;
1364 
1365  /* initialise client */
1367  M0_UT_ASSERT(rc == 0);
1368 
1369  /* base case */
1370  M0_ALLOC_PTR(cr);
1371  M0_UT_ASSERT(cr != NULL);
1373  M0_UT_ASSERT(cr->cr_cob_attr != NULL);
1374 
1375  M0_ALLOC_PTR(oo);
1376  M0_UT_ASSERT(oo != NULL);
1377 
1378  oo->oo_fid = fid;
1379  OP_OBJ2CODE(oo) = M0_EO_CREATE;
1380 #ifdef CLIENT_FOR_M0T1FS
1381  m0_buf_init(&oo->oo_name, str, strlen(str));
1382 #endif
1383 
1384  cr->cr_op = &oo->oo_oc.oc_op;
1385  cr->cr_fid = fid;
1386  cr->cr_cob_attr->ca_lid = 1;
1387  cr->cr_cinst = instance;
1388  cr->cr_opcode = M0_EO_CREATE;
1389 
1390  fop.f_data.fd_data = &create;
1392  fop.f_type = &ft;
1393 
1394  rc = cob_mds_fop_populate(cr, &fop);
1395  M0_UT_ASSERT(rc == 0);
1396  M0_UT_ASSERT(!m0_fid_cmp(&create.c_body.b_tfid, &oo->oo_fid));
1398 }
1399 
1403 #ifdef CLIENT_FOR_M0T1FS
1404 static void ut_test_filename_to_mds_session(void)
1405 {
1406  struct m0_rpc_session *session;
1407  struct m0_reqh_service_ctx *ctx;
1408  char *filename = "filename";
1409  m0_bcount_t len;
1410  struct m0_client *instance = NULL;
1411  int rc;
1412 
1413  /* initialise client */
1415  M0_UT_ASSERT(rc == 0 && instance != NULL);
1416 
1417  len = (m0_bcount_t)strlen(filename);
1418 
1419  /* base case */
1420  M0_ALLOC_PTR(ctx);
1421  M0_ALLOC_ARR(instance->m0c_pools_common.pc_mds_map, 1);
1422  instance->m0c_pools_common.pc_mds_map[0] = ctx;
1423  instance->m0c_pools_common.pc_nr_svcs[M0_CST_MDS] = 1;
1424  session =
1425  filename_to_mds_session(instance, (unsigned char *)filename, len);
1426  M0_UT_ASSERT(session == &ctx->sc_rlink.rlk_sess);
1427  m0_free(instance->m0c_pools_common.pc_mds_map);
1428  m0_free(ctx);
1429 
1430  /* fini */
1432 }
1433 #endif
1434 
1435 static void ut_test_cob_mds_send(void)
1436 {
1437 }
1438 
1440 {
1441 }
1442 
1446 static void ut_test_obj_namei_cb_free(void)
1447 {
1448  struct m0_op_obj *oo;
1449  struct m0_entity ent;
1450  struct m0_realm realm;
1451  struct m0_client *instance = NULL;
1452  int rc = 0; /* required */
1453 
1454  /* initialise client */
1456  M0_UT_ASSERT(rc == 0);
1457 
1458  /* init */
1460 
1461  /* base case */
1462  M0_ALLOC_PTR(oo);
1463  m0_op_obj_bob_init(oo);
1464  oo->oo_oc.oc_op.op_size = sizeof *oo;
1465  oo->oo_oc.oc_op.op_entity = &ent;
1466  obj_namei_cb_free(&oo->oo_oc);
1467 
1468  /* fini */
1469  m0_entity_fini(&ent);
1471 }
1472 
1476 static void ut_test_obj_namei_cb_fini(void)
1477 {
1478  int rc = 0; /* required */
1479  struct m0_op_obj oo;
1480  struct m0_realm realm;
1481  struct m0_entity ent;
1482  struct m0_client *instance = NULL;
1483 
1484  /* initialise client */
1486  M0_UT_ASSERT(rc == 0);
1487 
1488  /* init */
1490  ut_layout_init(&ut_layout, &instance->m0c_reqh.rh_ldom);
1492 
1493  /* base cases */
1494  M0_SET0(&oo);
1495  m0_op_obj_bob_init(&oo);
1496  m0_ast_rc_bob_init(&oo.oo_ar);
1497  m0_op_common_bob_init(&oo.oo_oc);
1498  oo.oo_oc.oc_op.op_entity = &ent;
1499  oo.oo_oc.oc_op.op_size = sizeof oo;
1500 
1501  /* base case: most fields are NULL */
1502  obj_namei_cb_fini(&oo.oo_oc);
1503 
1504 
1505  /* fini */
1506  m0_entity_fini(&ent);
1507  ut_layout_fini(&ut_layout, &instance->m0c_reqh.rh_ldom);
1510 }
1511 
1513 
1514 M0_INTERNAL int ut_object_init(void)
1515 {
1516 #ifndef __KERNEL__
1518 #endif
1519 
1520  m0_fi_enable("m0__obj_pool_version_get", "fake_pool_version");
1521 
1522  return 0;
1523 }
1524 
1525 M0_INTERNAL int ut_object_fini(void)
1526 {
1527  m0_fi_disable("m0__obj_pool_version_get", "fake_pool_version");
1528 
1529  return 0;
1530 }
1531 
1532 struct m0_ut_suite ut_suite_obj = {
1533  .ts_name = "obj-ut",
1534  .ts_init = ut_object_init,
1535  .ts_fini = ut_object_fini,
1536  .ts_tests = {
1537 
1538  /* XXX
1539  */
1540  { "m0_op_obj_invariant",
1542 
1543  /* Set the namespace operation. */
1544  { "m0_op_obj_invariant",
1546  { "m0_op_obj_ast_rc_invariant",
1548  { "m0_op_common_invariant",
1550  { "cob_req_invariant",
1552  { "entity_namei_op(create)",
1554  { "entity_namei_op(delete)",
1556  { "m0_entity_create(object)",
1558  { "m0_entity_delete(object)",
1560  { "m0__obj_layout_instance_build",
1562  { "m0_fid_print",
1564  { "obj_namei_op_init",
1566  { "obj_op_obj_invariant",
1568  { "obj_op_obj_init",
1570  { "obj_op_prepare",
1572 
1573  /* Processing a namespace object operation. */
1574  { "m0__entity_instance",
1576  { "m0__oo_instance",
1578  { "cob_complete_op",
1580  { "cob_fail_op",
1582  { "rpc_item_to_ios_cob_req",
1584  { "icr_ast_complete",
1586  { "icr_ast_fail",
1588  { "icr_ast_ver_mismatch",
1590  { "cob_rio_ios_replied",
1592  { "cob_ios_fop_populate",
1594  { "m0_obj_container_id_to_session",
1596  { "m0_cob_ios_fop_fini",
1598  { "cob_ios_send",
1600  { "rpc_item_to_cr",
1602  { "cob_ast_fail_oo",
1604  { "cob_rio_mds_replied",
1606  { "cob_name_mem2wire",
1608  { "cob_body_mem2wire",
1610  { "cob_mds_fop_populate",
1612 #ifdef CLIENT_FOR_M0T1FS
1613  { "filename_to_mds_session",
1614  &ut_test_filename_to_mds_session},
1615 #endif
1616  { "cob_mds_send",
1618  { "obj_namei_cb_launch",
1620 
1621  /* Freeing a namespace object operation. */
1622  { "obj_namei_cb_free",
1624 
1625  /* Finalising a namespace object operation. */
1626  { "obj_namei_cb_fini",
1628 
1629  /*
1630  * Assignment of optimal layout id for object accoriding to
1631  * initial buffer size.
1632  */
1633  { "obj_optimal_lid_set",
1635  }
1636 };
1637 
1638 #undef M0_TRACE_SUBSYSTEM
1639 
1640 /*
1641  * Local variables:
1642  * c-indentation-style: "K&R"
1643  * c-basic-offset: 8
1644  * tab-width: 8
1645  * fill-column: 80
1646  * scroll-step: 1
1647  * End:
1648  */
static void ut_test_obj_namei_cb_free(void)
Definition: obj.c:1446
void * fd_data
Definition: fop.h:75
static int cob_mds_fop_populate(struct cob_req *cr, struct m0_fop *fop)
Definition: cob.c:1595
static struct ctx cc
uint64_t ca_lid
Definition: cob.h:380
uint32_t b_nlink
Definition: md_fops.h:81
uint64_t id
Definition: cob.h:2380
static bool ios_cob_req_invariant(struct ios_cob_req *icr)
Definition: cob.c:141
void ut_layout_domain_empty(struct m0_client *cinst)
Definition: obj.c:218
uint32_t rit_opcode
Definition: item.h:474
struct m0_fop ** cr_ios_fop
Definition: cob.c:75
const struct m0_bob_type oo_bobtype
Definition: client.c:45
static const struct m0_bob_type layout_instance_bob
Definition: obj.c:150
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
static void ut_test_m0_entity_delete(void)
Definition: obj.c:721
static void ut_test_entity_namei_op_delete(void)
Definition: obj.c:656
static void ut_test_m0_obj_container_id_to_session(void)
Definition: obj.c:1213
void m0_entity_fini(struct m0_entity *entity)
Definition: client.c:438
M0_INTERNAL void m0_fid_gob_make(struct m0_fid *gob_fid, uint32_t container, uint64_t key)
Definition: fid_convert.c:46
struct m0_op * cr_op
Definition: cob.c:65
struct m0_cob_attr * cr_cob_attr
Definition: cob.c:80
static struct m0_layout_ops ut_layout_ops
Definition: obj.c:130
Definition: client.h:788
M0_INTERNAL struct m0_rpc_session * m0_obj_container_id_to_session(struct m0_pool_version *pv, uint64_t container_id)
Definition: cob.c:925
struct m0_layout * li_l
Definition: layout.h:590
M0_INTERNAL struct m0_client * m0__oo_instance(struct m0_op_obj *oo)
Definition: obj.c:43
uint32_t b_valid
Definition: md_fops.h:76
#define NULL
Definition: misc.h:38
m0_entity_opcode
Definition: client.h:523
static void ut_test_cob_ast_fail_oo(void)
Definition: obj.c:1274
struct m0_fid b_tfid
Definition: md_fops.h:92
struct m0_buf oo_name
static void ut_test_rpc_item_to_cr(void)
Definition: obj.c:1258
static struct m0_layout_enum_ops ut_layout_enum_ops
Definition: obj.c:86
static void ut_test_icr_ast_complete(void)
Definition: obj.c:953
void ut_m0_ops_fini(struct m0_ref *ref)
Definition: obj.c:125
void * b_addr
Definition: buf.h:39
static void ut_test_cob_mds_fop_populate(void)
Definition: obj.c:1350
static void ut_test_obj_namei_cb_launch(void)
Definition: obj.c:1439
void ut_layout_domain_fill(struct m0_client *cinst)
Definition: obj.c:208
struct m0_pool_version * pv
Definition: dir.c:629
struct m0_layout_instance_ops ut_layout_instance_ops
Definition: obj.c:106
#define M0T1FS_LAYOUT_P
Definition: client.h:61
static void ut_test_obj_op_obj_init(void)
Definition: obj.c:489
static int obj_op_prepare(struct m0_entity *entity, struct m0_op **op, enum m0_entity_opcode opcode)
Definition: obj.c:665
struct m0_sm_group * oo_sm_grp
static void create(void)
Definition: service_ut.c:546
static struct m0_realm uber_realm
Definition: m0hsm.c:49
struct m0_ast_rc cr_ar
Definition: cob.c:63
uint32_t cr_opcode
Definition: cob.c:68
M0_INTERNAL void m0_buf_init(struct m0_buf *buf, void *data, uint32_t nob)
Definition: buf.c:37
M0_INTERNAL void ut_striped_layout_fini(struct m0_striped_layout *stl, struct m0_layout_domain *dom)
Definition: obj.c:202
struct m0_fid ut_fid
Definition: obj.c:71
struct m0_op oc_op
struct m0_layout_enum *(* lio_to_enum)(const struct m0_layout_instance *li)
Definition: layout.h:614
static void t_unregister(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: obj.c:48
uint64_t m0_client_layout_id(const struct m0_client *instance)
Definition: obj.c:859
static struct m0_addb2_mach * mach
Definition: storage.c:42
static void cob_body_mem2wire(struct m0_fop_cob *body, struct m0_cob_attr *attr, int valid, struct cob_req *cr)
Definition: cob.c:178
struct m0_ast_rc oo_ar
static void ut_lio_fini(struct m0_layout_instance *li)
Definition: obj.c:102
static struct cob_req * rpc_item_to_cr(struct m0_rpc_item *item)
Definition: cob.c:1448
uint64_t m0_bcount_t
Definition: types.h:77
static void ut_test_cob_ios_send(void)
Definition: obj.c:1251
#define container_of(ptr, type, member)
Definition: misc.h:33
static struct m0_rpc_session session
Definition: formation2.c:38
#define M0_SET0(obj)
Definition: misc.h:64
static int cob_name_mem2wire(struct m0_fop_str *tgt, const struct m0_buf *name)
Definition: cob.c:154
Definition: ut.h:77
const struct m0_uint128 M0_UBER_REALM
Definition: client.c:85
struct m0_layout_enum ut_layout_enum
Definition: obj.c:92
M0_INTERNAL int m0_fid_cmp(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:170
static void ut_test_icr_ast_ver_mismatch(void)
Definition: obj.c:1144
M0_INTERNAL int ut_m0_client_init(struct m0_client **instance)
Definition: client.c:265
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
struct m0_layout_enum_type * le_type
Definition: layout.h:409
static struct foo * obj
Definition: tlist.c:302
static void icr_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: cob.c:806
const char * bt_name
Definition: bob.h:73
M0_INTERNAL int ut_object_fini(void)
Definition: obj.c:1525
static int t_register(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: obj.c:42
static const struct m0_layout_type_ops ut_layout_type_ops
Definition: obj.c:58
M0_BOB_DEFINE(M0_INTERNAL, &enum_bob, m0_layout_enum)
Definition: dir.c:58
static m0_bcount_t t_max_recsize(struct m0_layout_domain *dom)
Definition: obj.c:53
struct m0_client * cr_cinst
Definition: cob.c:62
struct m0_fop_cob * body
Definition: dir.c:1436
M0_INTERNAL void m0_rwlock_init(struct m0_rwlock *lock)
Definition: rwlock.c:32
static void cob_complete_op(struct m0_op *op)
Definition: cob.c:457
const struct m0_uint128 M0_ID_APP
Definition: client.c:92
struct m0_fid fid
Definition: di.c:46
op
Definition: libdemo.c:64
unsigned int op_code
Definition: client.h:650
static void ut_test_cob_fail_op(void)
Definition: obj.c:874
M0_INTERNAL bool m0_op_obj_invariant(struct m0_op_obj *oo)
Definition: obj.c:79
static void ut_test_obj_op_obj_invariant(void)
Definition: obj.c:455
struct m0_fid oo_pver
Definition: buf.h:37
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
static void ut_test_cob_body_mem2wire(void)
Definition: obj.c:1310
int opcode
Definition: crate.c:301
static struct m0_layout_enum_type ut_layout_enum_type
Definition: obj.c:90
size_t op_size
Definition: client.h:664
struct m0_fop_type * f_type
Definition: fop.h:81
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 struct m0_layout_instance ut_layout_instance
Definition: obj.c:111
M0_INTERNAL void m0_fid_set(struct m0_fid *fid, uint64_t container, uint64_t key)
Definition: fid.c:116
const struct m0_bob_type oc_bobtype
Definition: client.c:44
M0_INTERNAL int ut_object_init(void)
Definition: obj.c:1514
static void ut_test_cob_name_mem2wire(void)
Definition: obj.c:1288
struct m0_fid cr_fid
Definition: dir.c:63
struct m0_sm op_sm
Definition: client.h:656
const char * name
Definition: trace.c:110
M0_INTERNAL uint64_t m0_pool_version2layout_id(const struct m0_fid *pv_fid, uint64_t lid)
Definition: pool.c:1900
static void ut_test_cob_mds_send(void)
Definition: obj.c:1435
Definition: refs.h:34
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
static void ut_test_m0_op_common_invariant(void)
Definition: obj.c:315
struct m0_fid pv_id
Definition: pool.h:113
struct cob_req * icr_cr
Definition: cob.c:45
bool * cr_ios_replied
Definition: cob.c:79
const struct m0_layout_enum_ops * le_ops
Definition: layout.h:423
M0_INTERNAL void m0_fi_disable(const char *fp_func, const char *fp_tag)
Definition: finject.c:485
uint32_t cr_icr_nr
Definition: cob.c:74
static void m0_fi_enable(const char *func, const char *tag)
Definition: finject.h:276
struct m0_ast_rc icr_ar
Definition: cob.c:46
#define M0_ASSERT(cond)
M0_INTERNAL void ut_m0_client_fini(struct m0_client **instance)
Definition: client.c:354
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
uint32_t cr_cob_type
Definition: cob.c:72
static void ut_layout_fini(struct m0_layout *l, struct m0_layout_domain *dom)
Definition: obj.c:189
int32_t op_rc
Definition: client.h:652
static void obj_namei_cb_launch(struct m0_op_common *oc)
Definition: obj.c:219
static void ut_entity_namei_op(enum m0_entity_opcode opcode)
Definition: obj.c:585
static void ut_test_obj_namei_cb_fini(void)
Definition: obj.c:1476
static void obj_namei_cb_free(struct m0_op_common *oc)
Definition: obj.c:285
uint32_t pc_nr_devices
Definition: pool.h:196
struct m0_reqh m0c_reqh
#define bob_of(ptr, type, field, bt)
Definition: bob.h:140
static struct ios_cob_req * rpc_item_to_icr(struct m0_rpc_item *item)
Definition: cob.c:697
uint32_t icr_index
Definition: cob.c:47
struct m0_layout_enum * sl_enum
Definition: layout.h:577
static struct m0_stob_domain * dom
Definition: storage.c:38
const char * lt_name
Definition: layout.h:357
static struct m0_fid cob_fid
Definition: net.c:116
static void obj_namei_cb_fini(struct m0_op_common *oc)
Definition: obj.c:311
static void ut_test_m0__entity_instance(void)
Definition: obj.c:752
int layout_id
Definition: dir.c:331
struct m0_rpc_item * ri_reply
Definition: item.h:163
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL void ut_shuffle_test_order(struct m0_ut_suite *suite)
Definition: client.c:1205
void * f_opaque
Definition: fop.h:84
uint64_t f_container
Definition: fid.h:39
M0_INTERNAL int m0_fid_print(char *s, size_t s_len, const struct m0_fid *fid)
Definition: fid.c:233
struct m0_pools_common * pv_pc
Definition: pool.h:130
struct m0_fid oo_fid
static void ut_test_m0_op_obj_ast_rc_invariant(void)
Definition: obj.c:267
Definition: xcode.c:55
int(* lo_instance_build)(struct m0_layout *l, const struct m0_fid *fid, struct m0_layout_instance **linst)
Definition: layout.h:303
struct m0_layout_domain rh_ldom
Definition: reqh.h:153
void(* oc_cb_fini)(struct m0_op_common *oc)
struct m0_pool_device_to_service * pc_dev2svc
Definition: pool.h:207
static struct m0_layout ut_layout
Definition: obj.c:68
struct m0_op_common oo_oc
static uint32_t ut_layout_nr(const struct m0_layout_enum *e)
Definition: obj.c:80
static struct fdmi_ctx ctx
Definition: main.c:80
static void ut_test_rpc_item_to_ios_cob_req(void)
Definition: obj.c:938
static struct m0_clink l[NR]
Definition: chan.c:37
void(* leo_get)(const struct m0_layout_enum *e, uint32_t idx, const struct m0_fid *gfid, struct m0_fid *out)
Definition: layout.h:437
static void ut_test_obj_lid_assign(void)
Definition: obj.c:661
static void ut_test_m0_op_obj_invariant(void)
Definition: obj.c:240
struct m0_fid li_gfid
Definition: layout.h:587
struct m0_reqh_service_ctx * pds_ctx
Definition: pool.h:74
static int ut_m0_ops_instance_build(struct m0_layout *layout, const struct m0_fid *fid, struct m0_layout_instance **linst)
Definition: obj.c:112
int m0_entity_create(struct m0_fid *pool, struct m0_entity *entity, struct m0_op **op)
Definition: obj.c:801
static struct m0_client cinst
Definition: sync.c:84
struct m0_sm_ast ar_ast
const char * ts_name
Definition: ut.h:99
struct m0_fop_data f_data
Definition: fop.h:82
M0_INTERNAL void ut_striped_layout_init(struct m0_striped_layout *stl, struct m0_layout_domain *dom)
Definition: obj.c:180
static void ut_test_cob_ios_fop_populate(void)
Definition: obj.c:1156
struct m0_pdclust_tgt_addr tgt
Definition: fd.c:110
struct m0_sm_group op_sm_group
Definition: client.h:654
bool le_sl_is_set
Definition: layout.h:417
static bool m0_op_common_invariant(struct m0_op_common *oc)
Definition: obj.c:67
M0_INTERNAL bool m0_op_obj_ast_rc_invariant(struct m0_ast_rc *ar)
Definition: obj.c:73
static void ut_test_cob_req_invariant(void)
Definition: obj.c:291
static int obj_namei_op_init(struct m0_entity *entity, struct m0_op *op)
Definition: obj.c:462
const struct m0_layout_instance_ops * li_ops
Definition: layout.h:593
M0_INTERNAL void m0_layout_domain_cleanup(struct m0_layout_domain *dom)
Definition: layout.c:653
Definition: fid.h:38
uint64_t f_key
Definition: fid.h:40
M0_INTERNAL void m0_sm_init(struct m0_sm *mach, const struct m0_sm_conf *conf, uint32_t state, struct m0_sm_group *grp)
Definition: sm.c:313
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static struct m0_realm realm
Definition: sync.c:87
int(* lto_register)(struct m0_layout_domain *dom, const struct m0_layout_type *lt)
Definition: layout.h:378
struct m0_entity * op_entity
Definition: client.h:660
M0_INTERNAL void ut_layout_init(struct m0_layout *layout, struct m0_layout_domain *dom)
Definition: obj.c:159
static struct m0_layout_type ut_layout_type
Definition: obj.c:63
static void ut_test_cob_complete_op(void)
Definition: obj.c:808
uint32_t pa_P
Definition: pdclust.h:115
struct m0_fop_type m0_fop_cob_create_fopt
Definition: io_fops.c:75
M0_INTERNAL void m0_sm_move(struct m0_sm *mach, int32_t rc, int state)
Definition: sm.c:485
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
struct m0_layout sl_base
Definition: layout.h:574
M0_INTERNAL int m0_layout_type_register(struct m0_layout_domain *dom, struct m0_layout_type *lt)
Definition: layout.c:707
static struct m0_fop * fop
Definition: item.c:57
struct m0_striped_layout * le_sl
Definition: layout.h:420
static void ut_test_m0_cob_ios_fop_fini(void)
Definition: obj.c:1244
void m0_obj_init(struct m0_obj *obj, struct m0_realm *parent, const struct m0_uint128 *id, uint64_t layout_id)
Definition: client.c:403
struct m0_rpc_item_type ft_rpc_item_type
Definition: fop.h:235
static int entity_namei_op(struct m0_entity *entity, struct m0_op **op, enum m0_entity_opcode opcode)
Definition: obj.c:743
static struct m0 instance
Definition: main.c:78
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
static struct m0_layout_enum * ut_lio_ops_to_enum(const struct m0_layout_instance *li)
Definition: obj.c:95
static void ut_test_cob_rio_mds_replied(void)
Definition: obj.c:1281
static void m0_fi_enable_once(const char *func, const char *tag)
Definition: finject.h:301
M0_INTERNAL void m0_layout_type_unregister(struct m0_layout_domain *dom, struct m0_layout_type *lt)
Definition: layout.c:741
struct m0_fop * oo_mds_fop
int m0_entity_delete(struct m0_entity *entity, struct m0_op **op)
Definition: obj.c:824
static int obj_op_obj_init(struct m0_op_obj *oo)
Definition: obj.c:592
void m0_container_init(struct m0_container *con, struct m0_realm *parent, const struct m0_uint128 *id, struct m0_client *instance)
Definition: realm.c:31
M0_INTERNAL void m0_layout__init(struct m0_layout *l, struct m0_layout_domain *dom, uint64_t lid, struct m0_layout_type *lt, const struct m0_layout_ops *ops)
Definition: layout.c:321
struct m0_client * re_instance
Definition: client.h:873
struct m0_ut_suite ut_suite_obj
Definition: obj.c:1512
static struct m0_fop_type * ft[]
Definition: service_ut.c:856
M0_INTERNAL int m0__obj_layout_instance_build(struct m0_client *cinst, const uint64_t layout_id, const struct m0_fid *fid, struct m0_layout_instance **linst)
Definition: obj.c:403
static const struct m0_bob_type enum_bob
Definition: obj.c:142
struct m0_fid b_pfid
Definition: md_fops.h:91
static void ut_layout_enum_get(const struct m0_layout_enum *e, uint32_t idx, const struct m0_fid *gfid, struct m0_fid *out)
Definition: obj.c:73
static void ut_test_obj_op_prepare(void)
Definition: obj.c:524
Definition: nucleus.c:42
#define OP_OBJ2CODE(op_obj)
static void cob_fail_op(struct m0_op *op, int rc)
Definition: cob.c:489
M0_INTERNAL void m0_layout_put(struct m0_layout *l)
Definition: layout.c:893
M0_INTERNAL void m0_fid_convert_gob2cob(const struct m0_fid *gob_fid, struct m0_fid *cob_fid, uint32_t device_id)
Definition: fid_convert.c:55
#define out(...)
Definition: gen.c:41
static void ut_test_entity_namei_op_create(void)
Definition: obj.c:648
struct m0_layout_instance * oo_layout_instance
struct m0_fid gfid
Definition: dir.c:626
struct m0_dirent * ent
Definition: dir.c:1029
static void ut_test_m0_entity_create(void)
Definition: obj.c:690
void(* oc_cb_launch)(struct m0_op_common *oc)
struct m0_fom_ops ops
Definition: io_foms.c:623
uint64_t u_lo
Definition: types.h:37
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL void m0_layout__populate(struct m0_layout *l, uint32_t user_count)
Definition: layout.c:355
struct m0_rpc_item f_item
Definition: fop.h:83
uint32_t sm_state
Definition: sm.h:307
struct m0_pdclust_attr pv_attr
Definition: pool.h:122
static void ut_test_obj_namei_op_init(void)
Definition: obj.c:389
int32_t rc
Definition: trigger_fop.h:47
static bool obj_op_obj_invariant(struct m0_op_obj *oo)
Definition: obj.c:95
struct m0_mutex op_priv_lock
Definition: client.h:685
#define offsetof(typ, memb)
Definition: misc.h:29
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct m0_sm_conf m0_op_conf
Definition: client.c:145
static void ut_test_cob_rio_ios_replied(void)
Definition: obj.c:1148
Definition: fop.h:79
static void ut_test_m0__oo_instance(void)
Definition: obj.c:779
static void ut_test_m0__obj_layout_instance_build(void)
Definition: obj.c:340
static void ut_test_m0_fid_print(void)
Definition: obj.c:373
M0_INTERNAL struct m0_client * m0__entity_instance(const struct m0_entity *entity)
Definition: client.c:226
M0_INTERNAL void m0_sm_fini(struct m0_sm *mach)
Definition: sm.c:331
static void ut_test_icr_ast_fail(void)
Definition: obj.c:1058