Motr  M0
xform.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2021 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 "lib/vec.h"
24 #include "lib/locality.h"
25 #include "lib/finject.h"
26 #include "ioservice/io_service.h"
27 #include "motr/setup.h"
28 #include "sns/cm/repair/xform.c"
30 #include "ioservice/fid_convert.h" /* m0_fid_convert_cob2stob */
31 #include "ut/stob.h" /* m0_ut_stob_create_by_stob_id */
32 #include "module/instance.h" /* m0_get */
33 
34 enum {
35  SEG_NR = 16,
36  SEG_SIZE = 4096,
37  BUF_NR = 2,
38  DATA_NR = 5,
39  PARITY_NR = 2,
40  CP_SINGLE = 1,
45 };
46 
47 static struct m0_fid gob_fid;
48 static struct m0_fid cob_fid;
49 
50 static struct m0_reqh *reqh;
52 static struct m0_cm *cm;
53 static struct m0_sns_cm *scm;
55 static struct m0_cob_domain *cdom;
56 static struct m0_semaphore sem;
57 static struct m0_net_buffer_pool nbp;
58 
59 /* Global structures for testing bufvec xor correctness. */
60 static struct m0_bufvec src;
61 static struct m0_bufvec dst;
62 static struct m0_bufvec xor;
63 
64 /* Global structures for single copy packet test. */
65 static struct m0_sns_cm_repair_ag s_rag;
67 static struct m0_sns_cm_cp s_cp;
68 static struct m0_net_buffer s_buf;
69 static struct m0_net_buffer s_acc_buf;
70 
71 /*
72  * Global structures for multiple copy packet test comprising of single
73  * failure.
74  */
75 static struct m0_sns_cm_repair_ag m_rag;
80 
81 /*
82  * Global structures for multiple copy packet test comprising of multiple
83  * failures.
84  */
85 static struct m0_sns_cm_repair_ag n_rag;
90 
91 M0_INTERNAL void cob_create(struct m0_reqh *reqh, struct m0_cob_domain *cdom,
92  struct m0_be_domain *bedom,
93  uint64_t cont, struct m0_fid *gfid,
94  uint32_t cob_idx);
95 M0_INTERNAL void cob_delete(struct m0_cob_domain *cdom,
96  struct m0_be_domain *bedom,
97  uint64_t cont, const struct m0_fid *gfid);
98 
99 static uint64_t cp_single_get(const struct m0_cm_aggr_group *ag)
100 {
101  return CP_SINGLE;
102 }
103 
104 static const struct m0_cm_aggr_group_ops group_single_ops = {
106 };
107 
108 static uint64_t single_fail_multi_cp_get(const struct m0_cm_aggr_group *ag)
109 {
111 }
112 
115 };
116 
117 static uint64_t multi_fail_multi_cp_get(const struct m0_cm_aggr_group *ag)
118 {
119  return MULTI_FAIL_MULTI_CP_NR;
120 }
121 
124 };
125 
126 static size_t dummy_fom_locality(const struct m0_fom *fom)
127 {
128  /* By default, use locality0. */
129  return 0;
130 }
131 
132 /* Dummy fom state routine to emulate only selective copy packet states. */
133 static int dummy_fom_tick(struct m0_fom *fom)
134 {
135  struct m0_cm_cp *cp = container_of(fom, struct m0_cm_cp, c_fom);
136 
137  switch (m0_fom_phase(fom)) {
138  case M0_FOM_PHASE_INIT:
141  return cp->c_ops->co_action[M0_CCP_XFORM](cp);
142  case M0_CCP_WRITE:
144  return M0_FSO_AGAIN;
145  case M0_CCP_IO_WAIT:
147  return M0_FSO_WAIT;
148  default:
149  M0_IMPOSSIBLE("Bad State");
150  return 0;
151  }
152 }
153 
154 static int dummy_acc_cp_fom_tick(struct m0_fom *fom)
155 {
156  switch (m0_fom_phase(fom)) {
157  case M0_FOM_PHASE_INIT:
160  return M0_FSO_AGAIN;
161  case M0_CCP_WRITE:
163  return M0_FSO_AGAIN;
164  case M0_CCP_IO_WAIT:
166  return M0_FSO_WAIT;
167  default:
168  M0_IMPOSSIBLE("Bad State");
169  return 0;
170  }
171 }
172 
173 static void single_cp_fom_fini(struct m0_fom *fom)
174 {
175  struct m0_cm_cp *cp = container_of(fom, struct m0_cm_cp, c_fom);
176 
177  m0_cm_cp_fini(cp);
178 }
179 
180 static void multiple_cp_fom_fini(struct m0_fom *fom)
181 {
182  struct m0_cm_cp *cp = container_of(fom, struct m0_cm_cp, c_fom);
183 
184  m0_cm_cp_fini(cp);
185 }
186 
187 /* Over-ridden copy packet FOM ops. */
188 static struct m0_fom_ops single_cp_fom_ops = {
190  .fo_tick = dummy_fom_tick,
191  .fo_home_locality = dummy_fom_locality
192 };
193 
194 static struct m0_fom_ops acc_cp_fom_ops = {
196  .fo_tick = dummy_acc_cp_fom_tick,
197  .fo_home_locality = dummy_fom_locality
198 };
199 
200 /* Over-ridden copy packet FOM ops. */
203  .fo_tick = dummy_fom_tick,
204  .fo_home_locality = dummy_fom_locality
205 };
206 
207 /*
208 static bool dummy_xform_ut_accumulator_is_full(const struct m0_sns_cm_ag *sag,
209  int xform_cp_nr)
210 {
211  uint64_t global_cp_nr = sag->sag_base.cag_cp_global_nr;
212 
213  return xform_cp_nr == global_cp_nr - sag->sag_fnr ? true : false;
214 }
215 */
217 };
218 
219 static void cp_buf_free(struct m0_sns_cm_ag *sag)
220 {
221  struct m0_cm_cp *acc_cp;
222  struct m0_net_buffer *nbuf;
223  struct m0_sns_cm_repair_ag *rag;
224  int i;
225 
226  rag = sag2repairag(sag);
227  for (i = 0; i < sag->sag_fnr; ++i) {
228  acc_cp = &rag->rag_fc[i].fc_tgt_acc_cp.sc_base;
229  m0_tl_for(cp_data_buf, &acc_cp->c_buffers, nbuf) {
230  m0_bufvec_free(&nbuf->nb_buffer);
231  } m0_tl_endfor;
232  }
233 }
234 
235 static void tgt_fid_cob_create(struct m0_reqh *reqh)
236 {
237  struct m0_stob_id stob_id;
238  int rc;
239 
243  m0_fid_convert_cob2stob(&cob_fid, &stob_id);
244  rc = m0_ut_stob_create_by_stob_id(&stob_id, NULL);
245  M0_ASSERT(rc == 0);
246 }
247 
248 static void ag_init(struct m0_sns_cm_repair_ag *rag)
249 {
250  struct m0_cm_aggr_group *ag = &rag->rag_base.sag_base;
251 
252  /* Workaround to avoid lock of uninitialised mutex */
253  m0_mutex_init(&ag->cag_mutex);
254 }
255 
256 static void ag_fini(struct m0_sns_cm_repair_ag *rag)
257 {
258  struct m0_cm_aggr_group *ag = &rag->rag_base.sag_base;
259 
260  m0_mutex_fini(&ag->cag_mutex);
261 }
262 
263 static void ag_prepare(struct m0_sns_cm_repair_ag *rag, int failure_nr,
264  const struct m0_cm_aggr_group_ops *ag_ops,
266 {
267  struct m0_sns_cm_ag *sag;
268  int i;
269 
270  sag = &rag->rag_base;
272  sag->sag_fnr = failure_nr;
273  sag->sag_base.cag_ops = ag_ops;
277  failure_nr;
278  for (i = 0; i < failure_nr; ++i) {
279  fc[i].fc_tgt_cobfid = cob_fid;
280  fc[i].fc_is_inuse = true;
281  }
282  rag->rag_fc = fc;
283 }
284 
285 /* Tests the correctness of the bufvec_xor function. */
286 static void test_bufvec_xor()
287 {
290  /*
291  * Actual result is anticipated and stored in new bufvec, which is
292  * used for comparison with xor'ed output.
293  * 4 XOR D = p
294  */
298  bv_free(&src);
299  bv_free(&dst);
300  bv_free(&xor);
301 }
302 
303 /*
304  * Test to check that single copy packet is treated as passthrough by the
305  * transformation function.
306  */
307 static void test_single_cp(void)
308 {
309  struct m0_sns_cm_ag *sag;
310  struct m0_cm_cp *cp = &s_cp.sc_base;
311  struct m0_sns_cm_file_ctx fctx;
312 
313  m0_semaphore_init(&sem, 0);
315  s_acc_buf.nb_pool = &nbp;
316  s_buf.nb_pool = &nbp;
318  sag = &s_rag.rag_base;
319  sag->sag_fctx = &fctx;
320  cp_prepare(cp, &s_buf, SEG_NR, SEG_SIZE, sag, 'e',
321  &single_cp_fom_ops, reqh, 0, false, NULL);
322  cp_prepare(&s_fc[0].fc_tgt_acc_cp.sc_base, &s_acc_buf, SEG_NR,
323  SEG_SIZE, sag, 0, &acc_cp_fom_ops, reqh, 0, true, NULL);
324  m0_bitmap_init(&s_fc[0].fc_tgt_acc_cp.sc_base.c_xform_cp_indices,
326  s_cp.sc_is_local = true;
327  m0_fom_queue(&cp->c_fom);
328 
329  /* Wait till ast gets posted. */
332 
333  /*
334  * These asserts ensure that the single copy packet has been treated
335  * as passthrough.
336  */
341  cp_buf_free(sag);
342 }
343 
344 /*
345  * Test to check that multiple copy packets are collected by the
346  * transformation function, in case of single failure.
347  */
349 {
350  struct m0_sns_cm_ag *sag;
351  struct m0_cm_cp *cp;
352  struct m0_sns_cm_file_ctx fctx;
353  int i;
354 
355  m0_semaphore_init(&sem, 0);
357  m_fc);
358  m_acc_buf[0].nb_pool = &nbp;
359  sag = &m_rag.rag_base;
361  sag->sag_fctx = &fctx;
362  cp_prepare(&m_fc[0].fc_tgt_acc_cp.sc_base, &m_acc_buf[0], SEG_NR,
363  SEG_SIZE, sag, 0, &acc_cp_fom_ops, reqh, 0, true, NULL);
364  m0_bitmap_init(&m_fc[0].fc_tgt_acc_cp.sc_base.c_xform_cp_indices,
366  for (i = 0; i < SINGLE_FAIL_MULTI_CP_NR; ++i) {
367  m_buf[i].nb_pool = &nbp;
368  cp = &m_cp[i].sc_base;
369  m_cp[i].sc_is_local = true;
370  cp_prepare(cp, &m_buf[i], SEG_NR, SEG_SIZE, sag,
371  'r', &multiple_cp_fom_ops, reqh, i, false, NULL);
372  m0_fom_queue(&cp->c_fom);
374  }
376 
377  /*
378  * These asserts ensure that all the copy packets have been collected
379  * by the transformation function.
380  */
385  for (i = 0; i < SINGLE_FAIL_MULTI_CP_NR; ++i)
386  bv_free(&m_buf[i].nb_buffer);
387 
388  cp_buf_free(sag);
389 }
390 
391 static void rs_init()
392 {
393  uint64_t local_cp_nr;
394 
395  local_cp_nr = n_rag.rag_base.sag_base.cag_cp_local_nr;
397  PARITY_NR) == 0);
399  &n_rag.rag_ir) == 0);
400 }
401 
402 static void buffers_attach(struct m0_net_buffer *nb, struct m0_cm_cp *cp,
403  char data)
404 {
405  int i;
406 
407  for (i = 1; i < BUF_NR; ++i) {
408  bv_alloc_populate(&nb[i].nb_buffer, data, SEG_NR, SEG_SIZE);
409  m0_cm_cp_buf_add(cp, &nb[i]);
410  nb[i].nb_pool = &nbp;
411  nb[i].nb_pool->nbp_seg_nr = SEG_NR;
413  nb[i].nb_pool->nbp_buf_nr = 1;
414  }
415 }
416 
417 /*
418  * Creates a copy packet and queues it for execution.
419  */
420 static void cp_multi_failures_post(char data, int cnt, int index)
421 {
422  struct m0_sns_cm_ag *sag;
423  struct m0_cm_cp *cp;
424 
425  n_buf[cnt][0].nb_pool = &nbp;
426  sag = &n_rag.rag_base;
427  cp = &n_cp[cnt].sc_base;
428  cp_prepare(cp, &n_buf[cnt][0], SEG_NR, SEG_SIZE,
430  false, NULL);
431  buffers_attach(n_buf[cnt], cp, data);
432 
433  cp->c_data_seg_nr = SEG_NR * BUF_NR;
434  n_cp[cnt].sc_is_local = true;
438  m0_fom_queue(&cp->c_fom);
440 }
441 
442 static void buf_initialize(struct m0_buf *bufs, uint32_t count, uint32_t len)
443 {
444  uint32_t i;
445  int ret;
446 
447  for (i = 0; i < count; ++i) {
448  ret = m0_buf_alloc(&bufs[i], len);
449  M0_UT_ASSERT(ret == 0);
450  }
451 }
452 
453 static void buf_free(struct m0_buf *bufs, uint32_t count)
454 {
455  uint32_t i;
456 
457  for (i = 0; i < count; ++i)
458  m0_buf_free(&bufs[i]);
459 }
460 
461 static void ref_parity_calculate(struct m0_parity_math *math,
462  struct m0_bufvec *bufvecs)
463 {
464  uint32_t i;
465  int ret;
466  uint32_t unit_count;
467  struct m0_buf *bufs;
468  struct m0_buf *parity_bufs;
469  struct m0_bufvec *parity_bufvecs;
470 
471  M0_UT_ASSERT(math != NULL);
472  M0_UT_ASSERT(bufvecs != NULL);
473 
474  unit_count = math->pmi_data_count + math->pmi_parity_count;
475 
476  M0_ALLOC_ARR(bufs, unit_count);
477  M0_UT_ASSERT(bufs != NULL);
478 
479  buf_initialize(bufs, unit_count, SEG_NR * SEG_SIZE);
480 
481  /* Copy data from buffer vector to m0 buffer */
482  for (i = 0; i < math->pmi_data_count; i++) {
483  ret = m0_bufvec_to_buf_copy(&bufs[i], &bufvecs[i]);
484  M0_UT_ASSERT(ret == 0);
485  }
486 
487  /* Calculate parity */
488  parity_bufs = &bufs[math->pmi_data_count];
489  m0_parity_math_calculate(math, bufs, parity_bufs);
490 
491  /* Copy parity from m0 buffer to buffer vector */
492  parity_bufvecs = &bufvecs[math->pmi_data_count];
493  for (i = 0; i < math->pmi_parity_count; i++) {
494  ret = m0_buf_to_bufvec_copy(&parity_bufvecs[i],
495  &parity_bufs[i]);
496  M0_UT_ASSERT(ret == 0);
497  }
498 
499  buf_free(bufs, unit_count);
500  m0_free(bufs);
501 }
502 
503 /*
504  * Test to check that multiple copy packets are collected by the
505  * transformation function, in case of multiple failures.
506  */
508 {
509  int i;
510  int j;
511  struct m0_net_buffer *nbuf;
512  struct m0_sns_cm_ag *sag;
513  struct m0_sns_cm_file_ctx fctx;
514  struct m0_pool_version pv;
515  struct m0_poolmach pm;
516  struct m0_parity_math math;
517  struct m0_bufvec *x;
518  char data[DATA_NR] = {'r', 's', 't', 'u', 'v'};
519  uint8_t failed_idx[MULTI_FAILURES] = {1, 6};
520  uint8_t *bufs_in_error;
521  uint32_t unit_count = DATA_NR + PARITY_NR;
522  int ret;
523 
524  M0_ALLOC_ARR(x, unit_count);
525  M0_UT_ASSERT(x != NULL);
526 
527  for (i = 0; i < unit_count; i++) {
529  M0_0VEC_SHIFT) == 0);
531  }
532 
533  for (i = 0; i < DATA_NR; i++)
535 
536  ret = m0_parity_math_init(&math, DATA_NR, PARITY_NR);
537  M0_UT_ASSERT(ret == 0);
538  ref_parity_calculate(&math, x);
539  m0_parity_math_fini(&math);
540 
541  m0_fi_enable("m0_sns_cm_tgt_ep", "local-ep");
542  m0_semaphore_init(&sem, 0);
544  n_fc);
545  sag = &n_rag.rag_base;
546  pm.pm_pver = &pv;
547  fctx.sf_pm = &pm;
549  sag->sag_fctx = &fctx;
550  for (i = 0; i < MULTI_FAILURES; ++i) {
551  n_acc_buf[i][0].nb_pool = &nbp;
552  cp_prepare(&n_fc[i].fc_tgt_acc_cp.sc_base, &n_acc_buf[i][0],
554  reqh, 0, true, NULL);
555  buffers_attach(n_acc_buf[i], &n_fc[i].fc_tgt_acc_cp.sc_base, 0);
556  m0_bitmap_init(&n_fc[i].fc_tgt_acc_cp.sc_base.c_xform_cp_indices,
558  n_fc[i].fc_is_inuse = true;
559  m0_cm_cp_bufvec_merge(&n_fc[i].fc_tgt_acc_cp.sc_base);
560  }
561 
562  rs_init();
563 
564  /*
565  * The test case is illustrated as follows.
566  * N = 5, K = 2
567  *
568  * Calculate parity for below data
569  * d0 = 'r', d1 = 's', d2 = 't', d3 = 'u', d4 = 'v'
570  *
571  * Consider,
572  * D0 = BUF_NR buffers having data = 'r' (index in ag = 0)
573  * D1 = FAILED (index in ag = 1)
574  * D2 = BUF_NR buffers having data = 't' (index in ag = 2)
575  * D3 = BUF_NR buffers having data = 'u' (index in ag = 3)
576  * D4 = BUF_NR buffers having data = 'v' (index in ag = 4)
577  * P1 = BUF_NR buffers having parity (index in ag = 5)
578  * P2 = FAILED (index in ag = 6)
579  *
580  * In above case, after recovery, the accumulator buffers should have
581  * recovered values of D1 and P2 respectively.
582  */
583 
584  for (i = 0; i < MULTI_FAILURES; ++i) {
585  ret = m0_sns_ir_failure_register(&n_acc_buf[i][0].nb_buffer,
586  failed_idx[i], &n_rag.rag_ir);
587  M0_UT_ASSERT(ret == 0);
588  n_rag.rag_fc[i].fc_failed_idx = failed_idx[i];
589  }
590 
592 
593  M0_ALLOC_ARR(bufs_in_error, unit_count);
594  M0_UT_ASSERT(bufs_in_error != NULL);
595 
596  for (i = 0; i < MULTI_FAILURES; ++i)
597  bufs_in_error[failed_idx[i]] = 1;
598 
599  for (i = 0, j = 0; i < DATA_NR; ++i, ++j) {
600  while (bufs_in_error[j])
601  j++;
602  cp_multi_failures_post(((char *)(x[j].ov_buf[0]))[0], i, j);
603  }
604  m0_free(bufs_in_error);
605 
607 
608  /* Verify that first accumulator contains recovered data for D1 and P2. */
609  for (i = 0; i < MULTI_FAILURES; ++i) {
610  m0_tl_for(cp_data_buf,
612  nbuf) {
613  bv_compare(&x[failed_idx[i]],
614  &nbuf->nb_buffer,
615  SEG_NR, SEG_SIZE);
616  } m0_tl_endfor;
617  }
618 
619  /*
620  * These asserts ensure that all the copy packets have been collected
621  * by the transformation function.
622  */
624 
625  for (i = 0; i < unit_count; i++)
626  bv_free(&x[i]);
627 
628  m0_free(x);
629 
630  for (i = 0; i < MULTI_FAIL_MULTI_CP_NR; ++i)
631  for (j = 0; j < BUF_NR; ++j)
632  bv_free(&n_buf[i][j].nb_buffer);
635 
639  cp_buf_free(sag);
640  m0_fi_disable("m0_sns_cm_tgt_ep", "local-ep");
641 }
642 
643 /*
644  * Initialises the request handler since copy packet fom has to be tested using
645  * request handler infrastructure.
646  */
647 static int xform_init(void)
648 {
649  int rc;
650 
651  M0_SET0(&gob_fid);
652  M0_SET0(&cob_fid);
653 
654  reqh = NULL;
655  pdlay = NULL;
656  cm = NULL;
657  scm = NULL;
658  scm_service = NULL;
659  cdom = NULL;
660  M0_SET0(&sem);
661  M0_SET0(&nbp);
662 
663  /* Global structures for testing bufvec xor correctness. */
664  M0_SET0(&src);
665  M0_SET0(&dst);
666  M0_SET0(&xor);
667 
668  /* Global structures for single copy packet test. */
669  M0_SET0(&s_rag);
670  M0_SET_ARR0(s_fc);
671  M0_SET0(&s_cp);
672  M0_SET0(&s_buf);
673  M0_SET0(&s_acc_buf);
674 
675  /*
676  * Global structures for multiple copy packet test comprising of single
677  * failure.
678  */
679  M0_SET0(&m_rag);
680  M0_SET_ARR0(m_fc);
681  M0_SET_ARR0(m_cp);
684 
685  /*
686  * Global structures for multiple copy packet test comprising of
687  * multiple failures.
688  */
689  M0_SET0(&n_rag);
690  M0_SET_ARR0(n_fc);
691  M0_SET_ARR0(n_cp);
694 
695  rc = cs_init(&sctx);
696  M0_ASSERT(rc == 0);
697 
698  m0_fid_gob_make(&gob_fid, 0, 4);
700 
702  layout_gen(&pdlay, reqh);
704 
706  m0_reqh_service_type_find("M0_CST_SNS_REP"), reqh);
708 
709  cm = container_of(scm_service, struct m0_cm, cm_service);
710  M0_ASSERT(cm != NULL);
711 
712  scm = cm2sns(cm);
713  scm->sc_cob_dom = cdom;
715 
716  ag_init(&s_rag);
717  ag_init(&m_rag);
718  ag_init(&n_rag);
719 
720  return 0;
721 }
722 
723 static int xform_fini(void)
724 {
725  struct m0_cob_domain *cdom;
726  struct m0_stob_id stob_id;
727  int rc;
728 
729  ag_fini(&n_rag);
730  ag_fini(&m_rag);
731  ag_fini(&s_rag);
732 
733  m0_fid_convert_cob2stob(&cob_fid, &stob_id);
734  rc = m0_ut_stob_destroy_by_stob_id(&stob_id);
735  M0_UT_ASSERT(rc == 0);
739  cs_fini(&sctx);
740  return 0;
741 }
742 
744  .ts_name = "snscm_xform-ut",
745  .ts_init = &xform_init,
746  .ts_fini = &xform_fini,
747  .ts_tests = {
748  { "bufvec_xor_correctness", test_bufvec_xor },
749  { "single_cp_passthrough", test_single_cp },
750  { "multi_cp_single_failure",
752  { "multi_cp_multi_failures",
754  { NULL, NULL }
755  }
756 };
757 
758 /*
759  * Local variables:
760  * c-indentation-style: "K&R"
761  * c-basic-offset: 8
762  * tab-width: 8
763  * fill-column: 80
764  * scroll-step: 1
765  * End:
766  */
void cs_fini(struct m0_motr *sctx)
Definition: cp_common.c:221
M0_INTERNAL int m0_bufvec_to_buf_copy(struct m0_buf *buf, const struct m0_bufvec *bvec)
Definition: vec.c:1301
Definition: cm.h:205
struct m0_be_domain * bs_domain
Definition: seg.h:82
static struct m0_sns_cm_repair_ag n_rag
Definition: xform.c:85
M0_INTERNAL void m0_parity_math_fini(struct m0_parity_math *math)
Definition: parity_math.c:325
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
Definition: xform.c:35
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_net_buffer_pool * nb_pool
Definition: net.h:1508
static int xform_fini(void)
Definition: xform.c:723
struct m0_reqh * m0_cs_reqh_get(struct m0_motr *cctx)
Definition: setup.c:1762
uint32_t pmi_data_count
Definition: parity_math.h:127
struct m0_parity_math rag_math
Definition: ag.h:96
#define NULL
Definition: misc.h:38
static struct m0_bufvec dst
Definition: xform.c:61
struct m0_bitmap c_xform_cp_indices
Definition: cp.h:181
M0_INTERNAL int m0_buf_to_bufvec_copy(struct m0_bufvec *bvec, const struct m0_buf *buf)
Definition: vec.c:1315
struct m0_bufvec nb_buffer
Definition: net.h:1322
M0_INTERNAL struct m0_sns_cm * cm2sns(struct m0_cm *cm)
Definition: cm.c:389
m0_bcount_t nbp_seg_size
Definition: buffer_pool.h:255
static bool x
Definition: sm.c:168
struct m0_pool_version * pm_pver
Definition: pool_machine.h:172
static void test_single_cp(void)
Definition: xform.c:307
static const struct m0_cm_aggr_group_ops group_single_fail_multi_cp_ops
Definition: xform.c:113
struct m0_pool_version * pv
Definition: dir.c:629
Definition: cp.h:160
static struct m0_sns_cm_repair_ag_failure_ctx s_fc[SINGLE_FAILURE]
Definition: xform.c:66
static void buf_initialize(struct m0_buf *bufs, uint32_t count, uint32_t len)
Definition: xform.c:442
static size_t dummy_fom_locality(const struct m0_fom *fom)
Definition: xform.c:126
M0_INTERNAL int m0_ut_stob_destroy_by_stob_id(struct m0_stob_id *stob_id)
Definition: stob.c:317
struct m0_vec ov_vec
Definition: vec.h:147
M0_INTERNAL void m0_ios_cdom_get(struct m0_reqh *reqh, struct m0_cob_domain **out)
Definition: io_service.c:463
static const struct m0_cm_aggr_group_ops group_single_ops
Definition: xform.c:104
static void rs_init()
Definition: xform.c:391
struct m0_bufvec data
Definition: di.c:40
struct m0_layout * sf_layout
Definition: file.h:74
Definition: xform.c:38
static struct m0_fom_ops single_cp_fom_ops
Definition: xform.c:188
static struct m0_fom_ops acc_cp_fom_ops
Definition: xform.c:194
static void cp_buf_free(struct m0_sns_cm_ag *sag)
Definition: xform.c:219
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
struct m0_poolmach * sf_pm
Definition: file.h:70
M0_INTERNAL void m0_sns_ir_fini(struct m0_sns_ir *ir)
Definition: parity_math.c:488
Definition: ut.h:77
static struct m0_sns_cm_repair_ag m_rag
Definition: xform.c:75
static struct m0_cob_domain * cdom
Definition: xform.c:55
void ** ov_buf
Definition: vec.h:149
uint64_t(* cago_local_cp_nr)(const struct m0_cm_aggr_group *ag)
Definition: ag.h:146
m0_fom_phase
Definition: fom.h:372
struct m0_pdclust_layout * pdlay
Definition: xform.c:51
static m0_bcount_t count
Definition: xcode.c:167
uint32_t sag_fnr
Definition: ag.h:51
M0_INTERNAL struct m0_reqh_service_type * m0_reqh_service_type_find(const char *sname)
Definition: reqh_service.c:168
const struct m0_sns_cm_helpers xform_ut_repair_helpers
Definition: xform.c:216
static struct m0_bufvec xor
Definition: xform.c:62
M0_INTERNAL int m0_sns_ir_failure_register(struct m0_bufvec *recov_addr, uint32_t failed_index, struct m0_sns_ir *ir)
Definition: parity_math.c:453
uint64_t cag_cp_global_nr
Definition: ag.h:86
struct m0_ut_suite snscm_xform_ut
Definition: xform.c:743
#define m0_tl_endfor
Definition: tlist.h:700
Definition: xform.c:37
M0_INTERNAL int m0_sns_ir_init(const struct m0_parity_math *math, uint32_t local_nr, struct m0_sns_ir *ir)
Definition: parity_math.c:425
int m0_bufvec_alloc_aligned(struct m0_bufvec *bufvec, uint32_t num_segs, m0_bcount_t seg_size, unsigned shift)
Definition: vec.c:355
M0_INTERNAL void m0_parity_math_calculate(struct m0_parity_math *math, struct m0_buf *data, struct m0_buf *parity)
Definition: parity_math.c:362
Definition: buf.h:37
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
Definition: vec.c:395
static void ag_fini(struct m0_sns_cm_repair_ag *rag)
Definition: xform.c:256
static struct m0_sns_cm_ag * sag
Definition: cm.c:66
static void ag_init(struct m0_sns_cm_repair_ag *rag)
Definition: xform.c:248
int i
Definition: dir.c:1033
static struct m0_fid gob_fid
Definition: xform.c:47
struct m0_cm_cp sc_base
Definition: cp.h:39
static void buffers_attach(struct m0_net_buffer *nb, struct m0_cm_cp *cp, char data)
Definition: xform.c:402
static struct m0_sns_cm_cp s_cp
Definition: xform.c:67
#define M0_SET_ARR0(arr)
Definition: misc.h:72
static void single_cp_fom_fini(struct m0_fom *fom)
Definition: xform.c:173
M0_INTERNAL void cob_create(struct m0_reqh *reqh, struct m0_cob_domain *cdom, struct m0_be_domain *bedom, uint64_t cont, struct m0_fid *gfid, uint32_t cob_idx)
Definition: cm.c:176
struct m0_sns_cm_ag rag_base
Definition: ag.h:77
Definition: cnt.h:36
struct m0_sns_ir rag_ir
Definition: ag.h:99
static struct m0_fom_ops multiple_cp_fom_ops
Definition: xform.c:201
static struct m0_sns_cm_repair_ag s_rag
Definition: xform.c:65
M0_INTERNAL void m0_fi_disable(const char *fp_func, const char *fp_tag)
Definition: finject.c:485
static struct m0_semaphore sem
Definition: xform.c:56
static void m0_fi_enable(const char *func, const char *tag)
Definition: finject.h:276
#define M0_ASSERT(cond)
static void ag_prepare(struct m0_sns_cm_repair_ag *rag, int failure_nr, const struct m0_cm_aggr_group_ops *ag_ops, struct m0_sns_cm_repair_ag_failure_ctx *fc)
Definition: xform.c:263
static struct m0_sns_cm_cp m_cp[SINGLE_FAIL_MULTI_CP_NR]
Definition: xform.c:77
static struct m0_net_buffer_pool nbp
Definition: xform.c:57
static uint64_t cp_single_get(const struct m0_cm_aggr_group *ag)
Definition: xform.c:99
void bv_compare(struct m0_bufvec *b1, struct m0_bufvec *b2, uint32_t seg_nr, uint32_t seg_size)
Definition: cp_common.c:95
struct m0_fid fc_tgt_cobfid
Definition: ag.h:60
uint32_t c_data_seg_nr
Definition: cp.h:190
M0_INTERNAL void m0_fid_convert_cob2stob(const struct m0_fid *cob_fid, struct m0_stob_id *stob_id)
Definition: fid_convert.c:141
M0_INTERNAL void m0_cm_cp_fini(struct m0_cm_cp *cp)
Definition: cp.c:682
const struct m0_cm_cp_ops * c_ops
Definition: cp.h:169
M0_INTERNAL void m0_cm_cp_buf_add(struct m0_cm_cp *cp, struct m0_net_buffer *nb)
Definition: cp.c:703
M0_INTERNAL int m0_sns_ir_mat_compute(struct m0_sns_ir *ir)
Definition: parity_math.c:482
M0_INTERNAL int m0_parity_math_init(struct m0_parity_math *math, uint32_t data_count, uint32_t parity_count)
Definition: parity_math.c:333
int(* co_action[])(struct m0_cm_cp *cp)
Definition: cp.h:259
M0_INTERNAL int m0_buf_alloc(struct m0_buf *buf, size_t size)
Definition: buf.c:43
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
M0_INTERNAL void cob_delete(struct m0_cob_domain *cdom, struct m0_be_domain *bedom, uint64_t cont, const struct m0_fid *gfid)
Definition: cm.c:231
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
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
static void cp_multi_failures_post(char data, int cnt, int index)
Definition: xform.c:420
struct m0_sns_cm_cp fc_tgt_acc_cp
Definition: ag.h:45
static struct m0_sns_cm_cp n_cp[MULTI_FAIL_MULTI_CP_NR]
Definition: xform.c:87
static struct m0_reqh_service * scm_service
Definition: xform.c:54
Definition: reqh.h:94
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
Definition: bitmap.c:139
static struct m0_net_buffer m_buf[SINGLE_FAIL_MULTI_CP_NR]
Definition: xform.c:78
uint32_t v_nr
Definition: vec.h:51
M0_INTERNAL struct m0_sns_cm_repair_ag * sag2repairag(const struct m0_sns_cm_ag *sag)
Definition: ag.c:61
Definition: dump.c:103
M0_INTERNAL void m0_buf_free(struct m0_buf *buf)
Definition: buf.c:55
static void bufvec_xor(struct m0_bufvec *dst, struct m0_bufvec *src, m0_bcount_t num_bytes)
Definition: xform.c:69
static struct m0_net_buffer m_acc_buf[SINGLE_FAILURE]
Definition: xform.c:79
M0_INTERNAL int m0_cm_cp_bufvec_merge(struct m0_cm_cp *cp)
Definition: cp.c:752
struct m0_cob_domain * sc_cob_dom
Definition: cm.h:217
void bv_alloc_populate(struct m0_bufvec *b, char data, uint32_t seg_nr, uint32_t seg_size)
Definition: cp_common.c:84
static struct m0_net_buffer n_buf[MULTI_FAIL_MULTI_CP_NR][BUF_NR]
Definition: xform.c:88
void layout_destroy(struct m0_pdclust_layout *pdlay)
Definition: cp_common.c:257
M0_INTERNAL void m0_reqh_idle_wait(struct m0_reqh *reqh)
Definition: reqh.c:606
uint64_t cag_transformed_cp_nr
Definition: ag.h:95
M0_INTERNAL int m0_ut_stob_create_by_stob_id(struct m0_stob_id *stob_id, const char *str_cfg)
Definition: stob.c:301
M0_INTERNAL struct m0_layout * m0_pdl_to_layout(struct m0_pdclust_layout *pl)
Definition: pdclust.c:393
static void test_multi_cp_single_failure(void)
Definition: xform.c:348
Definition: fom.h:481
const char * ts_name
Definition: ut.h:99
struct m0_sns_cm_file_ctx * sag_fctx
Definition: ag.h:48
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_sns_cm_repair_ag_failure_ctx * rag_fc
Definition: ag.h:93
static void ref_parity_calculate(struct m0_parity_math *math, struct m0_bufvec *bufvecs)
Definition: xform.c:461
static struct m0_fid cob_fid
Definition: xform.c:48
Definition: fid.h:38
static struct m0_net_buffer s_acc_buf
Definition: xform.c:69
static int dummy_acc_cp_fom_tick(struct m0_fom *fom)
Definition: xform.c:154
static void test_multi_cp_multi_failures(void)
Definition: xform.c:507
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
static void test_bufvec_xor()
Definition: xform.c:286
const struct m0_cm_aggr_group_ops * cag_ops
Definition: ag.h:74
static struct m0_reqh * reqh
Definition: xform.c:50
int cs_init(struct m0_motr *sctx)
Definition: cp_common.c:206
static const struct m0_cm_aggr_group_ops group_multi_fail_multi_cp_ops
Definition: xform.c:122
static uint64_t single_fail_multi_cp_get(const struct m0_cm_aggr_group *ag)
Definition: xform.c:108
bool sc_is_local
Definition: cp.h:53
Definition: cm.h:166
void bv_populate(struct m0_bufvec *b, char data, uint32_t seg_nr, uint32_t seg_size)
Definition: cp_common.c:71
static struct m0_sns_cm_repair_ag_failure_ctx n_fc[MULTI_FAILURES]
Definition: xform.c:86
static int dummy_fom_tick(struct m0_fom *fom)
Definition: xform.c:133
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
static void buf_free(struct m0_buf *bufs, uint32_t count)
Definition: xform.c:453
uint64_t cag_cp_local_nr
Definition: ag.h:92
void bv_free(struct m0_bufvec *b)
Definition: cp_common.c:115
struct m0_be_seg * rh_beseg
Definition: reqh.h:112
static struct m0_bufvec src
Definition: xform.c:60
M0_INTERNAL void m0_fom_queue(struct m0_fom *fom)
Definition: fom.c:624
struct m0_tl c_buffers
Definition: cp.h:184
Definition: xform.c:36
struct m0_mutex cag_mutex
Definition: ag.h:76
void(* fo_fini)(struct m0_fom *fom)
Definition: fom.h:657
static struct m0_cm * cm
Definition: xform.c:52
static int xform_init(void)
Definition: xform.c:647
static struct m0_sns_cm_file_ctx fctx
Definition: net.c:55
static struct m0_sns_cm_repair_ag rag
Definition: net.c:54
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
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
struct m0_cm_aggr_group sag_base
Definition: ag.h:46
void m0_fom_phase_set(struct m0_fom *fom, int phase)
Definition: fom.c:1688
static void tgt_fid_cob_create(struct m0_reqh *reqh)
Definition: xform.c:235
struct m0_fid gfid
Definition: dir.c:626
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
struct m0_fom c_fom
Definition: cp.h:161
static void multiple_cp_fom_fini(struct m0_fom *fom)
Definition: xform.c:180
void layout_gen(struct m0_pdclust_layout **pdlay, struct m0_reqh *reqh)
Definition: cp_common.c:227
static uint64_t multi_fail_multi_cp_get(const struct m0_cm_aggr_group *ag)
Definition: xform.c:117
void cp_prepare(struct m0_cm_cp *cp, struct m0_net_buffer *buf, uint32_t bv_seg_nr, uint32_t bv_seg_size, struct m0_sns_cm_ag *sns_ag, char data, struct m0_fom_ops *cp_fom_ops, struct m0_reqh *reqh, uint64_t cp_ag_idx, bool is_acc_cp, struct m0_cm *cm)
Definition: cp_common.c:120
static struct m0_sns_cm * scm
Definition: xform.c:53
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
void m0_free(void *data)
Definition: memory.c:146
static struct m0_net_buffer s_buf
Definition: xform.c:68
static struct m0_net_buffer n_acc_buf[MULTI_FAILURES][BUF_NR]
Definition: xform.c:89
const struct m0_sns_cm_helpers * sc_helpers
Definition: cm.h:215
int32_t rc
Definition: trigger_fop.h:47
#define M0_UT_ASSERT(a)
Definition: ut.h:46
uint32_t pmi_parity_count
Definition: parity_math.h:128
static struct m0_sns_cm_repair_ag_failure_ctx m_fc[SINGLE_FAILURE]
Definition: xform.c:76
Definition: vec.h:145
#define M0_IMPOSSIBLE(fmt,...)