Motr  M0
net.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 <unistd.h> /* sleep */
24 
25 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_SNSCM
26 #include "lib/trace.h"
27 
28 #include "sns/cm/repair/ag.h" /* sag2repairag */
29 #include "sns/cm/repair/ut/cp_common.h" /* cp_prepare */
30 #include "ioservice/fid_convert.h" /* m0_fid_convert_cob2stob */
31 #include "ioservice/io_service.h" /* m0_ios_cdom_get */
32 #include "rpc/rpclib.h" /* m0_rpc_client_ctx */
33 #include "rpc/rpc_opcodes.h" /* M0_CM_UT_SENDER_OPCODE */
34 #include "lib/fs.h" /* m0_file_read */
35 #include "lib/finject.h"
36 #include "ut/ut_rpc_machine.h" /* m0_ut_rpc_mach_ctx */
37 #include "ut/stob.h" /* m0_ut_stob_create_by_stob_id */
38 #include "ut/misc.h" /* M0_UT_PATH */
39 #include "ut/ut.h"
40 
41 #include "sns/cm/repair/ag.c" /* m0_sns_cm_acc_cp_init */
42 #include "ha/msg.h" /* m0_ha_msg */
43 
44 #define DUMMY_DBNAME "dummy-db"
45 #define DUMMY_COB_ID 20
46 #define DUMMY_SERVER_ADDR "0@lo:12345:34:10"
47 
48 /* Receiver side. */
49 static struct m0_reqh *s0_reqh;
50 static struct m0_cm *recv_cm;
51 static struct m0_sns_cm *recv_scm;
53 static struct m0_cm_aggr_group *ag_cpy;
54 static struct m0_sns_cm_repair_ag rag;
55 static struct m0_sns_cm_file_ctx fctx;
56 
57 /*
58  * Global structures for read copy packet used for verification.
59  * (Receiver side).
60  */
61 static struct m0_sns_cm_repair_ag r_rag;
62 static struct m0_sns_cm_cp r_sns_cp;
63 static struct m0_net_buffer r_buf;
64 static struct m0_net_buffer_pool r_nbp;
65 
66 /* Sender side. */
67 enum {
72  CP_SINGLE = 1,
73  FAIL_NR = 1,
74  BUF_NR = 4,
75  START_DATA = 101,
76  DEV_ID = 1,
77  KEY = 1
78 };
79 
81 static struct m0_semaphore sem;
82 static struct m0_semaphore cp_sem;
83 static struct m0_semaphore read_cp_sem;
84 static struct m0_semaphore write_cp_sem;
85 
86 static const char client_addr[] = "0@lo:12345:34:2";
87 static const char server_addr[] = "0@lo:12345:34:1";
88 
89 static struct m0_rpc_client_ctx cctx = {
91  .rcx_local_addr = client_addr,
92  .rcx_remote_addr = server_addr,
93  .rcx_max_rpcs_in_flight = MAX_RPCS_IN_FLIGHT,
94  .rcx_fid = &g_process_fid,
95 };
96 
97 extern struct m0_cm_type sender_cm_cmt;
98 
100 static struct m0_cm sender_cm;
102 static struct m0_cm_cp sender_cm_cp;
103 static struct m0_motr sender_motr = { .cc_pool_width = 10 };
105 
106 /* Global structures for copy packet to be sent (Sender side). */
108 static struct m0_sns_cm_cp s_sns_cp;
109 static struct m0_net_buffer_pool nbp;
111 static struct m0_cm_proxy *recv_cm_proxy;
112 static struct m0_rpc_conn conn;
113 static struct m0_rpc_session session;
114 
115 static struct m0_fid gob_fid;
116 static struct m0_fid cob_fid;
117 
119 static uint32_t seg_nr;
120 
121 static struct m0_cm_ag_id ag_id = {
122  .ai_hi = {
123  .u_hi = DEV_ID,
124  .u_lo = KEY
125  },
126  .ai_lo = {
127  .u_hi = 0,
128  .u_lo = 1
129  }
130 };
131 
132 static const struct m0_fid M0_SNS_CM_NET_UT_PVER = M0_FID_TINIT('v', 1, 8);
133 
134 M0_INTERNAL void cob_create(struct m0_reqh *reqh, struct m0_cob_domain *cdom,
135  struct m0_be_domain *bedom,
136  uint64_t cont, struct m0_fid *gfid,
137  uint32_t cob_idx);
138 M0_INTERNAL void cob_delete(struct m0_cob_domain *cdom,
139  struct m0_be_domain *bedom,
140  uint64_t cont, const struct m0_fid *gfid);
141 
142 M0_INTERNAL int m0_sns_cm_repair_cp_send(struct m0_cm_cp *cp);
143 
144 static void fail_device(struct m0_cm *cm)
145 {
146  struct m0_motr *motr;
147  struct m0_pool_version *pver;
148  struct m0_reqh *reqh;
149 
153  M0_UT_ASSERT(pver != NULL);
156 }
157 
158 static uint64_t cp_single_get(const struct m0_cm_aggr_group *ag)
159 {
160  return CP_SINGLE;
161 }
162 
163 static void cp_ag_fini(struct m0_cm_aggr_group *ag)
164 {
165 
166  M0_PRE(ag != NULL);
167 
169 }
170 
171 static bool cp_ag_can_fini(const struct m0_cm_aggr_group *ag)
172 {
174 
176  ag->cag_freed_cp_nr) {
177  /*
178  * We wait until accumulator write is complete, before proceeding
179  * for read.
180  */
181  if (rag->rag_acc_inuse_nr > 0)
183  return true;
184  }
185 
186  return false;
187 
188 }
189 
190 static const struct m0_cm_aggr_group_ops group_ops = {
192  .cago_fini = &cp_ag_fini,
193  .cago_ag_can_fini = &cp_ag_can_fini
194 };
195 
196 /* Over-ridden copy packet FOM fini. */
197 static void dummy_fom_fini(struct m0_fom *fom)
198 {
201 }
202 
203 /* Over-ridden copy packet FOM locality (using single locality). */
204 static uint64_t dummy_fom_locality(const struct m0_fom *fom)
205 {
206  return 0;
207 }
208 
209 /* Over-ridden copy packet FOM tick. */
210 static int dummy_fom_tick(struct m0_fom *fom)
211 {
212  struct m0_cm_cp *cp = container_of(fom, struct m0_cm_cp, c_fom);
213 
214  switch (m0_fom_phase(fom)) {
215  case M0_FOM_PHASE_INIT:
218  return cp->c_ops->co_action[M0_CCP_XFORM](cp);
219  case M0_CCP_XFORM:
221  return cp->c_ops->co_action[M0_CCP_SEND](cp);
222  case M0_CCP_SEND:
224  return cp->c_ops->co_action[M0_CCP_SEND_WAIT](cp);
225  case M0_CCP_SEND_WAIT:
227  return M0_FSO_WAIT;
228  default:
229  M0_IMPOSSIBLE("Bad State");
230  return 0;
231  }
232 }
233 
234 /* Over-ridden copy packet FOM ops. */
235 static struct m0_fom_ops cp_fom_ops = {
237  .fo_tick = dummy_fom_tick,
238  .fo_home_locality = dummy_fom_locality,
239 };
240 
241 /* Over-ridden copy packet init phase. */
242 static int dummy_cp_init(struct m0_cm_cp *cp)
243 {
244  /* This is used to ensure that ast has been posted. */
246  return M0_FSO_AGAIN;
247 }
248 
249 /* Passthorugh phase for testing purpose. */
250 static int dummy_cp_phase(struct m0_cm_cp *cp)
251 {
252  return M0_FSO_AGAIN;
253 }
254 
255 /* Passthorugh for testing purpose. */
256 static void dummy_cp_complete(struct m0_cm_cp *cp)
257 {
258 }
259 
260 static uint64_t dummy_home_loc_helper(const struct m0_cm_cp *cp)
261 {
262  return 1;
263 }
264 
265 static void cm_cp_free(struct m0_cm_cp *cp)
266 {
267  struct m0_cm_aggr_group *ag = cp->c_ag;
268 
270 
271  if (ag != NULL)
272  m0_cm_ag_cp_del(ag, cp);
273 }
274 
275 static bool sender_cm_cp_invariant(const struct m0_cm_cp *cp)
276 {
277  return true;
278 }
279 
280 static const struct m0_cm_cp_ops sender_cm_cp_ops = {
282  .co_free = cm_cp_free
283 };
284 
285 const struct m0_cm_cp_ops cp_dummy_ops = {
286  .co_action = {
300  },
301  .co_action_nr = M0_CCP_NR,
302  .co_phase_next = &m0_sns_cm_cp_phase_next,
303  .co_invariant = &m0_sns_cm_cp_invariant,
304  .co_complete = &dummy_cp_complete,
305  .co_free = &cm_cp_free,
306  .co_home_loc_helper = &dummy_home_loc_helper
307 };
308 
309 /* Over-ridden read copy packet FOM tick. */
310 static int dummy_read_fom_tick(struct m0_fom *fom)
311 {
312  struct m0_cm_cp *cp = container_of(fom, struct m0_cm_cp, c_fom);
313  return cp->c_ops->co_action[m0_fom_phase(fom)](cp);
314 }
315 
316 /* Over-ridden read copy packet FOM fini. */
317 static void dummy_read_fom_fini(struct m0_fom *fom)
318 {
324 }
325 
326 /* Over-ridden read copy packet FOM ops. */
327 static struct m0_fom_ops read_cp_fom_ops = {
329  .fo_tick = dummy_read_fom_tick,
330  .fo_home_locality = dummy_fom_locality,
331 };
332 
333 /*
334  * Over-ridden copy packet init phase for read copy packet.
335  * For unit-test purpose, the epoch checking code is copied from
336  * m0_sns_cm_cp_init().
337  */
338 static int dummy_read_cp_init(struct m0_cm_cp *cp)
339 {
340  /* This is used to ensure that ast has been posted. */
342  return cp->c_ops->co_phase_next(cp);
343 }
344 
345 /* Passthorugh phase for testing purpose. */
346 static int dummy_read_cp_phase(struct m0_cm_cp *cp)
347 {
348  if (m0_fom_phase(&cp->c_fom) == M0_CCP_RECV_INIT &&
350  return m0_sns_cm_cp_recv_init(cp);
351  return cp->c_ops->co_phase_next(cp);
352 }
353 
354 static void buffers_verify()
355 {
356  int i;
357  int j;
358  int rc;
359  int cnt = 0;
360  char *str = m0_alloc(seg_size * sizeof(char));
361  if (str == NULL)
362  return;
363 
364  for (i = 0; i < BUF_NR; ++i) {
365  for (j = 0; j < seg_nr; ++j) {
366  memset(str, (START_DATA + i), seg_size);
367  rc = memcmp(r_buf.nb_buffer.ov_buf[cnt], str, seg_size);
368  M0_UT_ASSERT(rc == 0);
369  cnt++;
370  }
371  }
372  m0_free(str);
373 }
374 
375 /* Passthorugh phase for testing purpose. */
376 static int dummy_read_cp_xform(struct m0_cm_cp *cp)
377 {
378  buffers_verify();
379  return cp->c_ops->co_phase_next(cp);
380 }
381 
382 /*
383  * Over-ridden copy packet write io wait phase. This is used when read operation
384  * of copy packet has to be tested. In this case, write io wait phase will
385  * simply be a passthrough phase.
386  */
387 static int dummy_cp_write_io_wait(struct m0_cm_cp *cp)
388 {
389  return cp->c_io_op == M0_CM_CP_WRITE ?
390  cp->c_ops->co_phase_next(cp) :
392 }
393 
394 /*
395  * Over-ridden copy packet write phase. This is used when read operation of
396  * copy packet has to be tested. In this case, write phase will simply be a
397  * passthrough phase.
398  */
399 static int dummy_cp_write(struct m0_cm_cp *cp)
400 {
401  cp->c_io_op = M0_CM_CP_WRITE;
402  cp->c_ops->co_phase_next(cp);
403  return M0_FSO_AGAIN;
404 }
405 
406 const struct m0_cm_cp_ops read_cp_ops = {
407  .co_action = {
421  },
422  .co_action_nr = M0_CCP_NR,
423  .co_phase_next = &m0_sns_cm_cp_phase_next,
424  .co_invariant = &m0_sns_cm_cp_invariant,
425  .co_complete = &dummy_cp_complete,
426  .co_free = &cm_cp_free
427 };
428 
429 static void ag_setup(struct m0_sns_cm_ag *sag, struct m0_cm *cm)
430 {
431  m0_cm_lock(cm);
433  m0_cm_unlock(cm);
434  sag->sag_fctx = &fctx;
436  sag->sag_fnr = FAIL_NR;
439 }
440 
441 /*
442  * Read the copy packet which has completed its fom cycle and ended up
443  * writing the data which was sent onwire. After reading, verify the
444  * data for correctness.
445  */
446 
447 static void read_and_verify()
448 {
449  char data;
450 
451  M0_SET0(&r_rag);
452  M0_SET0(&r_sns_cp);
453  M0_SET0(&r_buf);
454  M0_SET0(&r_nbp);
455 
457 
459 
460  r_buf.nb_pool = &r_nbp;
461  /*
462  * Purposefully fill the read bv with spaces i.e. ' '. This should get
463  * replaced by appropriate data, when the data is read.
464  */
465  data = ' ';
467  &r_rag.rag_base, data, &read_cp_fom_ops, s0_reqh, 0, false,
468  recv_cm);
469 
472  r_sns_cp.sc_index = 0;
475 
477 }
478 
479 /* Create and add the aggregation group to the list in copy machine. */
480 static void receiver_ag_create(struct m0_cm *cm)
481 {
482  int i;
483  struct m0_sns_cm_ag *sag;
484  struct m0_cm_aggr_group *ag;
485  struct m0_sns_cm_cp *sns_cp;
486 
487  sag = &rag.rag_base;
488  ag_setup(sag, cm);
489  ag = &sag->sag_base;
490  sag->sag_base.cag_cm = cm;
491  sag->sag_base.cag_has_incoming = true;
492  sag->sag_local_tgts_nr = 1;
495  m0_mutex_init(&ag->cag_mutex);
496  aggr_grps_in_tlink_init(ag);
497  aggr_grps_out_tlink_init(ag);
500  for (i = 0; i < sag->sag_fnr; ++i) {
502  rag.rag_fc[i].fc_is_inuse = true;
504  sns_cp = &rag.rag_fc[i].fc_tgt_acc_cp;
505  m0_sns_cm_acc_cp_init(sns_cp, sag);
506  sns_cp->sc_base.c_data_seg_nr = seg_nr * BUF_NR;
508  sns_cp->sc_cobfid = rag.rag_fc[i].fc_tgt_cobfid;
509  sns_cp->sc_is_acc = true;
510  m0_cm_lock(cm);
512  m0_cm_unlock(cm);
513  }
514 
515  m0_cm_lock(cm);
518  m0_cm_unlock(cm);
520 }
521 
522 static void receiver_stob_create()
523 {
524  struct m0_cob_domain *cdom;
525  struct m0_stob_id stob_id;
526  int rc;
527 
530 
531  /*
532  * Create a stob. In actual repair scenario, this will already be
533  * created by the IO path.
534  */
535  m0_fid_convert_cob2stob(&cob_fid, &stob_id);
536  rc = m0_ut_stob_create_by_stob_id(&stob_id, NULL);
537  M0_UT_ASSERT(rc == 0);
538 }
539 
540 static void cm_ready(struct m0_cm *cm)
541 {
542  m0_cm_lock(cm);
544  m0_cm_unlock(cm);
545 }
546 
547 static void receiver_init(void)
548 {
549  int rc;
550 
551  M0_SET0(&rag);
552  M0_SET0(&fctx);
553 
555  M0_UT_ASSERT(rc == 0);
556 
557  rc = cs_init(&sctx);
558  M0_UT_ASSERT(rc == 0);
559 
562  m0_reqh_service_type_find("M0_CST_SNS_REP"), s0_reqh);
564 
565  recv_cm = container_of(scm_service, struct m0_cm, cm_service);
567 
570 
576 
578 
579  cm_ready(recv_cm);
581 
591 }
592 
593 static struct m0_cm_cp* sender_cm_cp_alloc(struct m0_cm *cm)
594 {
596  return &sender_cm_cp;
597 }
598 
599 static int sender_cm_setup(struct m0_cm *cm)
600 {
601  return 0;
602 }
603 
604 static int sender_cm_start(struct m0_cm *cm)
605 {
606  return 0;
607 }
608 
609 static void sender_cm_stop(struct m0_cm *cm)
610 {
611 }
612 
613 static int sender_cm_data_next(struct m0_cm *cm, struct m0_cm_cp *cp)
614 {
615  return -ENODATA;
616 }
617 
618 static void sender_cm_fini(struct m0_cm *cm)
619 {
620 }
621 
622 static int sender_cm_prepare(struct m0_cm *cm)
623 {
624  return 0;
625 }
626 
627 static int sender_cm_ag_next(struct m0_cm *cm,
628  const struct m0_cm_ag_id *id_curr,
629  struct m0_cm_ag_id *id_next)
630 {
631  return -ENODATA;
632 }
633 
634 static void sender_cm_ha_msg(struct m0_cm *cm,
635  struct m0_ha_msg *msg, int rc)
636 {
637 }
638 
639 static const struct m0_cm_ops sender_cm_ops = {
641  .cmo_prepare = sender_cm_prepare,
642  .cmo_start = sender_cm_start,
643  .cmo_stop = sender_cm_stop,
644  .cmo_cp_alloc = sender_cm_cp_alloc,
645  .cmo_data_next = sender_cm_data_next,
646  .cmo_ag_next = sender_cm_ag_next,
647  .cmo_ha_msg = sender_cm_ha_msg,
648  .cmo_fini = sender_cm_fini
649 };
650 
652 {
653  return m0_cm_setup(container_of(service, struct m0_cm, cm_service));
654 }
655 
657 {
658  struct m0_cm *cm = container_of(service, struct m0_cm, cm_service);
659  m0_cm_fini(cm);
660 }
661 
663 {
665  M0_SET0(&sender_cm);
666 }
667 
670  .rso_stop = sender_cm_service_stop,
671  .rso_fini = sender_cm_service_fini
672 };
673 
675  const struct m0_reqh_service_type *stype)
676 {
677  struct m0_cm *cm = &sender_cm;
678 
679  *service = &cm->cm_service;
680  (*service)->rs_ops = &sender_cm_service_ops;
681  (*service)->rs_sm.sm_state = M0_RST_INITIALISING;
682 
683  return m0_cm_init(cm, container_of(stype, struct m0_cm_type, ct_stype),
684  &sender_cm_ops);
685 }
686 
689 };
690 
692  &sender_cm_service_type_ops, "sender_cm", 0);
693 
695 {
696  int rc;
697  /* Internally calls m0_cm_init(). */
701  &sender_rctx);
702  M0_ASSERT(rc == 0);
704 }
705 
706 M0_TL_DECLARE(proxy_cp, M0_EXTERN, struct m0_cm_cp);
707 
708 static void sender_ag_create()
709 {
710  struct m0_sns_cm_ag *sag;
711 
712  M0_SET0(&s_rag);
713  sag = &s_rag.rag_base;
720 }
721 
723 {
724 }
725 
727 {
728 }
729 
732  .nbpo_below_threshold = bp_below_threshold
733 };
734 
735 static void sender_init()
736 {
737  struct m0_confc *confc;
738  struct m0_locality *locality;
739  struct m0_net_domain *ndom;
740  struct m0_cm_ag_id agid0;
741  char *confstr = NULL;
742  uint32_t colours;
743  int nr_bufs;
744  int rc;
745 
746  M0_SET0(&rmach_ctx);
747  M0_SET0(&sender_cm);
749  M0_SET0(&s_rag);
750  M0_SET0(&s_sns_cp);
751  M0_SET0(&nbp);
752  M0_SET0(&conn);
753  M0_SET0(&session);
754 
755 
759 
763  rc = m0_file_read(M0_UT_PATH("diter.xc"), &confstr);
764  M0_UT_ASSERT(rc == 0);
765  rc = m0_confc_init(confc, locality->lo_grp, NULL, NULL, confstr);
766  M0_UT_ASSERT(rc == 0);
767  m0_free0(&confstr);
768 
770  M0_UT_ASSERT(rc == 0);
771 
777 
779 
781  ndom = &rmach_ctx.rmc_net_dom;
786  colours, M0_0VEC_SHIFT, false);
787  M0_UT_ASSERT(rc == 0);
788  nbp.nbp_ops = &bp_ops;
792  M0_UT_ASSERT(nr_bufs == 4);
794 
796 
798 
800  M0_UT_ASSERT(rc == 0);
801 
803  M0_UT_ASSERT(rc == 0);
807  M0_TIME_NEVER);
808  M0_UT_ASSERT(rc == 0);
813  M0_SET0(&agid0);
820 }
821 
822 static void receiver_fini()
823 {
824  struct m0_cob_domain *cdom;
825  struct m0_stob_id stob_id;
826  int rc;
827 
828  recv_cm_proxy->px_is_done = true;
835  m0_fid_convert_cob2stob(&cob_fid, &stob_id);
836  rc = m0_ut_stob_destroy_by_stob_id(&stob_id);
837  M0_UT_ASSERT(rc == 0);
841  cs_fini(&sctx);
843 }
844 
845 static void sender_fini()
846 {
847  struct m0_confc *confc;
848  int rc;
849 
850  sender_cm_proxy->px_is_done = true;
858  M0_UT_ASSERT(rc == 0);
860  M0_UT_ASSERT(rc == 0);
862  M0_UT_ASSERT(rc == 0);
871 
873 
877 }
878 
879 static void test_fini()
880 {
882  sender_fini();
884  receiver_fini();
885 }
886 
887 static void test_init(bool ag_create)
888 {
889  M0_SET0(&rag);
890  M0_SET0(&fctx);
891  M0_SET0(&r_rag);
892  M0_SET0(&r_sns_cp);
893  M0_SET0(&r_buf);
894  M0_SET0(&r_nbp);
896  M0_SET0(&sem);
897  M0_SET0(&cp_sem);
899  M0_SET0(&rmach_ctx);
900  M0_SET0(&sender_cm);
902  M0_SET0(&s_rag);
903  M0_SET0(&s_sns_cp);
904  M0_SET0(&nbp);
905  M0_SET0(&conn);
906  M0_SET0(&session);
907  M0_SET0(&gob_fid);
908  M0_SET0(&cob_fid);
909 
910  m0_fid_gob_make(&gob_fid, 0, 4);
912  receiver_init();
913  sender_init();
914  if (ag_create)
918 }
919 
921 {
922  struct m0_sns_cm_ag *sag;
923  struct m0_net_buffer *nbuf;
924  int i;
925  char data;
926  struct m0_pool_version pv;
927  struct m0_poolmach pm;
928  m0_time_t epoch_saved;
929 
930  m0_fi_enable("m0_sns_cm_tgt_ep", "local-ep");
931  m0_fi_enable("cpp_data_next", "enodata");
932  m0_fi_enable("m0_ha_local_state_set", "no_ha");
933 
934  test_init(false);
936 
937  m0_semaphore_init(&sem, 0);
939 
940  sag = &s_rag.rag_base;
941  pm.pm_pver = &pv;
942  fctx.sf_pm = &pm;
943  sag->sag_fctx = &fctx;
944  data = START_DATA;
949  sag, data, &cp_fom_ops,
950  sender_cm_service->rs_reqh, 0, false,
951  &sender_cm);
952  for (i = 1; i < BUF_NR; ++i) {
953  data = i + START_DATA;
959  }
960  m0_tl_for(cp_data_buf, &s_sns_cp.sc_base.c_buffers, nbuf) {
961  M0_UT_ASSERT(nbuf != NULL);
962  } m0_tl_endfor;
963 
967  /* Set some bit to true. */
973  s_sns_cp.sc_index = 0;
977  /* Assume this as accumulator copy packet to be sent on remote side. */
979 
980  epoch_saved = recv_cm_proxy->px_epoch;
981  recv_cm_proxy->px_epoch = 0x1234567890abcdef;
983 
984  /* Wait till ast gets posted. */
987  sleep(STOB_UPDATE_DELAY);
988 
989  recv_cm_proxy->px_epoch = epoch_saved;
992  while (m0_net_buffer_pool_prune(&nbp))
993  {;}
995 
996  test_fini();
997 
998  m0_fi_disable("m0_sns_cm_tgt_ep", "local-ep");
999  m0_fi_disable("cpp_data_next", "enodata");
1000  m0_fi_disable("m0_ha_local_state_set", "no_ha");
1001 }
1002 
1004 {
1005  struct m0_sns_cm_ag *sag;
1006  struct m0_net_buffer *nbuf;
1007  int i;
1008  char data;
1009  struct m0_pool_version pv;
1010  struct m0_poolmach pm;
1011  struct m0_pdclust_layout *pdlay;
1012 
1013  m0_fi_enable("m0_sns_cm_tgt_ep", "local-ep");
1014  m0_fi_enable("cpp_data_next", "enodata");
1015  m0_fi_enable("m0_ha_local_state_set", "no_ha");
1016  m0_fi_enable("cp_stob_release_exts", "no-stob-punch");
1017 
1018  test_init(true);
1020 
1021  m0_semaphore_init(&sem, 0);
1024 
1026  sag = &s_rag.rag_base;
1027  pm.pm_pver = &pv;
1028  fctx.sf_pm = &pm;
1030  sag->sag_fctx = &fctx;
1031  data = START_DATA;
1036  sag, data, &cp_fom_ops,
1037  sender_cm_service->rs_reqh, 0, false,
1038  &sender_cm);
1039  for (i = 1; i < BUF_NR; ++i) {
1040  data = i + START_DATA;
1046  }
1047  m0_tl_for(cp_data_buf, &s_sns_cp.sc_base.c_buffers, nbuf) {
1048  M0_UT_ASSERT(nbuf != NULL);
1049  } m0_tl_endfor;
1050 
1054  /* Set some bit to true. */
1060  s_sns_cp.sc_index = 0;
1064  /* Assume this as accumulator copy packet to be sent on remote side. */
1067 
1069 
1070  /* Wait till ast gets posted. */
1074  sleep(STOB_UPDATE_DELAY);
1075 
1076  read_and_verify();
1077 
1080  while (m0_net_buffer_pool_prune(&nbp))
1081  {;}
1083 
1085 
1087  test_fini();
1088 
1089  m0_fi_disable("cp_stob_release_exts", "no-stob-punch");
1090  m0_fi_disable("m0_sns_cm_tgt_ep", "local-ep");
1091  m0_fi_disable("cpp_data_next", "enodata");
1092  m0_fi_disable("m0_ha_local_state_set", "no_ha");
1093 }
1094 
1096  .ts_name = "snscm_net-ut",
1097  .ts_tests = {
1098  { "cp-send-recv-verify", test_cp_send_recv_verify },
1099  { "cp-send-mismatched-epoch", test_cp_send_mismatch_epoch },
1100  { NULL, NULL }
1101  }
1102 };
1103 
1104 #undef M0_TRACE_SUBSYSTEM
1105 /*
1106  * Local variables:
1107  * c-indentation-style: "K&R"
1108  * c-basic-offset: 8
1109  * tab-width: 8
1110  * fill-column: 80
1111  * scroll-step: 1
1112  * End:
1113  */
static m0_bcount_t seg_size
Definition: net.c:118
static int sender_cm_setup(struct m0_cm *cm)
Definition: net.c:599
void cs_fini(struct m0_motr *sctx)
Definition: cp_common.c:221
M0_INTERNAL m0_bcount_t m0_net_domain_get_max_buffer_segment_size(struct m0_net_domain *dom)
bool(* co_invariant)(const struct m0_cm_cp *cp)
Definition: cp.h:235
M0_INTERNAL void m0_cm_cp_buf_release(struct m0_cm_cp *cp)
Definition: cp.c:713
uint64_t id
Definition: cob.h:240
Definition: cm.h:205
static struct m0_fid gob_fid
Definition: net.c:115
static int dummy_cp_write(struct m0_cm_cp *cp)
Definition: net.c:399
struct m0_net_domain rmc_net_dom
struct m0_be_domain * bs_domain
Definition: seg.h:82
static struct m0_rpc_client_ctx cctx
Definition: net.c:89
M0_INTERNAL void m0_cm_lock(struct m0_cm *cm)
Definition: cm.c:545
#define M0_PRE(cond)
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service)
Definition: reqh_service.c:343
M0_INTERNAL int m0_bitmap_init(struct m0_bitmap *map, size_t nr)
Definition: bitmap.c:86
M0_INTERNAL void m0_cm_ag_cp_del(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:520
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
M0_INTERNAL void m0_ut_rpc_mach_init_and_add(struct m0_ut_rpc_mach_ctx *ctx)
int(* rso_start)(struct m0_reqh_service *service)
Definition: reqh_service.h:360
struct m0_net_buffer_pool * nb_pool
Definition: net.h:1508
static uint64_t dummy_home_loc_helper(const struct m0_cm_cp *cp)
Definition: net.c:260
struct m0_reqh * m0_cs_reqh_get(struct m0_motr *cctx)
Definition: setup.c:1762
static uint32_t seg_nr
Definition: net.c:119
static void receiver_fini()
Definition: net.c:822
M0_INTERNAL void m0_reqh_service_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:402
struct m0_sns_cm_buf_pool sc_obp
Definition: cm.h:240
#define NULL
Definition: misc.h:38
static struct m0_motr sender_motr
Definition: net.c:103
static const struct m0_fid M0_SNS_CM_NET_UT_PVER
Definition: net.c:132
M0_INTERNAL int m0_sns_cm_cp_send_wait(struct m0_cm_cp *cp)
Definition: net.c:297
struct m0_bitmap c_xform_cp_indices
Definition: cp.h:181
struct m0_stob_id sc_stob_id
Definition: cp.h:45
static void sender_init()
Definition: net.c:735
static const struct m0_reqh_service_ops sender_cm_service_ops
Definition: net.c:668
static size_t locality(const struct m0_fom *fom)
Definition: rm_foms.c:269
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_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
Definition: net.c:76
static int sender_cm_prepare(struct m0_cm *cm)
Definition: net.c:622
static struct m0_sns_cm_cp s_sns_cp
Definition: net.c:108
static bool cp_ag_can_fini(const struct m0_cm_aggr_group *ag)
Definition: net.c:171
M0_INTERNAL void m0_sns_cm_acc_cp_init(struct m0_sns_cm_cp *scp, struct m0_sns_cm_ag *sag)
Definition: acc_cp.c:108
const struct m0_cm_ops * cm_ops
Definition: cm.h:188
struct m0_pool_version * pm_pver
Definition: pool_machine.h:172
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
M0_INTERNAL struct m0_pool_version * m0_pool_version_find(struct m0_pools_common *pc, const struct m0_fid *id)
Definition: pool.c:586
static struct m0_reqh_context sender_rctx
Definition: net.c:104
M0_INTERNAL void m0_cm_aggr_group_add(struct m0_cm *cm, struct m0_cm_aggr_group *ag, bool has_incoming)
Definition: ag.c:301
const struct m0_net_buffer_pool_ops bp_ops
Definition: net.c:730
struct m0_pool_version * pv
Definition: dir.c:629
M0_INTERNAL void m0_cm_type_deregister(struct m0_cm_type *cmtype)
Definition: cm.c:1019
uint64_t m0_time_t
Definition: time.h:37
static struct m0_ut_rpc_mach_ctx rmach_ctx
Definition: net.c:99
Definition: cp.h:160
M0_INTERNAL void m0_reqh_service_prepare_to_stop(struct m0_reqh_service *service)
Definition: reqh_service.c:375
static void buf_available(struct m0_net_buffer_pool *pool)
Definition: net.c:726
M0_INTERNAL int m0_file_read(const char *path, char **out)
Definition: fs.c:61
M0_INTERNAL struct m0_net_buffer * m0_net_buffer_pool_get(struct m0_net_buffer_pool *pool, uint32_t colour)
Definition: buffer_pool.c:215
M0_INTERNAL void m0_net_buffer_pool_unlock(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:203
static int dummy_cp_phase(struct m0_cm_cp *cp)
Definition: net.c:250
static struct m0_cm_aggr_group * ag_cpy
Definition: net.c:53
void(* cmo_stop)(struct m0_cm *cm)
Definition: cm.h:304
M0_INTERNAL int m0_ut_stob_destroy_by_stob_id(struct m0_stob_id *stob_id)
Definition: stob.c:317
static struct m0_cm sender_cm
Definition: net.c:100
const struct m0_net_buffer_pool_ops * nbp_ops
Definition: buffer_pool.h:263
static const struct m0_cm_aggr_group_ops group_ops
Definition: net.c:190
uint32_t rag_acc_inuse_nr
Definition: ag.h:86
M0_INTERNAL void m0_ios_cdom_get(struct m0_reqh *reqh, struct m0_cob_domain **out)
Definition: io_service.c:463
uint32_t cc_pool_width
Definition: setup.h:409
int m0_rpc_session_destroy(struct m0_rpc_session *session, m0_time_t abs_timeout)
Definition: session.c:559
M0_INTERNAL int m0_confc_init(struct m0_confc *confc, struct m0_sm_group *sm_group, const char *confd_addr, struct m0_rpc_machine *rpc_mach, const char *local_conf)
Definition: confc.c:560
static struct m0_cm * recv_cm
Definition: net.c:50
struct m0_bufvec data
Definition: di.c:40
static uint64_t dummy_fom_locality(const struct m0_fom *fom)
Definition: net.c:204
struct m0_cob_domain_id rmc_cob_id
static const char server_addr[]
Definition: net.c:87
struct m0_layout * sf_layout
Definition: file.h:74
M0_INTERNAL void m0_confc_fini(struct m0_confc *confc)
Definition: confc.c:570
static struct m0_net_buffer_pool r_nbp
Definition: net.c:64
Definition: net.c:72
static struct m0_fom_ops read_cp_fom_ops
Definition: net.c:327
uint64_t m0_bcount_t
Definition: types.h:77
static void test_init(bool ag_create)
Definition: net.c:887
static void sender_cm_fini(struct m0_cm *cm)
Definition: net.c:618
uint64_t c_ag_cp_idx
Definition: cp.h:175
struct m0_sns_cm_buf_pool sc_ibp
Definition: cm.h:227
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
static bool sender_cm_cp_invariant(const struct m0_cm_cp *cp)
Definition: net.c:275
M0_INTERNAL void m0_cm_fini(struct m0_cm *cm)
Definition: cm.c:964
static void sender_cm_ha_msg(struct m0_cm *cm, struct m0_ha_msg *msg, int rc)
Definition: net.c:634
struct m0_poolmach * sf_pm
Definition: file.h:70
Definition: ut.h:77
M0_INTERNAL int m0_sns_cm_buf_attach(struct m0_net_buffer_pool *bp, struct m0_cm_cp *cp)
Definition: cm.c:810
struct m0_motr * rc_motr
Definition: setup.h:318
uint32_t * p_count
Definition: proxy.h:154
M0_INTERNAL void m0_cm_state_set(struct m0_cm *cm, enum m0_cm_state state)
Definition: cm.c:570
static int dummy_read_fom_tick(struct m0_fom *fom)
Definition: net.c:310
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_INTERNAL void m0_cm_aggr_group_init(struct m0_cm_aggr_group *ag, struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming, const struct m0_cm_aggr_group_ops *ag_ops)
Definition: ag.c:153
m0_fom_phase
Definition: fom.h:372
struct m0_pdclust_layout * pdlay
Definition: xform.c:51
struct m0_rpc_session * px_session
Definition: proxy.h:116
static struct m0_cm_cp * sender_cm_cp_alloc(struct m0_cm *cm)
Definition: net.c:593
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
static void test_cp_send_mismatch_epoch()
Definition: net.c:920
M0_TL_DECLARE(rpcbulk, M0_INTERNAL, struct m0_rpc_bulk_buf)
uint64_t cag_cp_global_nr
Definition: ag.h:86
M0_INTERNAL int m0_sns_cm_cp_write_pre(struct m0_cm_cp *cp)
Definition: storage.c:330
M0_INTERNAL void m0_cm_cp_fom_fini(struct m0_fom *fom)
Definition: cp.c:412
#define m0_tl_endfor
Definition: tlist.h:700
static int sender_cm_data_next(struct m0_cm *cm, struct m0_cm_cp *cp)
Definition: net.c:613
M0_INTERNAL int m0_cm_init(struct m0_cm *cm, struct m0_cm_type *cm_type, const struct m0_cm_ops *cm_ops)
Definition: cm.c:925
static struct m0_cm * cm
Definition: cm.c:63
M0_INTERNAL void m0_cm_unlock(struct m0_cm *cm)
Definition: cm.c:550
M0_INTERNAL const char * m0_rpc_conn_addr(const struct m0_rpc_conn *conn)
Definition: conn.c:1306
static struct m0_semaphore cp_sem
Definition: net.c:82
Definition: cp.h:151
enum m0_cm_op sc_op
Definition: cm.h:209
struct m0_fid sc_cobfid
Definition: cp.h:42
M0_INTERNAL void m0_cm_ag_cp_add(struct m0_cm_aggr_group *ag, struct m0_cm_cp *cp)
Definition: ag.c:510
static struct m0_cm_proxy * sender_cm_proxy
Definition: net.c:110
#define DUMMY_SERVER_ADDR
Definition: net.c:46
static void sender_ag_create()
Definition: net.c:708
static struct m0_sns_cm_ag * sag
Definition: cm.c:66
int i
Definition: dir.c:1033
static struct m0_cm_ag_id ag_id
Definition: net.c:121
struct m0_cm_cp sc_base
Definition: cp.h:39
static int sender_cm_start(struct m0_cm *cm)
Definition: net.c:604
enum m0_cm_cp_io_op c_io_op
Definition: cp.h:196
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
static struct m0_rpc_conn conn
Definition: net.c:112
M0_INTERNAL int m0_rpc_client_connect(struct m0_rpc_conn *conn, struct m0_rpc_session *session, struct m0_rpc_machine *rpc_mach, const char *remote_addr, struct m0_fid *svc_fid, uint64_t max_rpcs_in_flight, m0_time_t abs_timeout)
Definition: rpclib.c:102
struct m0_sns_cm_ag rag_base
Definition: ag.h:77
M0_INTERNAL int m0_sns_cm_cp_recv_init(struct m0_cm_cp *cp)
Definition: net.c:432
Definition: cnt.h:36
static struct m0_net_buffer r_buf
Definition: net.c:63
struct m0_cm_proxy_in_count sag_proxy_in_count
Definition: ag.h:57
M0_INTERNAL struct m0_confc * m0_reqh2confc(struct m0_reqh *reqh)
Definition: reqh.c:753
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90
static int dummy_read_cp_xform(struct m0_cm_cp *cp)
Definition: net.c:376
static const struct socktype stype[]
Definition: sock.c:1156
static struct m0_rpc_session session
Definition: net.c:113
static void read_and_verify()
Definition: net.c:447
M0_INTERNAL void m0_fi_disable(const char *fp_func, const char *fp_tag)
Definition: finject.c:485
const struct m0_cm_cp_ops cp_dummy_ops
Definition: net.c:285
int(* cmo_prepare)(struct m0_cm *cm)
Definition: cm.h:294
static struct m0_net_domain client_net_dom
Definition: net.c:80
static void m0_fi_enable(const char *func, const char *tag)
Definition: finject.h:276
static void receiver_ag_create(struct m0_cm *cm)
Definition: net.c:480
#define m0_free0(pptr)
Definition: memory.h:77
#define M0_ASSERT(cond)
static struct m0_sns_cm_cp r_sns_cp
Definition: net.c:62
static struct m0_confc * confc
Definition: file.c:94
M0_INTERNAL bool m0_net_buffer_pool_prune(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:310
struct m0_rpc_conn * px_conn
Definition: proxy.h:114
m0_time_t m0_time_now(void)
Definition: time.c:134
struct m0_fid pver
Definition: idx_dix.c:74
struct m0_ut_suite snscm_net_ut
Definition: net.c:1095
struct m0_fid fc_tgt_cobfid
Definition: ag.h:60
uint32_t c_data_seg_nr
Definition: cp.h:190
M0_INTERNAL int m0_sns_cm_cp_io_wait(struct m0_cm_cp *cp)
Definition: storage.c:341
M0_INTERNAL void m0_reqh_service_fini(struct m0_reqh_service *service)
Definition: reqh_service.c:457
M0_INTERNAL int m0_sns_cm_cp_phase_next(struct m0_cm_cp *cp)
Definition: cp.c:261
M0_INTERNAL void m0_fid_convert_cob2stob(const struct m0_fid *cob_fid, struct m0_stob_id *stob_id)
Definition: fid_convert.c:141
struct m0_cm * cag_cm
Definition: ag.h:70
m0_bindex_t sc_index
Definition: cp.h:60
static void cp_ag_fini(struct m0_cm_aggr_group *ag)
Definition: net.c:163
static void cm_cp_free(struct m0_cm_cp *cp)
Definition: net.c:265
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
void(* nbpo_not_empty)(struct m0_net_buffer_pool *)
Definition: buffer_pool.h:150
M0_INTERNAL void m0_cm_cp_buf_add(struct m0_cm_cp *cp, struct m0_net_buffer *nb)
Definition: cp.c:703
int m0_rpc_conn_destroy(struct m0_rpc_conn *conn, m0_time_t abs_timeout)
Definition: conn.c:974
static struct m0_fid cob_fid
Definition: net.c:116
M0_INTERNAL void m0_net_buffer_pool_lock(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:186
static void sender_cm_stop(struct m0_cm *cm)
Definition: net.c:609
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:217
static int dummy_read_cp_phase(struct m0_cm_cp *cp)
Definition: net.c:346
M0_INTERNAL struct m0_cm_aggr_group * m0_cm_aggr_group_locate(struct m0_cm *cm, const struct m0_cm_ag_id *id, bool has_incoming)
Definition: ag.c:262
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
M0_INTERNAL bool m0_sns_cm_cp_invariant(const struct m0_cm_cp *cp)
Definition: cp.c:62
uint64_t u_hi
Definition: types.h:36
int(* co_action[])(struct m0_cm_cp *cp)
Definition: cp.h:259
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
void * m0_alloc(size_t size)
Definition: memory.c:126
static struct m0_rpc_server_ctx sctx
Definition: console.c:88
static const char client_addr[]
Definition: net.c:86
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL uint64_t m0_reqh_nr_localities(const struct m0_reqh *reqh)
Definition: reqh.c:723
Definition: msg.h:115
struct m0_sns_cm_cp fc_tgt_acc_cp
Definition: ag.h:45
M0_INTERNAL void m0_cm_proxy_del(struct m0_cm *cm, struct m0_cm_proxy *pxy)
Definition: proxy.c:124
M0_INTERNAL int m0_reqh_service_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
Definition: reqh_service.c:185
Definition: reqh.h:94
M0_INTERNAL void m0_bitmap_set(struct m0_bitmap *map, size_t idx, bool val)
Definition: bitmap.c:139
bool px_is_done
Definition: proxy.h:93
void sender_service_alloc_init()
Definition: net.c:694
Definition: dump.c:103
struct m0_cm_aggr_group * c_ag
Definition: cp.h:172
static struct m0_reqh_service * sender_cm_service
Definition: net.c:101
struct m0_reqh rmc_reqh
Definition: cm.h:286
M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:428
static void dummy_fom_fini(struct m0_fom *fom)
Definition: net.c:197
uint64_t px_id
Definition: proxy.h:63
static void sender_cm_service_fini(struct m0_reqh_service *service)
Definition: net.c:662
struct m0_net_domain * rcx_net_dom
Definition: rpclib.h:128
bool swu_is_complete
Definition: sw.h:85
struct m0_chan cm_complete
Definition: cm.h:238
M0_INTERNAL int m0_cm_setup(struct m0_cm *cm)
Definition: cm.c:595
static int sender_cm_service_allocate(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: net.c:674
m0_time_t c_epoch
Definition: cp.h:166
M0_INTERNAL void m0_chan_signal_lock(struct m0_chan *chan)
Definition: chan.c:165
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
static struct m0_pool pool
Definition: iter_ut.c:58
M0_INTERNAL struct m0_layout * m0_pdl_to_layout(struct m0_pdclust_layout *pl)
Definition: pdclust.c:393
uint64_t rcx_max_rpcs_in_flight
Definition: rpclib.h:136
Definition: fom.h:481
Definition: cm.h:143
static struct m0_semaphore sem
Definition: net.c:81
static void bp_below_threshold(struct m0_net_buffer_pool *bp)
Definition: net.c:722
const char * ts_name
Definition: ut.h:99
static struct m0_sns_cm_repair_ag r_rag
Definition: net.c:61
struct m0_sns_cm_file_ctx * sag_fctx
Definition: ag.h:48
static const struct m0_cm_cp_ops sender_cm_cp_ops
Definition: net.c:280
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
uint64_t cm_proxy_nr
Definition: cm.h:250
static int dummy_cp_init(struct m0_cm_cp *cp)
Definition: net.c:242
struct m0_sns_cm_repair_ag_failure_ctx * rag_fc
Definition: ag.h:93
Definition: setup.h:354
struct m0_reqh reqh
Definition: rm_foms.c:48
struct m0_cm_proxy * c_cm_proxy
Definition: cp.h:208
static struct m0_cm_proxy * recv_cm_proxy
Definition: net.c:111
M0_INTERNAL int m0_sns_cm_cp_read(struct m0_cm_cp *cp)
Definition: storage.c:324
static struct m0_fom_ops cp_fom_ops
Definition: net.c:235
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
struct m0_net_buffer_pool sb_bp
Definition: cm.h:135
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
struct m0_cm_sw_update cm_sw_update
Definition: cm.h:259
M0_INTERNAL int m0_sns_cm_repair_cp_send(struct m0_cm_cp *cp)
Definition: net.c:37
#define M0_CNT_INC(cnt)
Definition: arith.h:226
uint64_t cag_freed_cp_nr
Definition: ag.h:98
M0_INTERNAL void m0_cm_aggr_group_fini(struct m0_cm_aggr_group *ag)
Definition: ag.c:180
static void receiver_init(void)
Definition: net.c:547
Definition: fid.h:38
static struct m0_cm_cp sender_cm_cp
Definition: net.c:102
uint32_t sag_local_tgts_nr
Definition: ag.h:78
static void cm_ready(struct m0_cm *cm)
Definition: net.c:540
static struct m0_semaphore write_cp_sem
Definition: net.c:84
M0_CM_TYPE_DECLARE(sender_cm, M0_CM_UT_SENDER_OPCODE, &sender_cm_service_type_ops, "sender_cm", 0)
static void sender_fini()
Definition: net.c:845
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
static struct m0_reqh * s0_reqh
Definition: net.c:49
struct m0_motr motr
static struct m0_semaphore read_cp_sem
Definition: net.c:83
const char * rmc_ep_addr
int cs_init(struct m0_motr *sctx)
Definition: cp_common.c:206
M0_INTERNAL void m0_cm_proxy_fini(struct m0_cm_proxy *pxy)
Definition: proxy.c:627
struct m0_reqh_service cm_service
Definition: cm.h:191
M0_INTERNAL int m0_cm_proxy_init(struct m0_cm_proxy *proxy, uint64_t px_id, struct m0_cm_ag_id *lo, struct m0_cm_ag_id *hi, const char *endpoint)
Definition: proxy.c:90
static void fail_device(struct m0_cm *cm)
Definition: net.c:144
M0_INTERNAL int m0_cm_proxy_in_count_alloc(struct m0_cm_proxy_in_count *pcount, uint32_t nr_proxies)
Definition: proxy.c:758
M0_INTERNAL void m0_ut_rpc_mach_fini(struct m0_ut_rpc_mach_ctx *ctx)
Definition: cm.h:166
const char * rcx_remote_addr
Definition: rpclib.h:134
static void receiver_stob_create()
Definition: net.c:522
static struct m0_sns_cm_repair_ag s_rag
Definition: net.c:107
struct m0_cm_type sender_cm_cmt
void bv_populate(struct m0_bufvec *b, char data, uint32_t seg_nr, uint32_t seg_size)
Definition: cp_common.c:71
M0_INTERNAL int m0_net_buffer_pool_provision(struct m0_net_buffer_pool *pool, uint32_t buf_nr)
Definition: buffer_pool.c:125
static void ag_setup(struct m0_sns_cm_ag *sag, struct m0_cm *cm)
Definition: net.c:429
int(* cmo_setup)(struct m0_cm *cm)
Definition: cm.h:292
static uint64_t cp_single_get(const struct m0_cm_aggr_group *ag)
Definition: net.c:158
M0_INTERNAL int m0_sns_cm_cp_fail(struct m0_cm_cp *cp)
Definition: cp.c:216
static void test_fini()
Definition: net.c:879
uint64_t cag_cp_local_nr
Definition: ag.h:92
int(* co_phase_next)(struct m0_cm_cp *cp)
Definition: cp.h:232
void bv_free(struct m0_bufvec *b)
Definition: cp_common.c:115
M0_INTERNAL int32_t m0_net_domain_get_max_buffer_segments(struct m0_net_domain *dom)
struct m0_be_seg * rh_beseg
Definition: reqh.h:112
struct m0_uint128 ai_hi
Definition: ag.h:50
Definition: net.c:73
struct m0_reqh_service_type ct_stype
Definition: cm.h:145
M0_INTERNAL void m0_fom_queue(struct m0_fom *fom)
Definition: fom.c:624
struct m0_tl c_buffers
Definition: cp.h:184
M0_INTERNAL void m0_cm_cp_init(struct m0_cm_type *cmtype, const struct m0_fom_type_ops *ft_ops)
Definition: cp.c:580
struct m0_mutex cag_mutex
Definition: ag.h:76
void(* fo_fini)(struct m0_fom *fom)
Definition: fom.h:657
static void dummy_read_fom_fini(struct m0_fom *fom)
Definition: net.c:317
static int dummy_cp_write_io_wait(struct m0_cm_cp *cp)
Definition: net.c:387
struct m0_rpc_machine rcx_rpc_machine
Definition: rpclib.h:145
static void test_cp_send_recv_verify()
Definition: net.c:1003
static struct m0_sns_cm_file_ctx fctx
Definition: net.c:55
static struct m0_sns_cm_repair_ag rag
Definition: net.c:54
bool cag_has_incoming
Definition: ag.h:101
static struct bulkio_params * bp
Definition: bulkio_ut.c:44
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
static void buffers_verify()
Definition: net.c:354
#define M0_UT_PATH(name)
Definition: misc.h:41
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
int(* cmo_start)(struct m0_cm *cm)
Definition: cm.h:301
struct m0_cm_aggr_group sag_base
Definition: ag.h:46
Definition: net.c:75
void m0_fom_phase_set(struct m0_fom *fom, int phase)
Definition: fom.c:1688
static const struct m0_cm_ops sender_cm_ops
Definition: net.c:639
struct m0_fid gfid
Definition: dir.c:626
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
struct m0_pools_common cc_pools_common
Definition: setup.h:356
struct m0_fom c_fom
Definition: cp.h:161
static void sender_cm_service_stop(struct m0_reqh_service *service)
Definition: net.c:656
Definition: net.c:74
bool sc_is_acc
Definition: cp.h:57
void layout_gen(struct m0_pdclust_layout **pdlay, struct m0_reqh *reqh)
Definition: cp_common.c:227
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 const struct m0_reqh_service_type_ops sender_cm_service_type_ops
Definition: net.c:687
#define DUMMY_COB_ID
Definition: net.c:45
static int sender_cm_service_start(struct m0_reqh_service *service)
Definition: net.c:651
static struct m0_reqh_service * scm_service
Definition: net.c:52
struct m0_reqh * rs_reqh
Definition: reqh_service.h:259
Definition: net.c:77
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
m0_time_t px_epoch
Definition: proxy.h:65
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL struct m0_sns_cm_repair_ag * sag2repairag(const struct m0_sns_cm_ag *sag)
Definition: ag.c:61
M0_INTERNAL int m0_net_buffer_pool_init(struct m0_net_buffer_pool *pool, struct m0_net_domain *ndom, uint32_t threshold, uint32_t seg_nr, m0_bcount_t seg_size, uint32_t colours, unsigned shift, bool dont_dump)
Definition: buffer_pool.c:82
static int dummy_read_cp_init(struct m0_cm_cp *cp)
Definition: net.c:338
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
M0_INTERNAL struct m0_motr * m0_cs_ctx_get(struct m0_reqh *reqh)
Definition: setup.c:1778
M0_INTERNAL void m0_cm_proxy_add(struct m0_cm *cm, struct m0_cm_proxy *pxy)
Definition: proxy.c:110
M0_INTERNAL struct m0_sns_cm_ag * ag2snsag(const struct m0_cm_aggr_group *ag)
Definition: ag.c:391
int32_t rc
Definition: trigger_fop.h:47
static struct m0_sns_cm * recv_scm
Definition: net.c:51
struct m0_fid g_process_fid
Definition: ut.c:689
static struct m0_net_buffer_pool nbp
Definition: net.c:109
#define M0_UT_ASSERT(a)
Definition: ut.h:46
static int sender_cm_ag_next(struct m0_cm *cm, const struct m0_cm_ag_id *id_curr, struct m0_cm_ag_id *id_next)
Definition: net.c:627
void pool_mach_transit(struct m0_reqh *reqh, struct m0_poolmach *pm, uint64_t fd, enum m0_pool_nd_state state)
Definition: cp_common.c:262
m0_time_t cm_epoch
Definition: cm.h:177
Definition: ag.h:49
static void dummy_cp_complete(struct m0_cm_cp *cp)
Definition: net.c:256
static int dummy_fom_tick(struct m0_fom *fom)
Definition: net.c:210
const struct m0_cm_cp_ops read_cp_ops
Definition: net.c:406
const struct m0_reqh_service_ops * rs_ops
Definition: reqh_service.h:254
#define M0_IMPOSSIBLE(fmt,...)
M0_INTERNAL int m0_cm_type_register(struct m0_cm_type *cmtype)
Definition: cm.c:995
static uint nr_bufs