Motr  M0
cob_foms.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 #include "ioservice/cob_foms.c" /* to access static APIs */
24 
25 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_COB
26 #include "lib/trace.h"
27 
28 #include "ioservice/ut/bulkio_common.h" /* cob_attr_default_fill */
29 #include "mdservice/fsync_fops.h" /* m0_fop_fsync */
30 #include "rpc/rpclib.h" /* m0_rpc_server_ctx */
31 #include "rpc/rpc_opcodes.h" /* M0_UT_IOS_OPCODE */
32 #include "rpc/rpc_machine.h" /* m0_rpc_machine_lock */
33 #include "stob/type.h" /* m0_stob_type */
34 #include "stob/ad.h" /* m0_stob_ad_type */
35 #include "stob/linux.h" /* m0_stob_linux_type */
36 #include "ut/cs_fop.h" /* m0_ut_fom_phase_set */
37 #include "ut/misc.h" /* M0_UT_PATH */
38 #include "ut/ut.h"
39 
42 
44 extern struct m0_reqh_service_type m0_ios_type;
45 
46 /* Static instance of struct cobfoms_ut used by all test cases. */
47 static struct cobfoms_ut *cut;
48 static struct m0_fom_locality dummy_loc;
49 
50 static struct m0_cob *test_cob = NULL;
51 static struct m0_fom_type ft;
52 
53 static bool cc_cob_create_test_done = false;
54 
55 static struct m0_fom *cd_fom_alloc();
56 static void cd_fom_dealloc(struct m0_fom *fom);
57 static void fom_dtx_init(struct m0_fom *fom, struct m0_sm_group *grp,
58  enum m0_cob_op opcode);
59 static void fom_stob_tx_credit(struct m0_fom *fom, enum m0_cob_op opcode);
60 static void fom_dtx_done(struct m0_fom *fom, struct m0_sm_group *grp);
61 static void cd_stob_delete_test();
62 
66 };
67 
68 enum {
77  POOL_WIDTH = 10,
78  COB_TEST_KEY = 111,
79 };
80 
81 static char COB_FOP_NR_STR[] = { '0' + COB_FOP_NR, '\0'};
82 
83 #define SERVER_EP_ADDR "0@lo:12345:34:1"
84 #define CLIENT_EP_ADDR "0@lo:12345:34:*"
85 #define SERVER_ENDP M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_EP_ADDR
86 
87 static const char *SERVER_LOGFILE = "cobfoms_ut.log";
88 
89 struct cobfoms_ut {
92  uint64_t cu_cobfop_nr;
95  struct m0_fid cu_gfid;
96  struct m0_fid cu_cfid;
100  uint64_t cu_thread_nr;
102  uint64_t cu_gobindex;
103 };
104 
107  int ca_index;
108  int ca_rc;
109  uint64_t ca_flags;
110 };
111 
112 static char *server_args[] = {
113  "m0d", "-T", "AD", "-D", "cobfoms_ut.db", "-S",
114  "cobfoms_ut_stob", "-A", "linuxstob:cobfoms_ut_addb_stob",
115  "-w", "10", "-e", SERVER_ENDP, "-H", SERVER_EP_ADDR,
116  "-f", M0_UT_CONF_PROCESS,
117  "-q", COB_FOP_NR_STR,
118  "-c", M0_UT_PATH("diter.xc")
119 };
120 
121 static void cobfoms_utinit(void)
122 {
123  int rc;
124  struct m0_rpc_server_ctx *sctx;
125  struct m0_rpc_client_ctx *cctx;
126 
127  M0_ALLOC_PTR(cut);
128  M0_UT_ASSERT(cut != NULL);
129 
131 
133  M0_UT_ASSERT(rc == 0);
134 
135  sctx = &cut->cu_sctx;
136  sctx->rsx_xprts = &cut->cu_xprt;
137  sctx->rsx_xprts_nr = 1;
141 
143  M0_UT_ASSERT(rc == 0);
144 
145  cctx = &cut->cu_cctx;
146  cctx->rcx_net_dom = &cut->cu_nd;
152 
155 
157  M0_UT_ASSERT(rc == 0);
158 
159  cut->cu_gobindex = 0;
160 }
161 
162 static void cobfoms_utfini(void)
163 {
164  int rc;
165 
166  M0_UT_ASSERT(cut != NULL);
167 
169  M0_UT_ASSERT(rc == 0);
170 
173  m0_free0(&cut);
174 }
175 
176 static void cobfops_populate_internal(struct m0_fop *fop, uint64_t gob_fid_key)
177 {
178  struct m0_fop_cob_common *common;
179  struct m0_cob_attr attr = { { 0, } };
180 
182  attr.ca_nlink = fop->f_type == &m0_fop_cob_create_fopt ? 1 : 0;
183 
184  M0_UT_ASSERT(fop != NULL);
186 
187  common = m0_cobfop_common_get(fop);
188  m0_fid_gob_make(&common->c_gobfid, 1 + gob_fid_key % POOL_WIDTH,
189  GOB_FID_KEY_ID + gob_fid_key);
190  m0_fid_convert_gob2cob(&common->c_gobfid, &common->c_cobfid,
192  attr.ca_pver = common->c_pver = CONF_PVER_FID;
193  m0_md_cob_mem2wire(&common->c_body, &attr);
194 }
195 
196 static void cobfops_populate(uint64_t index)
197 {
198  struct m0_fop *fop;
199 
200  M0_UT_ASSERT(cut != NULL);
203 
208  cut->cu_gobindex++;
209 }
210 
211 static void cobfops_create(void)
212 {
213  uint64_t i;
214  struct m0_rpc_machine *mach;
215 
216  M0_UT_ASSERT(cut != NULL);
219 
222 
225 
227  for (i = 0; i < cut->cu_cobfop_nr; ++i) {
229  NULL, mach);
231 
233  NULL, mach);
236  }
237 }
238 
239 static void cobfops_destroy(struct m0_fop_type *ftype1,
240  struct m0_fop_type *ftype2)
241 {
242  uint64_t i;
243 
244  M0_UT_ASSERT(cut != NULL);
247  M0_UT_ASSERT(ftype1 == NULL || ftype1 == &m0_fop_cob_create_fopt);
248  M0_UT_ASSERT(ftype2 == NULL || ftype2 == &m0_fop_cob_delete_fopt);
249 
251  if (ftype1 != NULL)
252  for (i = 0; i < cut->cu_cobfop_nr; ++i)
254 
255  if (ftype2 != NULL)
256  for (i = 0; i < cut->cu_cobfop_nr; ++i)
259 
262 }
263 
264 static void cobfops_threads_init(void)
265 {
266  int i;
267 
268  M0_UT_ASSERT(cut != NULL);
270 
273 
274  for (i = 0; i < cut->cu_thread_nr; ++i) {
277  }
278 }
279 
280 static void cobfops_threads_fini(void)
281 {
282  int i;
283 
284  M0_UT_ASSERT(cut != NULL);
287 
288  for (i = 0; i < cut->cu_thread_nr; ++i)
289  m0_free(cut->cu_threads[i]);
291 }
292 
293 static void cobfops_send_wait(struct cobthread_arg *arg)
294 {
295  int i;
296  int rc;
297  struct m0_fop *fop;
298  struct m0_fop_cob_op_reply *rfop;
299  struct m0_fop_cob_common *common;
300 
301  M0_UT_ASSERT(cut != NULL);
302  M0_UT_ASSERT(arg != NULL);
303  M0_UT_ASSERT(arg->ca_ftype != NULL);
304 
305  i = arg->ca_index;
306  M0_LOG(M0_DEBUG, "i=%d", i);
308  cut->cu_deletefops[i];
309 
310  common = m0_cobfop_common_get(fop);
311  common->c_flags = arg->ca_flags;
312  common->c_pver = CONF_PVER_FID;
313  M0_LOG(M0_DEBUG, "gobfid="FID_F" cobfid="FID_F,
314  FID_P(&common->c_gobfid), FID_P(&common->c_cobfid));
315 
317  0 /* deadline */);
318  M0_UT_ASSERT(rc == 0);
320  M0_UT_ASSERT(rc == 0);
322  M0_UT_ASSERT(rfop->cor_rc == arg->ca_rc);
323 }
324 
325 static void cobfoms_fops_dispatch(struct m0_fop_type *ftype, uint64_t flags,
326  int expected_rc)
327 {
328  int rc;
329  uint64_t i;
330  struct cobthread_arg *arg;
331 
332  M0_UT_ASSERT(ftype != NULL);
333  M0_UT_ASSERT(cut != NULL);
338 
340  M0_UT_ASSERT(arg != NULL);
341 
342  for (i = 0; i < cut->cu_cobfop_nr; ++i) {
343  arg[i].ca_ftype = ftype;
344  arg[i].ca_index = i;
345  arg[i].ca_flags = flags;
346  arg[i].ca_rc = expected_rc;
347  M0_SET0(cut->cu_threads[i]);
349  NULL, &cobfops_send_wait, &arg[i],
350  ftype == &m0_fop_cob_create_fopt ?
351  "cob_create" : "cob_delete");
352  M0_UT_ASSERT(rc == 0);
353  }
354 
355  for (i = 0; i < cut->cu_cobfop_nr; ++i)
357 
358  m0_free(arg);
359 }
360 
361 static void cobfoms_fop_thread_init(uint64_t fop_nr, uint64_t thread_nr)
362 {
363  M0_UT_ASSERT(fop_nr > 0 && thread_nr > 0);
364  M0_UT_ASSERT(cut != NULL);
365 
366  cut->cu_cobfop_nr = fop_nr;
367  cobfops_create();
368  cut->cu_thread_nr = thread_nr;
370 }
371 
372 static void cobfoms_fop_thread_fini(struct m0_fop_type *ftype1,
373  struct m0_fop_type *ftype2)
374 {
375  cobfops_destroy(ftype1, ftype2);
377 }
378 
379 static void cobfoms_send_internal(struct m0_fop_type *ftype1,
380  struct m0_fop_type *ftype2,
381  uint64_t flags,
382  int rc1, int rc2,
383  uint64_t nr)
384 {
386 
387  if (ftype1 != NULL)
388  cobfoms_fops_dispatch(ftype1, flags, rc1);
389  if (ftype2 != NULL)
390  cobfoms_fops_dispatch(ftype2, flags, rc2);
391 
392  cobfoms_fop_thread_fini(ftype1, ftype2);
393 }
394 
395 static void cobfoms_single(void)
396 {
398  0, 0, 0, COB_FOP_SINGLE);
399 }
400 
401 /*
402  * Sends multiple cob_create fops to same ioservice instance
403  * so as to stress the fom code with multiple simultaneous requests.
404  */
405 static void cobfoms_multiple(void)
406 {
408  0, 0, 0, COB_FOP_NR);
409 }
410 
411 static void cobfoms_preexisting_cob(void)
412 {
415 
416  /*
417  * Get the value of cobfoms_ut::cu_gobindex to send cob_create
418  * fop and subsequence cob_delete fop with same fid.
419  */
420  --cut->cu_gobindex;
423 
424  --cut->cu_gobindex;
425 
426  /* Cleanup. */
429  cut->cu_gobindex++;
430  cut->cu_gobindex++;
431 }
432 
433 static void cobfoms_del_nonexist_cob(void)
434 {
438  0, 0, COB_FOP_SINGLE);
439 }
440 
450 static void cobfoms_fsync_send_fop(struct m0_be_tx_remid *remid,
451  int expected_rc);
452 
457 static void cobfoms_fsync_nonexist_tx(void)
458 {
459  struct m0_be_tx_remid remid;
460 
461  remid.tri_txid = 666;
462  remid.tri_locality = 0;
463 
464  cobfoms_fsync_send_fop(&remid, 0);
465 }
466 
467 static void cobfoms_fsync_send_fop(struct m0_be_tx_remid *remid,
468  int expected_rc)
469 {
470  int rc;
471  struct m0_fop *fop;
472  struct m0_fop_fsync *ffop;
473  struct m0_fop_fsync_rep *rfop;
474  struct m0_rpc_machine *machine;
475 
477 
478  /* create a fop from fsync_fopt */
480 
481  /* populate fop */
482  ffop = m0_fop_data(fop);
483  ffop->ff_be_remid.tri_txid = remid->tri_txid;
484  ffop->ff_be_remid.tri_locality = remid->tri_locality;
486 
487  /* send fop */
489  NULL, 0 /* deadline */);
490  M0_UT_ASSERT(rc == 0);
492  M0_UT_ASSERT(rc == 0);
494 
495  /* such tx shouldn't exist */
496  M0_UT_ASSERT(rfop->ffr_rc == expected_rc);
497  M0_UT_ASSERT(rfop->ffr_be_remid.tri_txid == remid->tri_txid);
498 
499  /* release structs */
501 }
502 
509 {
510  int rc;
511  int i;
512  struct m0_fop **fops;
513  struct m0_fop_cob_op_reply *rfop;
514  /* how many create-delete pairs are we issuing? */
515  uint32_t cobfop_nr = 5;
516  struct m0_be_tx_remid remid;
517  struct m0_rpc_machine *machine;
518 
520 
521  /* allocate the required fops */
522  M0_ALLOC_ARR(fops, cobfop_nr*2);
523  M0_UT_ASSERT(fops != NULL);
524 
525  /* fill the aux fop arrays with create-delete pairs */
526  for (i = 0; i < cobfop_nr; ++i ) {
527  /* allocate and fill with the right fid */
529  M0_UT_ASSERT(fops[i] != NULL);
531 
532  fops[i+cobfop_nr] = m0_fop_alloc(&m0_fop_cob_delete_fopt,
533  NULL, machine);
534  M0_UT_ASSERT(fops[i+cobfop_nr] != NULL);
535  cobfops_populate_internal(fops[i+cobfop_nr], cut->cu_gobindex);
536 
537  /* cu_goibindex is shared across all the suite's tests */
538  ++cut->cu_gobindex;
539  }
540 
541  /* send the fops and keep the txid returned by the last one */
542  for (i = 0; i < cobfop_nr*2; ++i ) {
543  /* sequentially, no need to use threads here */
545  NULL, 0 /* deadline */);
546  M0_UT_ASSERT(rc == 0);
548  &fops[i]->f_item, M0_TIME_NEVER);
549  M0_UT_ASSERT(rc == 0);
550  rfop = (struct m0_fop_cob_op_reply *)
551  m0_fop_data(
552  m0_rpc_item_to_fop(fops[i]->f_item.ri_reply));
553  M0_UT_ASSERT(rfop->cor_rc == 0);
554  remid.tri_txid =
556  remid.tri_locality =
558  }
559 
560  /* now try to fsync the last transaction and check the op. succeeds */
561  cobfoms_fsync_send_fop(&remid, 0);
562 
563  /* release all the fops */
564  for (i = 0; i < cobfop_nr*2; ++i) {
565  m0_fop_put_lock(fops[i]);
566  }
567  m0_free(fops);
568 }
569 
570 extern const struct m0_sm_conf cob_ops_conf;
571 
572 /*
573  * Create COB FOMs - create or delete
574  */
575 static void fom_create(struct m0_fom **fom, enum cob_fom_type fomtype)
576 {
577  struct m0_fom *base_fom;
578  struct m0_reqh *reqh;
579  int rc;
580 
582  M0_UT_ASSERT(rc == 0);
583 
584  base_fom = *fom;
586  m0_fom_init(base_fom, &ft,
587  fomtype == COB_CREATE ? &cc_fom_ops : &cd_fom_ops,
588  NULL, NULL, reqh);
589 
591  M0_UT_ASSERT(base_fom->fo_service != NULL);
592 
593  base_fom->fo_loc = &dummy_loc;
594  m0_fom_locality_inc(base_fom);
595  base_fom->fo_type = &ft;
596 
597  m0_fom_sm_init(base_fom);
598  m0_fol_rec_init(&base_fom->fo_tx.tx_fol_rec, &reqh->rh_fol);
599 }
600 
601 /*
602  * Delete COB FOMs - create or delete
603  */
604 static void fom_fini(struct m0_fom *fom, enum cob_fom_type fomtype)
605 {
607 
608  m0_fol_rec_fini(&fom->fo_tx.tx_fol_rec);
609  switch (fomtype) {
610  case COB_CREATE:
611  cc_fom_fini(fom);
612  break;
613  case COB_DELETE:
614  cd_fom_fini(fom);
615  break;
616  default:
617  M0_IMPOSSIBLE("Invalid COB-FOM type");
618  }
619 }
620 
621 /*
622  * Allocate desired FOP and populate test-data in it.
623  */
624 static void fop_alloc(struct m0_fom *fom, enum cob_fom_type fomtype)
625 {
626  struct m0_fop_cob_common *c;
627  struct m0_fop *base_fop;
629  struct m0_cob_attr attr = { { 0, } };
630 
631  switch (fomtype) {
632  case COB_CREATE:
634  M0_UT_ASSERT(base_fop != NULL);
635  break;
636  case COB_DELETE:
638  M0_UT_ASSERT(base_fop != NULL);
639  break;
640  default:
641  M0_IMPOSSIBLE("Invalid COB-FOM type");
642  base_fop = NULL;
643  break;
644  }
645  c = m0_cobfop_common_get(base_fop);
646  c->c_pver = CONF_PVER_FID;
647  m0_fid_gob_make(&c->c_gobfid, 0, COB_TEST_KEY);
648  m0_fid_convert_gob2cob(&c->c_gobfid, &c->c_cobfid,
650 
652  attr.ca_nlink = base_fop->f_type == &m0_fop_cob_create_fopt ? 1 : 0;
653 
654  m0_md_cob_mem2wire(&c->c_body, &attr);
655 
656  c->c_cob_idx = M0_AD_STOB_DOM_KEY_DEFAULT;
657  fom->fo_fop = base_fop;
658  fom->fo_type = &base_fop->f_type->ft_fom_type;
659 
661  M0_UT_ASSERT(fom->fo_rep_fop != NULL);
662 }
663 
664 /*
665  * A generic COB-FOM-delete verification function.
666  */
667 static void fom_fini_test(enum cob_fom_type fomtype)
668 {
669  struct m0_fom *fom;
670  struct m0_reqh *reqh;
671 
672  /*
673  * 1. Allocate FOM object of interest
674  * 2. Calculate memory usage before and after object allocation
675  * and de-allocation.
676  * 3. Before taking memory record, make sure there are no
677  * stray foms around.
678  */
681  fom_create(&fom, fomtype);
682  fom_fini(fom, fomtype);
683 }
684 
685 /*
686  * A generic COB-FOM test function that validates the sub-class FOM object.
687  */
688 static void fom_get_test(enum cob_fom_type fomtype)
689 {
690  struct m0_fom *fom;
691  struct m0_fom_cob_op *cc;
692 
693  fom_create(&fom, fomtype);
694  M0_UT_ASSERT(fom != NULL);
695 
696  cc = cob_fom_get(fom);
697  M0_UT_ASSERT(cc != NULL);
698  M0_UT_ASSERT(&cc->fco_fom == fom);
699  fom_fini(fom, fomtype);
700 }
701 
702 /*
703  * A generic test to verify COM-FOM create functions.
704  */
705 static void fom_create_test(enum cob_fom_type fomtype)
706 {
707  struct m0_fom *fom;
708 
709  fom_create(&fom, fomtype);
710  M0_UT_ASSERT(fom != NULL);
711  fom_fini(fom, fomtype);
712 }
713 
714 /*
715  * Delete COB-create FOM.
716  */
717 static void cc_fom_dealloc(struct m0_fom *fom)
718 {
720 
721  cc_fom_fini(fom);
722 }
723 
724 /*
725  * Create COB-create FOM and populate it with testdata.
726  */
727 static struct m0_fom *cc_fom_alloc()
728 {
729  struct m0_fom *fom = NULL;
730 
732  M0_UT_ASSERT(fom != NULL);
733 
735  M0_UT_ASSERT(fom->fo_fop != NULL);
738 
739  return fom;
740 }
741 
742 /*
743  * Test function for cc_fom_create().
744  */
745 static void cc_fom_create_test()
746 {
748 }
749 
750 /*
751  * Test function for cc_fom_fini().
752  */
753 static void cc_fom_fini_test()
754 {
756 }
757 
758 /*
759  * Test function for cc_fom_get().
760  */
761 static void cc_fom_get_test()
762 {
764 }
765 
766 /*
767  * Test function for m0_cc_stob_create().
768  */
769 static void cc_stob_create_test()
770 {
771  int rc;
772  struct m0_fom *fom;
773  struct m0_fom_cob_op *cc;
774  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
775 
776  fom = cc_fom_alloc();
777  M0_UT_ASSERT(fom != NULL);
778 
779  cc = cob_fom_get(fom);
780 
783  rc = m0_cc_stob_create(fom, &cc->fco_stob_id);
785  fom_dtx_done(fom, grp);
786 
787  M0_UT_ASSERT(rc == 0);
788 
791 
793 }
794 
795 /*
796  * Test function to check COB record in the database.
797  */
798 static void cob_verify(struct m0_fom *fom, const bool exists)
799 {
800  int rc;
801  struct m0_cob_domain *cobdom;
802  struct m0_cob_nskey *nskey;
803  struct m0_fid gfid;
804  struct m0_fid cfid;
805  char nskey_bs[UINT32_STR_LEN];
806  uint32_t nskey_bs_len;
807  uint32_t cob_idx = M0_AD_STOB_DOM_KEY_DEFAULT;
808 
811  m0_ios_cdom_get(m0_fom_reqh(fom), &cobdom);
812  M0_UT_ASSERT(cobdom != NULL);
813 
814  snprintf(nskey_bs, UINT32_STR_LEN, "%u", cob_idx);
815  nskey_bs_len = strlen(nskey_bs);
816 
817  rc = m0_cob_nskey_make(&nskey, &gfid, nskey_bs, nskey_bs_len);
818  M0_UT_ASSERT(rc == 0);
819 
820  test_cob = NULL;
821  rc = m0_cob_lookup(cobdom, nskey, 0, &test_cob);
822 
823  if (exists) {
824  M0_UT_ASSERT(rc == 0);
827  } else
828  M0_UT_ASSERT(rc == -ENOENT);
829  if (rc != 0)
830  m0_free(nskey);
831 }
832 
833 static void md_cob_fop_create_delete_test(bool create_p,
834  const struct m0_fid *pver,
835  int expected_reply_rc)
836 {
837  struct m0_fop *fop;
838  struct m0_fop_cob_common *common;
839  struct m0_fop_cob_op_reply *reply;
840  int rc;
841 
842  cut->cu_gobindex = 0;
843  cobfops_create();
844  fop = *(create_p ? cut->cu_createfops : cut->cu_deletefops);
845  common = m0_cobfop_common_get(fop);
847  common->c_body.b_pver = *pver;
848  common->c_body.b_nlink = !!create_p;
849  common->c_cob_type = M0_COB_MD;
851  0 /* deadline */);
852  M0_UT_ASSERT(rc == 0);
854  M0_UT_ASSERT(rc == 0);
856  M0_UT_ASSERT(reply->cor_rc == expected_reply_rc);
858 }
859 
860 static void md_cob_create_delete()
861 {
862  M0_UT_ASSERT(cut != NULL);
863  cut->cu_cobfop_nr = 2;
865  /* Create the same mdcob again. */
867  /* Create the same mdcob with different pool version. */
869  /* Delete the mdcob. */
871 }
872 
873 /*
874  * Test function for cc_cob_create().
875  */
876 static void cc_cob_create_test()
877 {
878  int rc;
879  struct m0_fom *fom;
880  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
881  struct m0_fom_cob_op *cc;
882  struct m0_cob_attr attr = { { 0, } };
883 
885 
886  fom = cc_fom_alloc();
887  M0_UT_ASSERT(fom != NULL);
888  cc = cob_fom_get(fom);
889 
890  /* Create md cob */
892  rc = m0_dtx_open_sync(&fom->fo_tx);
893  M0_UT_ASSERT(rc == 0);
894  cc->fco_cob_type = M0_COB_MD;
895  rc = cc_cob_create(fom, cc, &attr);
897  M0_UT_ASSERT(rc == 0);
898  else
899  M0_UT_ASSERT(rc == -EEXIST);
900  fom_dtx_done(fom, grp);
901  cc->fco_cob_type = M0_COB_IO;
902  /*
903  * Set the FOM phase and set transaction context
904  * Test-case 1: Test successful creation of COB
905  */
906 
909  /*
910  * Create STOB first.
911  */
912  rc = m0_cc_stob_create(fom, &cc->fco_stob_id);
913  /* stob may be already created by another test */
914  M0_UT_ASSERT(M0_IN(rc, (0, -EEXIST)));
915 
916  rc = cc_cob_create(fom, cc, &attr);
917  fom_dtx_done(fom, grp);
918 
920  M0_UT_ASSERT(rc == 0);
921 
922  /*
923  * Test-case 1 - Verify COB creation
924  */
925  cob_verify(fom, true);
926 
927  /*
928  * Test-case 2 - Test failure case. Try to create the
929  * same COB.
930  */
932  rc = m0_dtx_open_sync(&fom->fo_tx);
933  M0_UT_ASSERT(rc == 0);
934  rc = cc_cob_create(fom, cc, &attr);
935  M0_UT_ASSERT(rc != 0);
936  fom_dtx_done(fom, grp);
937 
938  /*
939  * Start cleanup by deleting the COB
940  */
942  rc = m0_dtx_open_sync(&fom->fo_tx);
943  M0_UT_ASSERT(rc == 0);
945  M0_UT_ASSERT(rc == 0);
946  fom_dtx_done(fom, grp);
947  test_cob = NULL;
948 
952 }
953 
954 /*
955  * Test function for create.
956  */
957 static void cc_fom_state_test(void)
958 {
959  int rc;
960  struct m0_fom *cfom;
961  struct m0_fom *dfom;
962  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
963 
964  /* delete existing stob */
966 
967  cfom = cc_fom_alloc();
968  M0_UT_ASSERT(cfom != NULL);
969 
972  rc = cob_ops_fom_tick(cfom);
973  M0_UT_ASSERT(m0_fom_rc(cfom) == 0);
975  rc = cob_ops_fom_tick(cfom);
976  fom_dtx_done(cfom, grp);
977 
980 
981  cob_verify(cfom, true);
982 
983  /*
984  * Now create delete fom. Use FOM functions to delete cob-data.
985  */
986  dfom = cd_fom_alloc();
987  M0_UT_ASSERT(dfom != NULL);
988 
991  m0_stob_delete_mark(cob_fom_get(dfom)->fco_stob);
992  rc = cob_ops_fom_tick(dfom); /* for M0_FOPH_COB_OPS_PREPARE */
994  rc = cob_ops_fom_tick(dfom); /* for M0_FOPH_COB_OPS_EXECUTE */
997 
998  fom_dtx_done(dfom, grp);
999 
1000  cc_fom_dealloc(cfom);
1001  cd_fom_dealloc(dfom);
1002 }
1003 
1004 /*
1005  * Test function for cc_fom_populate().
1006  */
1008 {
1009  struct m0_fom *fom;
1010  struct m0_fom_cob_op *cc;
1011 
1012  fom = cc_fom_alloc();
1013  M0_UT_ASSERT(fom != NULL);
1014 
1015  cc = cob_fom_get(fom);
1016  M0_UT_ASSERT(cc->fco_cfid.f_key == COB_TEST_KEY);
1017  M0_UT_ASSERT(m0_fid_cob_device_id(&cc->fco_cfid) ==
1022 }
1023 
1024 /*
1025  *****************
1026  * COB delete-FOM test functions
1027  ******************
1028  */
1029 
1030 /*
1031  * Delete COB-delete FOM object.
1032  */
1033 static void cd_fom_dealloc(struct m0_fom *fom)
1034 {
1036  cd_fom_fini(fom);
1037 }
1038 
1039 /*
1040  * Create COB-delete FOM and populate it with testdata.
1041  */
1042 static struct m0_fom *cd_fom_alloc()
1043 {
1044  struct m0_fom *fom = NULL;
1045 
1047  M0_UT_ASSERT(fom != NULL);
1048 
1050  M0_UT_ASSERT(fom->fo_fop != NULL);
1053 
1054  return fom;
1055 }
1056 
1057 /*
1058  * Test function for cd_fom_create().
1059  */
1060 static void cd_fom_create_test()
1061 {
1063 }
1064 
1065 /*
1066  * Test function for cd_fom_fini().
1067  */
1068 static void cd_fom_fini_test()
1069 {
1071 }
1072 
1073 /*
1074  * Test function for cd_fom_get().
1075  */
1076 static void cd_fom_get_test()
1077 {
1079 }
1080 
1081 /*
1082  * Test function for cd_fom_populate().
1083  */
1085 {
1086  struct m0_fom *fom;
1087  struct m0_fom_cob_op *cd;
1088 
1089  fom = cd_fom_alloc();
1090  M0_UT_ASSERT(fom != NULL);
1091 
1092  cd = cob_fom_get(fom);
1099 }
1100 
1101 /*
1102  * Before testing COB-delete FOM functions, create COB testdata.
1103  */
1104 static struct m0_fom *cob_testdata_create()
1105 {
1106  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
1107  struct m0_fom *fom;
1108  int rc;
1109 
1110  /*
1111  * Create cob-create FOM.
1112  * Crate COB and related meta-data.
1113  */
1114  fom = cc_fom_alloc();
1115  M0_UT_ASSERT(fom != NULL);
1116 
1119  rc = cob_ops_fom_tick(fom);
1120  M0_UT_ASSERT(m0_fom_rc(fom) == 0);
1122  rc = cob_ops_fom_tick(fom);
1123  fom_dtx_done(fom, grp);
1124 
1127 
1128  return fom;
1129 }
1130 
1131 /*
1132  * Delete COB testdata. In this case we delete COB-create FOM.
1133  */
1134 static void cob_testdata_cleanup(struct m0_fom *fom)
1135 {
1137 }
1138 
1139 /*
1140  * Test function for cd_stob_delete()
1141  */
1142 static void cd_stob_delete_test()
1143 {
1144  struct m0_fom_cob_op *cd;
1145  struct m0_fom_cob_op *cc;
1146  struct m0_fom *cfom;
1147  struct m0_fom *dfom;
1148  int rc;
1149  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
1150 
1151  cfom = cc_fom_alloc();
1152  M0_UT_ASSERT(cfom != NULL);
1153  cc = cob_fom_get(cfom);
1156  rc = m0_cc_stob_create(cfom, &cc->fco_stob_id);
1157  M0_UT_ASSERT(M0_IN(rc, (0, -EEXIST)));
1158  fom_dtx_done(cfom, grp);
1159 
1160  /* Test stob delete after it has been created */
1161  dfom = cd_fom_alloc();
1162  M0_UT_ASSERT(dfom != NULL);
1163 
1164  cd = cob_fom_get(dfom);
1168  rc = ce_stob_edit(dfom, cd, M0_COB_OP_DELETE);
1170  M0_ASSERT(rc == 0);
1171  fom_dtx_done(dfom, grp);
1172 
1175  cd_fom_dealloc(dfom);
1178  cc_fom_dealloc(cfom);
1179 }
1180 
1181 /*
1182  * Test function for cd_cob_delete()
1183  */
1184 static void cd_cob_delete_test()
1185 {
1186  int rc;
1187  struct m0_fom *cfom;
1188  struct m0_fom *dfom;
1189  struct m0_fom_cob_op *cd;
1190  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
1191  struct m0_cob_attr attr = { { 0, } };
1192 
1193  attr.ca_ctime = 1416970585;
1194  attr.ca_nlink = 0;
1195  attr.ca_valid = M0_COB_CTIME | M0_COB_NLINK;
1196 
1197 
1198  cfom = cob_testdata_create();
1199 
1200  /* Test COB delete after COB has been created */
1201  dfom = cd_fom_alloc();
1202  M0_UT_ASSERT(dfom != NULL);
1203 
1204  cd = cob_fom_get(dfom);
1205  /*
1206  * Test-case 1: Delete cob. The test should succeed.
1207  */
1209  rc = m0_dtx_open_sync(&dfom->fo_tx);
1210  M0_UT_ASSERT(rc == 0);
1211  rc = cd_cob_delete(dfom, cd, &attr);
1213  M0_UT_ASSERT(rc == 0);
1214 
1215  fom_dtx_done(dfom, grp);
1216 
1217  /*
1218  * Make sure that there no entry in the database.
1219  */
1220  cob_verify(cfom, false);
1221 
1222  /*
1223  * Test-case 2: Delete cob again. The test should fail.
1224  */
1228  rc = cd_cob_delete(dfom, cd, &attr);
1229  M0_UT_ASSERT(rc != 0);
1230 
1231  /*
1232  * Now do the cleanup.
1233  */
1234  rc = ce_stob_edit(dfom, cd, M0_COB_OP_DELETE);
1235  M0_UT_ASSERT(rc == 0);
1236  fom_dtx_done(dfom, grp);
1237 
1240  cd_fom_dealloc(dfom);
1241  cob_testdata_cleanup(cfom);
1242 }
1243 
1244 /*
1245  * Test function for cob_ops_fom_tick()
1246  */
1247 static void cd_fom_state_test(void)
1248 {
1249  struct m0_fom *cfom;
1250  struct m0_fom *dfom;
1251  struct m0_sm_group *grp = m0_locality0_get()->lo_grp;
1252  int rc;
1253 
1254  cfom = cob_testdata_create();
1255 
1256  /* Test if COB-map got deleted */
1257  dfom = cd_fom_alloc();
1258  M0_UT_ASSERT(dfom != NULL);
1259 
1262  m0_stob_delete_mark(cob_fom_get(dfom)->fco_stob);
1263  rc = cob_ops_fom_tick(dfom);
1265  rc = cob_ops_fom_tick(dfom);
1268  fom_dtx_done(dfom, grp);
1269 
1270 
1271  cd_fom_dealloc(dfom);
1272  cob_testdata_cleanup(cfom);
1273 }
1274 
1276 {
1279  m0_locality_lockers_init(&dummy_loc.fl_locality);
1280 }
1281 
1282 static void cob_create_api_test(void)
1283 {
1284  /* Dummy locality setup */
1287 
1288  /* Test for cc_fom_create() */
1290 
1291  /* Test for cc_fom_fini() */
1292  cc_fom_fini_test();
1293 
1294  /* Test for cc_fom_get() */
1295  cc_fom_get_test();
1296 
1297  /* Test cc_fom_populate() */
1299 
1300  /* Test m0_cc_stob_create() */
1302 
1303  /* Test cc_cob_create() */
1305  cc_cob_create_test_done = true;
1306 
1307  /* Test for cob_ops_fom_tick() */
1309 
1311 }
1312 
1313 static void cob_delete_api_test(void)
1314 {
1316 
1317  /* Test for cd_fom_create() */
1319 
1320  /* Test for cd_fom_fini() */
1321  cd_fom_fini_test();
1322 
1323  /* Test for cd_fom_fini() */
1324  cd_fom_get_test();
1325 
1326  /* Test cd_fom_populate() */
1328 
1329  /* Test cd_stob_delete() */
1331 
1332  /* Test cd_cob_delete() */
1334 
1335  /* Test for cob_ops_fom_tick() */
1337 
1339 }
1340 
1341 # if 0
1342 #define COB_DATA(data) M0_XCODE_OBJ(m0_fop_cob_common_xc, data)
1343 
1344 static int cob_cd_op(struct m0_fol_rec *rec, struct m0_fop *fop, bool undo) {
1345  struct m0_fol_frag *dec_frag;
1346  struct m0_fop_cob_common *cob_cmn;
1347  int result = 0;
1348 
1349  cob_cmn = m0_cobfop_common_get(fop);
1350  m0_tl_for(m0_rec_frag, &rec->fr_frags, dec_frag) {
1351  if (dec_frag->rp_ops->rpo_type->rpt_index ==
1353  struct m0_fop_cob_common *cob_data;
1354  struct m0_fop_fol_frag *fp_frag;
1355  struct m0_fop_type *ftype;
1356  struct m0_fop_cob_op_reply *cob_rep;
1357 
1358  fp_frag = dec_frag->rp_data;
1359  cob_rep = fp_frag->ffrp_rep;
1360 
1361  cob_data = m0_is_cob_create_fop(fop) ?
1362  &((struct m0_fop_cob_create *)
1363  fp_frag->ffrp_fop)->cc_common :
1364  &((struct m0_fop_cob_delete *)
1365  fp_frag->ffrp_fop)->cd_common;
1366 
1367  M0_UT_ASSERT(m0_xcode_cmp(&COB_DATA(cob_data),
1368  &COB_DATA(cob_cmn)) == 0);
1369  M0_UT_ASSERT(cob_rep->cor_rc == 0);
1370 
1371  ftype = m0_fop_type_find(fp_frag->ffrp_fop_code);
1372  M0_UT_ASSERT(ftype != NULL);
1373  M0_UT_ASSERT(ftype->ft_ops->fto_undo != NULL &&
1374  ftype->ft_ops->fto_redo != NULL);
1375  result = undo ?
1376  ftype->ft_ops->fto_undo(fp_frag, rec->fr_fol) :
1377  ftype->ft_ops->fto_redo(fp_frag, rec->fr_fol);
1378  M0_UT_ASSERT(result == 0);
1379  }
1380  } m0_tl_endfor;
1381 
1382  return result;
1383 }
1384 
1385 static void cobfoms_fol_verify(void)
1386 {
1387  struct m0_reqh *reqh;
1388  struct m0_fol_rec dec_cc_rec;
1389  struct m0_fol_rec dec_cd_rec;
1390  int result;
1391  struct m0_fop *c_fop;
1392  struct m0_fop *d_fop;
1393  struct m0_be_tx *cctx;
1394  struct m0_be_tx *cdtx;
1395 
1399 
1400  c_fop = cut->cu_createfops[0];
1401  d_fop = cut->cu_deletefops[0];
1402 
1404  result = m0_fol_rec_lookup(reqh->rh_fol,
1405  reqh->rh_fol->f_lsn - 2, &dec_cc_rec);
1406  M0_UT_ASSERT(result == 0);
1407  M0_UT_ASSERT(dec_cc_rec.fr_header.rh_frags_nr == 1);
1408 
1409  result = m0_fol_rec_lookup(reqh->rh_fol,
1410  reqh->rh_fol->f_lsn - 1, &dec_cd_rec);
1411  M0_UT_ASSERT(result == 0);
1412  M0_UT_ASSERT(dec_cd_rec.fr_header.rh_frags_nr == 1);
1413 
1414  /* Perform undo operations */
1415  result = cob_cd_op(&dec_cd_rec, d_fop, true);
1416  M0_UT_ASSERT(result == 0);
1417  result = cob_cd_op(&dec_cc_rec, c_fop, true);
1418  M0_UT_ASSERT(result == 0);
1419 
1420  /* Perform redo operations */
1421  result = cob_cd_op(&dec_cd_rec, d_fop, false);
1422  M0_UT_ASSERT(result == 0);
1423  result = cob_cd_op(&dec_cc_rec, c_fop, false);
1424  M0_UT_ASSERT(result == 0);
1425 
1426  m0_fol_rec_fini(&dec_cc_rec);
1427  m0_fol_rec_fini(&dec_cd_rec);
1428 
1430 }
1431 #endif
1432 
1433 static void fom_stob_tx_credit(struct m0_fom *fom, enum m0_cob_op opcode)
1434 {
1435  struct m0_fom_cob_op *co;
1436  int rc;
1437 
1438  co = cob_fom_get(fom);
1439  if (opcode == M0_COB_OP_DELETE) {
1440  rc = cob_ops_stob_find(co);
1441  M0_ASSERT(rc == 0);
1443  opcode);
1444  } else
1447  M0_UT_ASSERT(rc == 0);
1448  rc = m0_dtx_open_sync(&fom->fo_tx);
1449  M0_UT_ASSERT(rc == 0);
1450 }
1451 
1452 static void fom_dtx_init(struct m0_fom *fom, struct m0_sm_group *grp,
1453  enum m0_cob_op opcode)
1454 {
1455  struct m0_be_seg *beseg;
1456  struct m0_fom_cob_op *co;
1457 
1458  beseg = m0_fom_reqh(fom)->rh_beseg;
1460  M0_SET0(&fom->fo_tx);
1461  m0_dtx_init(&fom->fo_tx, beseg->bs_domain, grp);
1463  co = cob_fom_get(fom);
1464  co->fco_is_done = true;
1465 }
1466 
1467 static void fom_dtx_done(struct m0_fom *fom, struct m0_sm_group *grp)
1468 {
1469  m0_dtx_done_sync(&fom->fo_tx);
1470  m0_dtx_fini(&fom->fo_tx);
1472 }
1473 
1474 enum {
1478 };
1479 
1480 static void fid_convert_ut_check(uint32_t container,
1481  uint64_t key,
1482  uint32_t device_id)
1483 {
1484  struct m0_fid gob_fid;
1485  struct m0_fid gob_fid2;
1486  struct m0_fid cob_fid;
1487  struct m0_fid cob_fid2;
1488  struct m0_stob_id stob_id;
1489  struct m0_stob_id stob_id2;
1490  struct m0_fid bstore_fid;
1491  uint8_t type_id_gob = m0_file_fid_type.ft_id;
1492  uint8_t type_id_cob = m0_cob_fid_type.ft_id;
1493  uint8_t type_id_adstob = m0_stob_ad_type.st_fidt.ft_id;
1494  uint8_t type_id_linuxstob = m0_stob_linux_type.st_fidt.ft_id;
1495 
1498  M0_UT_ASSERT(m0_fid_tget(&gob_fid) == type_id_gob);
1499 
1500  m0_fid_convert_gob2cob(&gob_fid, &cob_fid, device_id);
1501  M0_UT_ASSERT(m0_fid_tget(&cob_fid) == type_id_cob);
1502  M0_UT_ASSERT(m0_fid_cob_device_id(&cob_fid) == device_id);
1504  m0_fid_convert_cob2gob(&cob_fid, &gob_fid2);
1505  M0_UT_ASSERT(m0_fid_validate_gob(&gob_fid2));
1506  M0_UT_ASSERT(m0_fid_eq(&gob_fid, &gob_fid2));
1507 
1508  m0_fid_convert_cob2adstob(&cob_fid, &stob_id);
1509  M0_UT_ASSERT(m0_fid_tget(&stob_id.si_fid) == type_id_adstob);
1510  M0_UT_ASSERT(m0_fid_tget(&stob_id.si_domain_fid) == type_id_adstob);
1512  m0_fid_convert_adstob2cob(&stob_id, &cob_fid2);
1513  M0_UT_ASSERT(m0_fid_validate_cob(&cob_fid2));
1514  M0_UT_ASSERT(m0_fid_eq(&cob_fid, &cob_fid2));
1515 
1516  m0_fid_convert_adstob2bstore(&stob_id.si_domain_fid, &bstore_fid);
1517  M0_UT_ASSERT(m0_fid_tget(&bstore_fid) == type_id_linuxstob);
1518  M0_UT_ASSERT(m0_fid_validate_bstore(&bstore_fid));
1519  m0_fid_convert_bstore2adstob(&bstore_fid, &stob_id2.si_domain_fid);
1520  stob_id2.si_fid = stob_id.si_fid;
1523  &stob_id2.si_domain_fid));
1524 
1525  m0_fid_convert_adstob2cob(&stob_id2, &cob_fid2);
1526  M0_UT_ASSERT(m0_fid_eq(&cob_fid, &cob_fid2));
1527  M0_UT_ASSERT(m0_fid_cob_device_id(&cob_fid2) == device_id);
1528  m0_fid_convert_cob2gob(&cob_fid2, &gob_fid2);
1529  M0_UT_ASSERT(m0_fid_eq(&gob_fid, &gob_fid2));
1530 }
1531 
1532 static void fid_convert_ut(void)
1533 {
1534  uint32_t container;
1535  uint64_t key;
1536  uint32_t device_id;
1537  int i;
1538  int j;
1539  int k;
1540 
1541  key = 0;
1542  for (i = 0; i <= FID_UT_KEY_BITS_MAX; ++i) {
1543  container = 0;
1544  for (j = 0; j <= FID_UT_CONTAINER_BITS_MAX; ++j) {
1545  device_id = 0;
1546  for (k = 0; k <= FID_UT_DEVICE_ID_BITS_MAX; ++k) {
1547  fid_convert_ut_check(container, key, device_id);
1548  device_id = device_id * 2 + 1;
1549  }
1550  container = container * 2 + 1;
1551  }
1552  key = key * 2 + 1;
1553  }
1554 }
1555 
1557  .ts_name = "cob-foms-ut",
1558  .ts_init = NULL,
1559  .ts_fini = NULL,
1560  .ts_tests = {
1561  { "cobfoms_utinit", cobfoms_utinit},
1562  { "fid_convert", fid_convert_ut},
1563  { "cobfoms_fsync_nonexistent_tx", cobfoms_fsync_nonexist_tx},
1564  { "cobfoms_fsync_create_delete",
1566  { "cobfoms_single_fop", cobfoms_single},
1567  { "cobfoms_multiple_fops", cobfoms_multiple},
1568  { "cobfoms_preexisting_cob_create", cobfoms_preexisting_cob},
1569  { "cobfoms_delete_nonexistent_cob", cobfoms_del_nonexist_cob},
1570  { "cobfoms_md_cob_fop", md_cob_create_delete},
1571  { "cobfoms_create_cob_apitest", cob_create_api_test},
1572  { "cobfoms_delete_cob_apitest", cob_delete_api_test},
1573  /* XXX: enable after m0_be_domain_tx_find() will be able
1574  * to read back from stob finalized transactions payloads.
1575  * This might be available along with recovery.
1576  { "cob_create_delete_fol_verify", cobfoms_fol_verify}, */
1577  { "cobfoms_utfini", cobfoms_utfini},
1578  { NULL, NULL }
1579  }
1580 };
1581 
1582 #undef M0_TRACE_SUBSYSTEM
static struct ctx cc
struct m0_fol * fr_fol
Definition: fol.h:190
uint32_t b_nlink
Definition: md_fops.h:81
struct m0_fop_type m0_fop_cob_op_reply_fopt
Definition: io_fops.c:78
static struct m0_fid gob_fid
Definition: net.c:115
static size_t nr
Definition: dump.c:1505
uint64_t c_flags
Definition: io_fops.h:477
static struct m0_fom_type ft
Definition: cob_foms.c:51
struct m0_be_domain * bs_domain
Definition: seg.h:82
static void cobfoms_fop_thread_fini(struct m0_fop_type *ftype1, struct m0_fop_type *ftype2)
Definition: cob_foms.c:372
static struct m0_fom_locality dummy_loc
Definition: cob_foms.c:48
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
static void cc_fom_fini_test()
Definition: cob_foms.c:753
Definition: cob.h:581
static void cd_stob_delete_test()
Definition: cob_foms.c:1142
static bool exists(const struct m0_ut_module *m, const char *s_name, const char *t_name)
Definition: ut.c:169
M0_INTERNAL void m0_fid_gob_make(struct m0_fid *gob_fid, uint32_t container, uint64_t key)
Definition: fid_convert.c:46
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
static void cobfoms_fsync_nonexist_tx(void)
Definition: cob_foms.c:457
M0_INTERNAL struct m0_fop_cob_common * m0_cobfop_common_get(struct m0_fop *fop)
Definition: io_fops.c:990
static void cobfoms_fsync_create_delete(void)
Definition: cob_foms.c:508
struct m0_reqh * m0_cs_reqh_get(struct m0_motr *cctx)
Definition: setup.c:1762
int const char const void size_t int flags
Definition: dir.c:328
static const char * SERVER_LOGFILE
Definition: cob_foms.c:87
struct m0_fom_domain * fl_dom
Definition: fom.h:256
static const struct m0_fom_ops cd_fom_ops
Definition: cob_foms.c:121
uint32_t b_valid
Definition: md_fops.h:76
struct m0_fop_type m0_fop_cob_create_fopt
Definition: io_fops.c:75
#define NULL
Definition: misc.h:38
struct m0_fop ** cu_createfops
Definition: cob_foms.c:93
M0_INTERNAL void m0_fol_rec_fini(struct m0_fol_rec *rec)
Definition: fol.c:104
struct m0_fid si_domain_fid
Definition: stob.h:103
struct m0_rpc_client_ctx cu_cctx
Definition: cob_foms.c:91
uint64_t co_flags
Definition: cob.h:585
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
const struct m0_fol_frag_ops * rp_ops
Definition: fol.h:244
static void dummy_locality_setup()
Definition: cob_foms.c:1275
struct m0_rpc_server_ctx cu_sctx
Definition: cob_foms.c:90
Definition: sm.h:350
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
static struct m0_cob * test_cob
Definition: cob_foms.c:50
static struct m0_sm_group * grp
Definition: bytecount.c:38
char ** rsx_argv
Definition: rpclib.h:77
static void cobfoms_utinit(void)
Definition: cob_foms.c:121
#define M0_LOG(level,...)
Definition: trace.h:167
static void cc_fom_dealloc(struct m0_fom *fom)
Definition: cob_foms.c:717
static void cobfoms_preexisting_cob(void)
Definition: cob_foms.c:411
struct m0_container container
static void cd_fom_dealloc(struct m0_fom *fom)
Definition: cob_foms.c:1033
static struct m0_fom * cc_fom_alloc()
Definition: cob_foms.c:727
static struct m0_be_tx_credit * m0_fom_tx_credit(struct m0_fom *fom)
Definition: fom.h:542
uint8_t ft_id
Definition: fid.h:101
struct m0_sm_group fl_group
Definition: fom.h:274
static void cob_op_credit(struct m0_fom *fom, enum m0_cob_op opcode, struct m0_be_tx_credit *accum)
Definition: cob_foms.c:868
int m0_rpc_server_start(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:50
static void cobfoms_fops_dispatch(struct m0_fop_type *ftype, uint64_t flags, int expected_rc)
Definition: cob_foms.c:325
static void fop_alloc(struct m0_fom *fom, enum cob_fom_type fomtype)
Definition: cob_foms.c:624
M0_INTERNAL void m0_dtx_init(struct m0_dtx *tx, struct m0_be_domain *be_domain, struct m0_sm_group *sm_group)
Definition: dtm.c:67
M0_INTERNAL void m0_ios_cdom_get(struct m0_reqh *reqh, struct m0_cob_domain **out)
Definition: io_service.c:463
M0_INTERNAL void m0_fid_convert_cob2adstob(const struct m0_fid *cob_fid, struct m0_stob_id *stob_id)
Definition: fid_convert.c:38
static int cc_cob_create(struct m0_fom *fom, struct m0_fom_cob_op *cc, const struct m0_cob_attr *attr)
Definition: cob_foms.c:1014
const struct m0_fid_type m0_cob_fid_type
Definition: cob.c:117
const struct m0_fid_type m0_file_fid_type
Definition: file.c:569
const struct m0_stob_type m0_stob_ad_type
Definition: ad.c:1003
struct m0_tl fr_frags
Definition: fol.h:201
static void cobfops_populate_internal(struct m0_fop *fop, uint64_t gob_fid_key)
Definition: cob_foms.c:176
struct m0_fid cu_cfid
Definition: cob_foms.c:96
M0_INTERNAL uint8_t m0_fid_tget(const struct m0_fid *fid)
Definition: fid.c:133
static struct m0_rpc_client_ctx cctx
Definition: rconfc.c:69
static void cobfops_threads_fini(void)
Definition: cob_foms.c:280
void * m0_fop_data(const struct m0_fop *fop)
Definition: fop.c:220
uint32_t c_cob_type
Definition: io_fops.h:474
static void cc_fom_populate_test()
Definition: cob_foms.c:1007
struct m0_dtx fo_tx
Definition: fom.h:498
static struct m0_addb2_mach * mach
Definition: storage.c:42
static void fom_get_test(enum cob_fom_type fomtype)
Definition: cob_foms.c:688
static bool cc_cob_create_test_done
Definition: cob_foms.c:53
struct m0_fid c_cobfid
Definition: io_fops.h:465
M0_INTERNAL void m0_fid_convert_adstob2bstore(const struct m0_fid *stob_domain_fid, struct m0_fid *bstore_fid)
Definition: fid_convert.c:76
uint32_t rpt_index
Definition: fol.h:262
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
static void cc_cob_create_test()
Definition: cob_foms.c:876
void * rp_data
Definition: fol.h:249
static void cobfoms_send_internal(struct m0_fop_type *ftype1, struct m0_fop_type *ftype2, uint64_t flags, int rc1, int rc2, uint64_t nr)
Definition: cob_foms.c:379
static void cobfops_create(void)
Definition: cob_foms.c:211
#define M0_SET0(obj)
Definition: misc.h:64
Definition: ut.h:77
int32_t ffr_rc
Definition: fsync_fops.h:64
static void fom_create(struct m0_fom **fom, enum cob_fom_type fomtype)
Definition: cob_foms.c:575
#define SERVER_EP_ADDR
Definition: cob_foms.c:83
static void cobfops_threads_init(void)
Definition: cob_foms.c:264
int m0_rpc_item_wait_for_reply(struct m0_rpc_item *item, m0_time_t timeout)
Definition: item.c:824
uint64_t cu_thread_nr
Definition: cob_foms.c:100
m0_cob_op
Definition: cob.h:1068
m0_fom_phase
Definition: fom.h:372
struct m0_fol_frag_type m0_fop_fol_frag_type
static struct m0_be_tx * m0_fom_tx(struct m0_fom *fom)
Definition: fom.h:537
M0_INTERNAL int m0_dtx_done_sync(struct m0_dtx *tx)
Definition: dtm.c:122
const struct m0_fol_frag_type * rpo_type
Definition: fol.h:283
struct m0_fom_type ft_fom_type
Definition: fop.h:232
struct m0_stob * fco_stob
Definition: cob_foms.h:65
const struct m0_fom_type * fo_type
Definition: dump.c:107
M0_INTERNAL int m0_cob_nskey_make(struct m0_cob_nskey **keyh, const struct m0_fid *pfid, const char *name, size_t namelen)
Definition: cob.c:148
#define m0_tl_endfor
Definition: tlist.h:700
static void cobfoms_fop_thread_init(uint64_t fop_nr, uint64_t thread_nr)
Definition: cob_foms.c:361
bool fco_is_done
Definition: cob_foms.h:66
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
M0_INTERNAL void m0_fol_rec_init(struct m0_fol_rec *rec, struct m0_fol *fol)
Definition: fol.c:98
int opcode
Definition: crate.c:301
void m0_fom_init(struct m0_fom *fom, const struct m0_fom_type *fom_type, const struct m0_fom_ops *ops, struct m0_fop *fop, struct m0_fop *reply, struct m0_reqh *reqh)
Definition: fom.c:1372
static void fid_convert_ut_check(uint32_t container, uint64_t key, uint32_t device_id)
Definition: cob_foms.c:1480
struct m0_locality fl_locality
Definition: fom.h:302
int i
Definition: dir.c:1033
struct m0_fop_type * ca_ftype
Definition: cob_foms.c:106
struct m0_fop_type * f_type
Definition: fop.h:81
static void cobfoms_del_nonexist_cob(void)
Definition: cob_foms.c:433
static void fom_dtx_done(struct m0_fom *fom, struct m0_sm_group *grp)
Definition: cob_foms.c:1467
struct m0_net_xprt * cu_xprt
Definition: cob_foms.c:97
struct m0_cob_domain cu_cob_dom
Definition: cob_foms.c:99
static const struct m0_fid CONF_PVER_FID1
Definition: bulkio_common.h:65
M0_INTERNAL int m0_cob_delete_put(struct m0_cob *cob, struct m0_be_tx *tx)
Definition: cob.c:1853
static void cd_fom_populate_test()
Definition: cob_foms.c:1084
#define SERVER_ENDP
Definition: cob_foms.c:85
M0_INTERNAL void m0_rpc_machine_unlock(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:558
struct m0_fop_cob_op_rep_common cor_common
Definition: io_fops.h:526
static int ce_stob_edit_credit(struct m0_fom *fom, struct m0_fom_cob_op *cc, struct m0_be_tx_credit *accum, uint32_t cot)
Definition: cob_foms.c:1169
static int key
Definition: locality.c:283
static void cob_create_api_test(void)
Definition: cob_foms.c:1282
static void attr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:949
const char * rsx_log_file_name
Definition: rpclib.h:81
static void cobfops_send_wait(struct cobthread_arg *arg)
Definition: cob_foms.c:293
M0_INTERNAL bool m0_fid_validate_adstob(const struct m0_stob_id *stob_id)
Definition: fid_convert.c:87
static void cobfoms_single(void)
Definition: cob_foms.c:395
#define m0_free0(pptr)
Definition: memory.h:77
static int cob_ops_stob_find(struct m0_fom_cob_op *co)
Definition: cob_foms.c:335
#define M0_ASSERT(cond)
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
M0_INTERNAL int m0_xcode_cmp(const struct m0_xcode_obj *o0, const struct m0_xcode_obj *o1)
Definition: xcode.c:572
struct m0_fid pver
Definition: idx_dix.c:74
static struct m0_addb2_callback c
Definition: consumer.c:41
M0_INTERNAL void m0_md_cob_mem2wire(struct m0_fop_cob *body, const struct m0_cob_attr *attr)
Definition: md_foms.c:89
struct m0_be_tx_remid ffr_be_remid
Definition: fsync_fops.h:70
uint64_t ca_flags
Definition: cob_foms.c:109
static void cc_fom_get_test()
Definition: cob_foms.c:761
struct m0_reqh_service_type m0_ios_type
Definition: io_service.c:112
static void cob_delete_api_test(void)
Definition: cob_foms.c:1313
static void cc_fom_create_test()
Definition: cob_foms.c:745
M0_INTERNAL void m0_fom_type_init(struct m0_fom_type *type, uint64_t id, const struct m0_fom_type_ops *ops, const struct m0_reqh_service_type *svc_type, const struct m0_sm_conf *sm)
Definition: fom.c:1596
static struct m0_fid cob_fid
Definition: net.c:116
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:217
const struct m0_sm_conf cob_ops_conf
Definition: cob_foms.c:99
struct m0_fid si_fid
Definition: stob.h:105
static int ce_stob_edit(struct m0_fom *fom, struct m0_fom_cob_op *cd, uint32_t cot)
Definition: cob_foms.c:1206
static void cd_fom_fini(struct m0_fom *fom)
Definition: cob_foms.c:1084
static void cc_fom_fini(struct m0_fom *fom)
Definition: cob_foms.c:259
struct m0_net_xprt * m0_net_xprt_default_get(void)
Definition: net.c:151
int m0_rpc_client_start(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:160
struct m0_net_xprt ** rsx_xprts
Definition: rpclib.h:69
static void cobfoms_fsync_send_fop(struct m0_be_tx_remid *remid, int expected_rc)
Definition: cob_foms.c:467
struct m0_rpc_item * ri_reply
Definition: item.h:163
struct m0_fid c_gobfid
Definition: io_fops.h:460
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
M0_INTERNAL uint32_t m0_fid_cob_device_id(const struct m0_fid *cob_fid)
Definition: fid_convert.c:81
uint32_t rcx_recv_queue_min_length
Definition: rpclib.h:153
static int cob_ops_fom_tick(struct m0_fom *fom)
Definition: cob_foms.c:576
int m0_rpc_post_sync(struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
Definition: rpclib.c:284
struct m0_fid b_pver
Definition: md_fops.h:93
M0_INTERNAL int m0_cob_lookup(struct m0_cob_domain *dom, struct m0_cob_nskey *nskey, uint64_t flags, struct m0_cob **out)
Definition: cob.c:1371
M0_INTERNAL int m0_cc_stob_create(struct m0_fom *fom, struct m0_stob_id *sid)
Definition: cob_foms.c:824
M0_INTERNAL void m0_dtx_fini(struct m0_dtx *tx)
Definition: dtm.c:134
M0_INTERNAL struct m0_rpc_machine * session_machine(const struct m0_rpc_session *s)
Definition: session.c:147
cob_fom_type
Definition: cob_foms.c:63
Definition: reqh.h:94
static void cd_fom_create_test()
Definition: cob_foms.c:1060
const struct m0_fom_type * fo_type
Definition: fom.h:485
struct m0_sm_group * lo_grp
Definition: locality.h:67
Definition: dump.c:103
static void cobfops_populate(uint64_t index)
Definition: cob_foms.c:196
static void cd_fom_get_test()
Definition: cob_foms.c:1076
struct m0_fol_rec tx_fol_rec
Definition: dtm.h:561
struct m0_fid * rcx_fid
Definition: rpclib.h:161
M0_INTERNAL void m0_fom_sm_init(struct m0_fom *fom)
Definition: fom.c:1674
struct m0_fop_type m0_fop_cob_delete_fopt
Definition: io_fops.c:76
uint64_t tri_txid
Definition: tx.h:431
struct m0_rpc_machine machine
Definition: mdstore.c:58
Definition: seg.h:66
struct m0_net_domain * rcx_net_dom
Definition: rpclib.h:128
static struct m0_fom * cd_fom_alloc()
Definition: cob_foms.c:1042
#define FID_P(f)
Definition: fid.h:77
struct m0_thread ** cu_threads
Definition: cob_foms.c:101
M0_INTERNAL bool m0_fid_validate_gob(const struct m0_fid *gob_fid)
Definition: fid_convert.c:93
M0_INTERNAL struct m0_fop_type * m0_fop_type_find(uint32_t opcode)
Definition: fop.c:388
uint64_t tri_locality
Definition: tx.h:432
static void fom_fini_test(enum cob_fom_type fomtype)
Definition: cob_foms.c:667
static void cob_verify(struct m0_fom *fom, const bool exists)
Definition: cob_foms.c:798
M0_INTERNAL bool m0_is_cob_create_fop(const struct m0_fop *fop)
Definition: io_fops.c:950
M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh)
Definition: reqh.c:606
void cob_attr_default_fill(struct m0_cob_attr *attr)
static void cc_fom_state_test(void)
Definition: cob_foms.c:957
struct m0_fop_type m0_fop_fsync_ios_fopt
Definition: io_fops.c:82
static int cd_cob_delete(struct m0_fom *fom, struct m0_fom_cob_op *cd, const struct m0_cob_attr *attr)
Definition: cob_foms.c:1119
static void cd_cob_delete_test()
Definition: cob_foms.c:1184
static void cobfoms_utfini(void)
Definition: cob_foms.c:162
uint64_t rcx_max_rpcs_in_flight
Definition: rpclib.h:136
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
M0_INTERNAL bool m0_fid_validate_bstore(const struct m0_fid *bstore_fid)
Definition: fid_convert.c:98
Definition: fom.h:481
M0_INTERNAL struct m0_reqh_service * m0_reqh_service_find(const struct m0_reqh_service_type *st, const struct m0_reqh *reqh)
Definition: reqh_service.c:538
struct m0_reqh reqh
Definition: rm_foms.c:48
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
static const struct m0_fid CONF_PVER_FID
Definition: bulkio_common.h:64
static void cd_fom_state_test(void)
Definition: cob_foms.c:1247
int rsx_xprts_nr
Definition: rpclib.h:71
int(* fto_redo)(struct m0_fop_fol_frag *ffrag, struct m0_fol *fol)
Definition: fop.h:274
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
static char * server_args[]
Definition: cob_foms.c:112
struct m0_rpc_session rcx_session
Definition: rpclib.h:147
static void cc_stob_create_test()
Definition: cob_foms.c:769
Definition: fid.h:38
struct m0_net_domain cu_nd
Definition: cob_foms.c:98
uint64_t f_key
Definition: fid.h:40
struct m0_fom_locality * fo_loc
Definition: fom.h:483
M0_INTERNAL void m0_rpc_machine_lock(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:551
struct m0_reqh_service * fo_service
Definition: fom.h:505
struct m0_be_tx_remid ff_be_remid
Definition: fsync_fops.h:48
struct m0_stob_id fco_stob_id
Definition: cob_foms.h:52
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
#define M0_UT_CONF_PROCESS
Definition: misc.h:45
static void fom_fini(struct m0_fom *fom, enum cob_fom_type fomtype)
Definition: cob_foms.c:604
static struct cobfoms_ut * cut
Definition: cob_foms.c:47
M0_INTERNAL struct m0_fom_domain * m0_fom_dom(void)
Definition: locality.c:575
void m0_ut_fom_phase_set(struct m0_fom *fom, int phase)
Definition: cs_fop.c:186
static void cobfoms_multiple(void)
Definition: cob_foms.c:405
const struct m0_fop_type_ops * ft_ops
Definition: fop.h:228
M0_INTERNAL int m0_fom_rc(const struct m0_fom *fom)
Definition: fom.c:1727
const char * rcx_remote_addr
Definition: rpclib.h:134
static void fid_convert_ut(void)
Definition: cob_foms.c:1532
static void fom_create_test(enum cob_fom_type fomtype)
Definition: cob_foms.c:705
void m0_fop_put_lock(struct m0_fop *fop)
Definition: fop.c:199
static char COB_FOP_NR_STR[]
Definition: cob_foms.c:81
M0_INTERNAL int m0_cc_stob_cr_credit(struct m0_stob_id *sid, struct m0_be_tx_credit *accum)
Definition: cob_foms.c:807
struct m0_fop_mod_rep cor_mod_rep
Definition: io_fops.h:518
static struct m0_fop * fop
Definition: item.c:57
struct m0_fol rh_fol
Definition: reqh.h:121
struct m0_be_seg * rh_beseg
Definition: reqh.h:112
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
static void cd_fom_fini_test()
Definition: cob_foms.c:1068
struct m0_fop * m0_rpc_item_to_fop(const struct m0_rpc_item *item)
Definition: fop.c:346
static void fom_dtx_init(struct m0_fom *fom, struct m0_sm_group *grp, enum m0_cob_op opcode)
Definition: cob_foms.c:1452
const char * rcx_local_addr
Definition: rpclib.h:131
M0_INTERNAL int m0_dtx_open_sync(struct m0_dtx *tx)
Definition: dtm.c:101
#define CLIENT_EP_ADDR
Definition: cob_foms.c:84
static int cob_fom_populate(struct m0_fom *fom)
Definition: cob_foms.c:285
struct m0_fid c_pver
Definition: io_fops.h:468
M0_INTERNAL void m0_fid_convert_cob2gob(const struct m0_fid *cob_fid, struct m0_fid *gob_fid)
Definition: fid_convert.c:69
void m0_rpc_server_stop(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:85
struct m0_rpc_machine rcx_rpc_machine
Definition: rpclib.h:145
M0_INTERNAL void m0_fid_convert_adstob2cob(const struct m0_stob_id *stob_id, struct m0_fid *cob_fid)
Definition: fid_convert.c:54
M0_INTERNAL void m0_fom_locality_inc(struct m0_fom *fom)
Definition: fom.c:1295
M0_INTERNAL void m0_stob_delete_mark(struct m0_stob *stob)
Definition: stob.c:193
#define M0_UT_PATH(name)
Definition: misc.h:41
uint32_t ff_fsync_mode
Definition: fsync_fops.h:51
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
void m0_fom_phase_set(struct m0_fom *fom, int phase)
Definition: fom.c:1688
struct m0_fid gfid
Definition: dir.c:626
static const struct m0_fom_ops cc_fom_ops
Definition: cob_foms.c:114
struct m0_fop ** cu_deletefops
Definition: cob_foms.c:94
static int cob_op_fom_create(struct m0_fom **out)
Definition: cob_foms.c:238
static void cob_testdata_cleanup(struct m0_fom *fom)
Definition: cob_foms.c:1134
static struct m0_dtm_oper_descr reply
Definition: transmit.c:94
struct m0_fid cu_gfid
Definition: cob_foms.c:95
M0_INTERNAL bool m0_fid_validate_cob(const struct m0_fid *cob_fid)
Definition: fid_convert.c:99
static struct m0_fom_cob_op * cob_fom_get(const struct m0_fom *fom)
Definition: cob_foms.c:252
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
void m0_free(void *data)
Definition: memory.c:146
void m0_fop_put(struct m0_fop *fop)
Definition: fop.c:177
struct m0_rpc_item f_item
Definition: fop.h:83
const struct m0_reqh_service_type * ft_rstype
Definition: fom.h:617
struct m0_fop_cob c_body
Definition: io_fops.h:456
const struct m0_stob_type m0_stob_linux_type
Definition: linux.c:86
M0_INTERNAL void m0_fid_convert_bstore2adstob(const struct m0_fid *bstore_fid, struct m0_fid *stob_domain_fid)
Definition: fid_convert.c:66
int32_t rc
Definition: trigger_fop.h:47
uint64_t cu_cobfop_nr
Definition: cob_foms.c:92
static void md_cob_fop_create_delete_test(bool create_p, const struct m0_fid *pver, int expected_reply_rc)
Definition: cob_foms.c:833
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_fid g_process_fid
Definition: ut.c:689
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct m0_be_tx_remid fmr_remid
Definition: fom_generic.h:243
struct m0_motr rsx_motr_ctx
Definition: rpclib.h:84
static void md_cob_create_delete()
Definition: cob_foms.c:860
int(* fto_undo)(struct m0_fop_fol_frag *ffrag, struct m0_fol *fol)
Definition: fop.h:273
static void cobfops_destroy(struct m0_fop_type *ftype1, struct m0_fop_type *ftype2)
Definition: cob_foms.c:239
Definition: fop.h:79
static void fom_stob_tx_credit(struct m0_fom *fom, enum m0_cob_op opcode)
Definition: cob_foms.c:1433
#define FID_F
Definition: fid.h:75
M0_INTERNAL struct m0_reqh * m0_fom_reqh(const struct m0_fom *fom)
Definition: fom.c:283
static struct m0_fom * cob_testdata_create()
Definition: cob_foms.c:1104
uint64_t cu_gobindex
Definition: cob_foms.c:102
struct m0_fid_type st_fidt
Definition: type.h:61
Definition: tx.h:280
struct m0_fid fco_cfid
Definition: cob_foms.h:60
Definition: idx_mock.c:47
struct m0_fop * m0_fop_alloc(struct m0_fop_type *fopt, void *data, struct m0_rpc_machine *mach)
Definition: fop.c:96
#define M0_IMPOSSIBLE(fmt,...)
uint32_t ffrp_fop_code
Definition: fop.h:354