Motr  M0
note.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 "ha/note.h"
24 #include "conf/pvers.h" /* m0_conf_pver_kind */
25 #include "conf/obj_ops.h" /* m0_conf_obj_find_lock */
26 #include "conf/helpers.h" /* m0_conf_full_load */
27 #include "rpc/rpclib.h" /* m0_rpc_client_ctx */
28 
29 #include "ha/note.c"
30 
31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_HA
32 #include "lib/trace.h"
33 
34 #include "lib/fs.h" /* m0_file_read */
35 #include "lib/finject.h" /* m0_fi_enable/disable */
36 #include "ut/misc.h" /* M0_UT_PATH */
37 #include "ut/ut.h"
38 
39 #define CLIENT_DB_NAME "ha_ut_client.db"
40 #define CLIENT_ENDPOINT_ADDR "0@lo:12345:34:*"
41 
42 #define SERVER_DB_NAME "ha_ut_confd_server.db"
43 #define SERVER_STOB_NAME "ha_ut_confd_server.stob"
44 #define SERVER_ADDB_STOB_NAME "linuxstob:ha_ut_confd_server.addb_stob"
45 #define SERVER_LOG_NAME "ha_ut_confd_server.log"
46 #define SERVER_ENDPOINT_ADDR "0@lo:12345:34:1"
47 #define SERVER_ENDPOINT M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR
48 
51 
52 enum {
60  NR_NODES = 10,
61  NR_DISKS = 200,
63  NR_SPARE = 20
64 };
65 
66 static struct m0_rpc_client_ctx cctx = {
68  .rcx_local_addr = CLIENT_ENDPOINT_ADDR,
69  .rcx_remote_addr = SERVER_ENDPOINT_ADDR,
70  .rcx_max_rpcs_in_flight = MAX_RPCS_IN_FLIGHT,
71  .rcx_fid = &g_process_fid,
72 };
73 
74 static char *server_argv[] = {
75  "ha_ut", "-T", "AD", "-D", SERVER_DB_NAME,
77  "-w", "10", "-e", SERVER_ENDPOINT, "-H", SERVER_ENDPOINT_ADDR,
78  "-f", M0_UT_CONF_PROCESS,
79  "-c", M0_UT_PATH("conf.xc")
80 };
81 
82 static struct m0_rpc_server_ctx sctx = {
83  .rsx_xprts_nr = 1,
84  .rsx_argv = server_argv,
85  .rsx_argc = ARRAY_SIZE(server_argv),
86  .rsx_log_file_name = SERVER_LOG_NAME,
87 };
88 
89 static struct m0_reqh_init_args reqh_args = {
90  .rhia_fid = &M0_FID_TINIT('r', 1, 1),
91  .rhia_mdstore = (void *)1
92 };
93 
95 
96 static struct m0_mutex chan_lock;
97 static struct m0_chan chan;
98 static struct m0_clink clink;
99 
100 static struct m0_sm_group g_grp;
101 
102 static struct {
103  bool run;
105 } g_ast;
106 
107 /* ----------------------------------------------------------------
108  * Auxiliary functions
109  * ---------------------------------------------------------------- */
110 
112 {
113  int rc;
114 
116  M0_ASSERT(rc == 0);
121  M0_ASSERT(rc == 0);
123  M0_ASSERT(rc == 0);
124 }
125 
126 static void stop_rpc_client_and_server(void)
127 {
128  int rc;
129 
131  M0_ASSERT(rc == 0);
136 }
137 
138 static void ast_thread(int _ M0_UNUSED)
139 {
140  while (g_ast.run) {
145  }
146 }
147 
148 static int ast_thread_init(void)
149 {
151  g_ast.run = true;
152  return M0_THREAD_INIT(&g_ast.thread, int, NULL, &ast_thread, 0,
153  "ast_thread");
154 }
155 
156 static void ast_thread_fini(void)
157 {
158  g_ast.run = false;
160  m0_thread_join(&g_ast.thread);
161  m0_thread_fini(&g_ast.thread);
163 }
164 
165 static void done_get_chan_init(void)
166 {
171 }
172 
173 static void done_get_chan_fini(void)
174 {
179 }
180 
181 static void local_confc_init(struct m0_confc *confc)
182 {
183  char *confstr;
184  int rc;
185 
186  rc = m0_file_read(M0_UT_PATH("conf.xc"), &confstr);
187  M0_UT_ASSERT(rc == 0);
188  /*
189  * All configuration objects need to be preloaded, since
190  * m0_ha_state_accept() function traverses all the descendants appearing
191  * in preloaded data. When missing configuration object is found,
192  * unit test for m0_ha_state_accept() will likely to show an error
193  * similar to below:
194  *
195  * FATAL : [lib/assert.c:43:m0_panic] panic:
196  * obj->co_status == M0_CS_READY m0_conf_obj_put()
197  */
199  &cctx.rcx_rpc_machine, confstr);
200  M0_UT_ASSERT(rc == 0);
201  m0_free(confstr);
202 }
203 
204 static void compare_ha_state(struct m0_confc *confc,
205  enum m0_ha_obj_state state)
206 {
207  struct m0_conf_obj *node_dir;
208  struct m0_conf_obj *node;
209  struct m0_conf_obj *svc_dir;
210  struct m0_conf_obj *svc;
211  int rc;
212 
213  rc = m0_confc_open_sync(&node_dir, confc->cc_root,
214  M0_CONF_ROOT_NODES_FID);
215  M0_UT_ASSERT(rc == 0);
216 
217  rc = m0_confc_open_sync(&node, node_dir, M0_FID_TINIT('n', 1, 2));
218  M0_UT_ASSERT(rc == 0);
219  M0_UT_ASSERT(node->co_ha_state == state);
220 
221  rc = m0_confc_open_sync(&svc_dir, node, M0_CONF_NODE_PROCESSES_FID,
222  M0_FID_TINIT('r', 1, 5),
223  M0_CONF_PROCESS_SERVICES_FID);
224  M0_UT_ASSERT(rc == 0);
225 
226  rc = m0_confc_open_sync(&svc, svc_dir, M0_FID_TINIT('s', 1, 9));
227  M0_UT_ASSERT(rc == 0);
228  M0_UT_ASSERT(svc->co_ha_state == state);
229 
231 
232  rc = m0_confc_open_sync(&svc, svc_dir, M0_FID_TINIT('s', 1, 10));
233  M0_UT_ASSERT(rc == 0);
234  M0_UT_ASSERT(svc->co_ha_state == state);
235 
237  m0_confc_close(svc_dir);
239  m0_confc_close(node_dir);
240 }
241 
242 
243 static void pool_machine_fid_populate(struct m0_poolmach *pool_mach);
244 static int pm_event_construct_and_apply(struct m0_poolmach *pm,
245  uint32_t dev_idx, uint32_t state);
246 
247 /* ----------------------------------------------------------------
248  * Unit tests
249  * ---------------------------------------------------------------- */
250 static void test_ha_state_set_and_get(void)
251 {
252  struct m0_confc confc;
253  int rc;
254  struct m0_ha_note n1[] = {
255  { M0_FID_TINIT('n', 1, 2), M0_NC_ONLINE },
256  { M0_FID_TINIT('s', 1, 9), M0_NC_ONLINE },
257  { M0_FID_TINIT('s', 1, 10), M0_NC_ONLINE},
258  };
259  struct m0_ha_nvec nvec = { ARRAY_SIZE(n1), n1 };
260 
263  m0_ha_state_set(&nvec);
264 
265  n1[0].no_state = M0_NC_UNKNOWN;
266  n1[1].no_state = M0_NC_UNKNOWN;
267  n1[2].no_state = M0_NC_UNKNOWN;
268  rc = m0_ha_state_get(&nvec, &chan);
269  M0_UT_ASSERT(rc == 0);
271  m0_ha_state_accept(&nvec, false);
274 
276 }
277 
278 static void test_ha_state_accept(void)
279 {
280  struct m0_confc confc;
281  struct m0_fid u[] = {
282  M0_FID_TINIT('n', 1, 2),
283  M0_FID_TINIT('s', 1, 9),
284  M0_FID_TINIT('s', 1, 10),
285  };
286  struct m0_ha_note *n;
287 
289  struct m0_ha_nvec nvec;
290  int i;
291 
294 
295  nvec.nv_nr = ARRAY_SIZE(u);
296  nvec.nv_note = n;
297 
298  /* To initialize */
299  for (i = 0; i < ARRAY_SIZE(u); ++i) {
300  n[i].no_id = u[i];
301  n[i].no_state = M0_NC_ONLINE;
302  }
303  m0_ha_state_accept(&nvec, false);
305 
306  /* To check updates */
307  for (i = 0; i < ARRAY_SIZE(u); ++i) {
308  n[i].no_state = M0_NC_FAILED;
309  }
310  m0_ha_state_accept(&nvec, false);
312 
315  m0_free(n);
316 }
317 
318 static void ha_ut_conf_init(struct m0_reqh *reqh)
319 {
320  int rc;
321  struct m0_confc *confc = m0_reqh2confc(reqh);
322 
324  M0_UT_ASSERT(rc == 0);
327 
329  M0_UT_ASSERT(rc == 0);
330 
332  M0_UT_ASSERT(rc == 0);
333  /*
334  * All conf objects are M0_NC_ONLINE now; see m0_conf_obj_create().
335  */
336 }
337 
338 static void ha_ut_conf_fini(struct m0_reqh *reqh)
339 {
343 }
344 
345 static void ha_ut_pver_kind_check(const struct m0_fid *pver_fid,
347 {
348  enum m0_conf_pver_kind actual;
349  int rc;
350 
351  rc = m0_conf_pver_fid_read(pver_fid, &actual, NULL, NULL);
352  M0_UT_ASSERT(rc == 0);
353  M0_UT_ASSERT(actual == expected);
354 }
355 
356 static bool test_is_objv(const struct m0_conf_obj *obj)
357 {
359 }
360 
362 static void check_pver_subtree(struct m0_confc *confc,
363  const struct m0_fid *pver_fid)
364 {
365  struct m0_conf_diter it;
366  struct m0_conf_obj *pver_obj;
367  struct m0_conf_objv *objv;
368  int rc;
369 
370  rc = m0_conf_obj_find_lock(&confc->cc_cache, pver_fid, &pver_obj);
371  M0_UT_ASSERT(rc == 0);
372  rc = m0_conf_diter_init(&it, confc, pver_obj,
373  M0_CONF_PVER_SITEVS_FID,
374  M0_CONF_SITEV_RACKVS_FID,
375  M0_CONF_RACKV_ENCLVS_FID,
376  M0_CONF_ENCLV_CTRLVS_FID,
377  M0_CONF_CTRLV_DRIVEVS_FID);
378  M0_UT_ASSERT(rc == 0);
379  while ((rc = m0_conf_diter_next_sync(&it, test_is_objv)) ==
380  M0_CONF_DIRNEXT) {
382  objv = M0_CONF_CAST(obj, m0_conf_objv);
383  M0_LOG(M0_DEBUG, "fid="FID_F" idx=%d state=%d",
384  FID_P(&obj->co_id), objv->cv_ix,
385  objv->cv_real->co_ha_state);
386  }
388 }
389 
390 static void test_failvec_fetch(void)
391 {
392  struct m0_pool pool;
393  struct m0_fid pool_fid;
394  struct m0_poolmach pool_mach;
395  struct m0_pool_version pool_ver;
396  uint32_t i;
397  uint64_t qlen;
398  uint64_t failed_nr;
399  int rc;
400 
401  M0_SET0(&pool);
402  M0_SET0(&pool_ver);
403  M0_SET0(&pool_mach);
404 
405  m0_fid_set(&pool_fid, 0, 999);
406  rc = m0_pool_init(&pool, &pool_fid, 0);
407  M0_UT_ASSERT(rc == 0);
408  pool_ver.pv_pool = &pool;
409  rc = m0_poolmach_init(&pool_mach, &pool_ver, NR_NODES, NR_DISKS,
411  pool_machine_fid_populate(&pool_mach);
412  /* Enqueue events received till fetching the failvec. */
413  for (i = 0; i < NR_OVERLAP; ++i) {
414  rc = pm_event_construct_and_apply(&pool_mach, i,
416  M0_UT_ASSERT(rc == 0);
417  }
418  qlen = m0_poolmach_equeue_length(&pool_mach);
419  M0_UT_ASSERT(qlen == NR_OVERLAP);
420  for (i = NR_NO_OVERLAP; i < MAX_FAILURES; ++i) {
421  rc = pm_event_construct_and_apply(&pool_mach, i,
423  M0_UT_ASSERT(rc == 0);
424  }
425  qlen = m0_poolmach_equeue_length(&pool_mach);
427  m0_fi_enable("m0_ha_msg_fvec_send", "non-trivial-fvec");
428  rc = m0_ha_failvec_fetch(&pool_fid, &pool_mach, &chan);
429  M0_UT_ASSERT(rc == 0);
431  m0_fi_disable("m0_ha_msg_fvec_send", "non-trivial-fvec");
432  failed_nr = m0_poolmach_nr_dev_failures(&pool_mach);
433  M0_UT_ASSERT(failed_nr == MAX_FAILURES);
434  M0_UT_ASSERT(m0_poolmach_equeue_length(&pool_mach) == 0);
435  m0_fi_enable_once("m0_poolmach_fini", "poolmach_init_by_conf_skipped");
436  m0_poolmach_fini(&pool_mach);
437  m0_pool_fini(&pool);
438 }
439 
440 static void pool_machine_fid_populate(struct m0_poolmach *pool_mach)
441 {
442  uint32_t i;
443 
444  for (i = 0; i < pool_mach->pm_state->pst_nr_devices; ++i)
445  pool_mach->pm_state->pst_devices_array[i].pd_id =
446  M0_FID_TINIT('d', 1, i);
447 }
448 
450  uint32_t dev_idx, uint32_t state)
451 {
452  const struct m0_poolmach_event event = {
453  .pe_type = M0_POOL_DEVICE,
454  .pe_index = dev_idx,
455  .pe_state = state
456  };
457  return m0_poolmach_state_transit(pm, &event);
458 }
459 
460 /* XXX Move to ha/note.h? */
461 static void ha_state_accept_1(const struct m0_fid *fid, uint32_t state)
462 {
463  struct m0_ha_note note = { .no_id = *fid, .no_state = state };
464 
465  m0_ha_state_accept(&(const struct m0_ha_nvec){ 1, &note }, false);
466 }
467 
468 static uint32_t recd_disks(const struct m0_conf_pver *pver)
469 {
470  M0_PRE(M0_IN(pver->pv_kind, (M0_CONF_PVER_ACTUAL,
472  return pver->pv_u.subtree.pvs_recd[M0_CONF_PVER_LVL_DRIVES];
473 }
474 
475 static void test_poolversion_get(void)
476 {
477  static const struct m0_fid disk_76 = M0_FID_TINIT('k', 1, 76);
478  static const struct m0_fid disk_77 = M0_FID_TINIT('k', 1, 77);
479  static const struct m0_fid disk_78 = M0_FID_TINIT('k', 1, 78);
480  static const struct m0_fid pool4_fid = M0_FID_TINIT('o', 1, 4);
481  static const struct m0_fid pool56_fid = M0_FID_TINIT('o', 1, 56);
482  struct m0_ha_note notes[] = {
483  { M0_FID_TINIT('a', 1, 3), M0_NC_ONLINE }, // rack-3
484  { M0_FID_TINIT('e', 1, 7), M0_NC_ONLINE }, // enclosure-7
485  { M0_FID_TINIT('c', 1, 11), M0_NC_ONLINE }, // controller-11
486  { disk_76, M0_NC_ONLINE },
487  { disk_77, M0_NC_ONLINE },
488  { disk_78, M0_NC_ONLINE }
489  };
490  const struct m0_ha_nvec nvec = { ARRAY_SIZE(notes), notes };
491  struct m0_conf_pver *pver0 = NULL;
492  struct m0_conf_pver *pver1 = NULL;
493  struct m0_conf_pver *pver2 = NULL;
494  struct m0_conf_pver *pver3 = NULL;
495  struct m0_conf_pver *pver4 = NULL;
496  struct m0_reqh reqh;
497  struct m0_confc *confc = m0_reqh2confc(&reqh);
498  int rc;
499  /*
500  * Use these bash commands to visualize the tree of conf objects:
501  *
502  * # helper function
503  * cg() { utils/m0confgen "$@"; }
504  *
505  * cg -t confgen ut/conf.cg | # reformat to one line per object
506  * # exclude unwanted objects
507  * grep -vE '^.(node|process|service|sdev)' |
508  * # generate DOT output
509  * cg -t dot >/tmp/conf.dot
510  * # convert to PNG
511  * dot -Tpng -o /tmp/conf.png /tmp/conf.dot
512  *
513  * open /tmp/conf.png
514  */
517 
518  rc = m0_conf_pver_get(confc, &pool4_fid, &pver0);
519  M0_UT_ASSERT(rc == 0);
520  M0_UT_ASSERT(pver0 != NULL);
522  M0_UT_ASSERT(m0_fid_eq(&pver0->pv_obj.co_id, &M0_FID_TINIT('v', 1, 8)));
524  M0_UT_ASSERT(recd_disks(pver0) == 0);
525 
527  rc = m0_conf_pver_get(confc, &pool4_fid, &pver1);
528  M0_UT_ASSERT(rc == 0);
529  M0_UT_ASSERT(pver1 != NULL);
530  M0_UT_ASSERT(pver1 != pver0);
533  M0_UT_ASSERT(recd_disks(pver0) == 1);
534 
535  ha_state_accept_1(&disk_78, M0_NC_FAILED);
536  rc = m0_conf_pver_get(confc, &pool4_fid, &pver2);
537  M0_UT_ASSERT(rc == 0);
538  M0_UT_ASSERT(pver2 != NULL);
539  M0_UT_ASSERT(pver2 != pver1 && pver2 != pver0);
542  M0_UT_ASSERT(recd_disks(pver0) == 2);
543 
545  rc = m0_conf_pver_get(confc, &pool4_fid, &pver3);
546  M0_UT_ASSERT(rc == -ENOENT);
547  M0_UT_ASSERT(pver3 == NULL);
548 
549 
550  rc = m0_conf_pver_get(confc, &pool56_fid, &pver3);
551  M0_UT_ASSERT(rc == 0);
552  M0_UT_ASSERT(pver3 != NULL);
553  M0_UT_ASSERT(pver3 != pver2 && pver3 != pver1 && pver3 != pver0);
554  /*
555  * Three disks has failed. This exceeds allowances of formulaic
556  * pvers of pool-4 ==> Motr switches to another pool.
557  */
560  &M0_FID_TINIT('v', 1, 57)));
562  M0_UT_ASSERT(recd_disks(pver0) == 3);
563  M0_UT_ASSERT(recd_disks(pver3) == 0);
564 
565  /* Put all disks back online. */
566  m0_ha_state_accept(&nvec, false);
567  rc = m0_conf_pver_get(confc, &pool4_fid, &pver4);
568  M0_UT_ASSERT(rc == 0);
569  M0_UT_ASSERT(pver4 == pver0);
570  M0_UT_ASSERT(recd_disks(pver0) == 0);
571 
572  m0_confc_close(&pver0->pv_obj);
573  m0_confc_close(&pver1->pv_obj);
574  m0_confc_close(&pver2->pv_obj);
575  m0_confc_close(&pver3->pv_obj);
576  m0_confc_close(&pver4->pv_obj);
578  m0_reqh_fini(&reqh);
579 }
580 
581 /*
582  * The test reproduces a MOTR-1997 regression. See
583  * https://jts.seagate.com/browse/MOTR-1997
584  */
585 static void test_ha_session_states(void)
586 {
588  struct m0_rconfc *cl_rconfc = &cctx.rcx_reqh.rh_rconfc;
589  struct m0_fid fid = M0_FID_TINIT('s', 1, 9);
590  struct m0_ha_note note = { .no_id = fid, .no_state = M0_NC_FAILED};
591  struct m0_ha_nvec nvec = { .nv_nr = 1, .nv_note = &note};
592  int rc;
593 
594  rc = m0_rconfc_init(cl_rconfc, m0_reqh2profile(reqh),
596  NULL, NULL);
597  M0_UT_ASSERT(rc == 0);
598  rc = m0_file_read(M0_UT_PATH("conf.xc"), &cl_rconfc->rc_local_conf);
599  M0_UT_ASSERT(rc == 0);
600  m0_rconfc_start(cl_rconfc);
601  m0_ha_client_add(&cl_rconfc->rc_confc);
603  M0_UT_ASSERT(rc == 0);
604 
605  m0_ha_state_accept(&nvec, false);
606 
608  m0_ha_client_del(&cl_rconfc->rc_confc);
609  m0_rconfc_stop_sync(cl_rconfc);
610  m0_rconfc_fini(cl_rconfc);
611 }
612 
613 /* -------------------------------------------------------------------
614  * Test suite
615  * ------------------------------------------------------------------- */
616 
617 static int ha_state_ut_init(void)
618 {
619  int rc;
620 
621  rc = ast_thread_init();
622  M0_ASSERT(rc == 0);
623 
626  return 0;
627 }
628 
629 static int ha_state_ut_fini(void)
630 {
633  ast_thread_fini();
634  return 0;
635 }
636 
638  .ts_name = "ha-state-ut",
639  .ts_init = ha_state_ut_init,
640  .ts_fini = ha_state_ut_fini,
641  .ts_tests = {
642  { "ha-state-set-and-get", test_ha_state_set_and_get },
643  { "ha-state-accept", test_ha_state_accept },
644  { "ha-failvecl-fetch", test_failvec_fetch },
645  { "ha-poolversion-get", test_poolversion_get },
646  { "ha-session-states", test_ha_session_states },
647  { NULL, NULL }
648  }
649 };
650 
651 #undef M0_TRACE_SUBSYSTEM
652 /*
653  * Local variables:
654  * c-indentation-style: "K&R"
655  * c-basic-offset: 8
656  * tab-width: 8
657  * fill-column: 80
658  * scroll-step: 1
659  * End:
660  */
661 /*
662  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
663  */
const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
Definition: obj.c:363
struct m0_fid co_id
Definition: obj.h:208
struct m0_poolmach_state * pm_state
Definition: pool_machine.h:169
M0_INTERNAL int m0_ha_state_get(struct m0_ha_nvec *note, struct m0_chan *chan)
Definition: note.c:74
#define SERVER_DB_NAME
Definition: note.c:42
#define M0_UT_CONF_PROFILE
Definition: misc.h:43
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
Definition: chan.c:336
static void test_poolversion_get(void)
Definition: note.c:475
struct m0_conf_obj * cc_root
Definition: confc.h:404
#define M0_PRE(cond)
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
const struct m0_conf_obj_type M0_CONF_OBJV_TYPE
Definition: objv.c:151
M0_INTERNAL void m0_pool_fini(struct m0_pool *pool)
Definition: pool.c:322
#define SERVER_ENDPOINT
Definition: note.c:47
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
struct m0_ut_suite ha_state_ut
Definition: note.c:637
M0_INTERNAL int m0_poolmach_state_transit(struct m0_poolmach *pm, const struct m0_poolmach_event *event)
Definition: pool_machine.c:554
char * rc_local_conf
Definition: rconfc.h:390
#define NULL
Definition: misc.h:38
uint32_t pst_nr_devices
Definition: pool_machine.h:108
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
Definition: chan.c:293
static struct m0_mutex chan_lock
Definition: note.c:96
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
M0_INTERNAL int m0_conf_full_load(struct m0_conf_root *r)
Definition: helpers.c:165
static void test_failvec_fetch(void)
Definition: note.c:390
struct m0_conf_obj rt_obj
Definition: obj.h:372
union @126 u
#define M0_LOG(level,...)
Definition: trace.h:167
static void compare_ha_state(struct m0_confc *confc, enum m0_ha_obj_state state)
Definition: note.c:204
M0_INTERNAL int m0_file_read(const char *path, char **out)
Definition: fs.c:61
static void ast_thread(int _ M0_UNUSED)
Definition: note.c:138
static int ha_state_ut_fini(void)
Definition: note.c:629
static struct m0_rpc_client_ctx cctx
Definition: note.c:66
int m0_rpc_server_start(struct m0_rpc_server_ctx *sctx)
Definition: rpclib.c:50
static struct net_test_cmd_node * node
Definition: commands.c:72
struct m0_clink s_clink
Definition: sm.h:516
struct m0_pool_version pool_ver
Definition: fd.c:111
M0_INTERNAL int m0_ha_client_del(struct m0_confc *confc)
Definition: epoch.c:232
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 int ast_thread_init(void)
Definition: note.c:148
M0_INTERNAL int m0_conf_diter_next_sync(struct m0_conf_diter *it, bool(*filter)(const struct m0_conf_obj *obj))
Definition: diter.c:555
#define SERVER_ENDPOINT_ADDR
Definition: note.c:46
M0_INTERNAL void m0_rconfc_stop_sync(struct m0_rconfc *rconfc)
Definition: rconfc.c:2995
static struct m0_be_emap_cursor it
Definition: extmap.c:46
struct m0_conf_obj pv_obj
Definition: obj.h:533
#define SERVER_LOG_NAME
Definition: note.c:45
M0_INTERNAL void m0_confc_fini(struct m0_confc *confc)
Definition: confc.c:570
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
static uint32_t recd_disks(const struct m0_conf_pver *pver)
Definition: note.c:468
#define M0_SET0(obj)
Definition: misc.h:64
Definition: ut.h:77
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
struct m0_pool * pv_pool
Definition: pool.h:128
#define CLIENT_ENDPOINT_ADDR
Definition: note.c:40
static void done_get_chan_fini(void)
Definition: note.c:173
M0_INTERNAL void m0_ha_state_set(const struct m0_ha_nvec *note)
Definition: note.c:95
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
m0_conf_pver_kind
Definition: obj.h:516
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL int m0_ha_failvec_fetch(const struct m0_fid *pool_fid, struct m0_poolmach *pmach, struct m0_chan *chan)
Definition: failvec.c:208
M0_INTERNAL int m0_pool_init(struct m0_pool *pool, const struct m0_fid *id, enum m0_pver_policy_code pver_policy)
Definition: pool.c:307
static struct @221 g_ast
struct m0_pooldev * pst_devices_array
Definition: pool_machine.h:111
struct m0_fid fid
Definition: di.c:46
static void done_get_chan_init(void)
Definition: note.c:165
M0_INTERNAL int m0_confc_root_open(struct m0_confc *confc, struct m0_conf_root **root)
Definition: helpers.c:219
static void check_pver_subtree(struct m0_confc *confc, const struct m0_fid *pver_fid)
Definition: note.c:362
M0_INTERNAL int m0_conf_pver_get(struct m0_confc *confc, const struct m0_fid *pool, struct m0_conf_pver **out)
Definition: helpers.c:71
static int expected
Definition: locality.c:102
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
M0_INTERNAL struct m0_fid * m0_reqh2profile(struct m0_reqh *reqh)
Definition: reqh.c:758
int i
Definition: dir.c:1033
#define SERVER_ADDB_STOB_NAME
Definition: note.c:44
M0_INTERNAL void m0_fid_set(struct m0_fid *fid, uint64_t container, uint64_t key)
Definition: fid.c:116
static void ha_ut_conf_fini(struct m0_reqh *reqh)
Definition: note.c:338
struct m0_conf_root * root
Definition: note.c:50
int32_t nv_nr
Definition: note.h:196
M0_INTERNAL struct m0_confc * m0_reqh2confc(struct m0_reqh *reqh)
Definition: reqh.c:753
static void test_ha_state_set_and_get(void)
Definition: note.c:250
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90
bool run
Definition: note.c:103
int cv_ix
Definition: obj.h:550
M0_INTERNAL int m0_rpc_conn_ha_subscribe(struct m0_rpc_conn *conn, struct m0_fid *svc_fid)
Definition: conn.c:585
M0_INTERNAL void m0_fi_disable(const char *fp_func, const char *fp_tag)
Definition: finject.c:485
static void m0_fi_enable(const char *func, const char *tag)
Definition: finject.h:276
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
Definition: chan.c:96
#define M0_ASSERT(cond)
static struct m0_confc * confc
Definition: file.c:94
Definition: note.c:60
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
struct m0_fid pver
Definition: idx_dix.c:74
struct m0_thread thread
Definition: note.c:104
enum m0_ha_obj_state co_ha_state
Definition: obj.h:241
static void test_ha_state_accept(void)
Definition: note.c:278
static struct m0_chan chan
Definition: note.c:97
struct m0_rpc_conn rcx_connection
Definition: rpclib.h:146
M0_INTERNAL int m0_reqh_init(struct m0_reqh *reqh, const struct m0_reqh_init_args *reqh_args)
Definition: reqh.c:227
m0_ha_obj_state
Definition: note.h:119
void m0_thread_fini(struct m0_thread *q)
Definition: thread.c:92
struct m0_reqh rc_reqh
Definition: setup.h:312
int m0_net_xprt_nr(void)
Definition: net.c:168
static void stop_rpc_client_and_server(void)
Definition: note.c:126
struct m0_conf_cache cc_cache
Definition: confc.h:394
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
Definition: rpclib.c:217
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
M0_INTERNAL void m0_clink_signal(struct m0_clink *clink)
Definition: chan.c:326
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL int m0_conf_obj_find_lock(struct m0_conf_cache *cache, const struct m0_fid *id, struct m0_conf_obj **out)
Definition: obj_ops.c:154
M0_INTERNAL int m0_conf_pver_fid_read(const struct m0_fid *fid, enum m0_conf_pver_kind *kind, uint64_t *container, uint64_t *key)
Definition: pvers.c:352
Definition: reqh.h:94
struct m0_fid pd_id
Definition: pool.h:428
Definition: chan.h:229
#define M0_CONF_CAST(ptr, type)
Definition: obj.h:780
M0_INTERNAL int m0_fid_sscanf(const char *s, struct m0_fid *fid)
Definition: fid.c:227
#define m0_confc_open_sync(result, origin,...)
Definition: confc.h:707
struct m0_net_domain * rcx_net_dom
Definition: rpclib.h:128
#define FID_P(f)
Definition: fid.h:77
struct m0_fid no_id
Definition: note.h:180
static int ha_state_ut_init(void)
Definition: note.c:617
M0_INTERNAL int m0_poolmach_init(struct m0_poolmach *pm, struct m0_pool_version *pver, uint32_t nr_nodes, uint32_t nr_devices, uint32_t nr_spare, uint32_t max_node_failures, uint32_t max_device_failures)
Definition: pool_machine.c:380
M0_INTERNAL void m0_rconfc_fini(struct m0_rconfc *rconfc)
Definition: rconfc.c:3009
static struct m0_net_domain client_net_dom
Definition: note.c:49
static struct m0_pool pool
Definition: iter_ut.c:58
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:255
static void ha_state_accept_1(const struct m0_fid *fid, uint32_t state)
Definition: note.c:461
static void local_confc_init(struct m0_confc *confc)
Definition: note.c:181
M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures(struct m0_poolmach *pm)
M0_INTERNAL struct m0_conf_obj * m0_conf_diter_result(const struct m0_conf_diter *it)
Definition: diter.c:576
#define m0_conf_diter_init(iter, confc, origin,...)
Definition: diter.h:235
const char * ts_name
Definition: ut.h:99
uint64_t n
Definition: fops.h:107
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
struct m0_reqh_service_type m0_rpc_service_type
Definition: service.c:120
int rsx_xprts_nr
Definition: rpclib.h:71
Definition: note.c:63
static void pool_machine_fid_populate(struct m0_poolmach *pool_mach)
Definition: note.c:440
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
static struct m0_rpc_server_ctx sctx
Definition: note.c:82
struct m0_reqh_context cc_reqh_ctx
Definition: setup.h:361
Definition: fid.h:38
struct m0_confc rc_confc
Definition: rconfc.h:235
static struct m0_clink clink
Definition: note.c:98
#define M0_UT_CONF_PROCESS
Definition: misc.h:45
struct m0_net_xprt ** m0_net_all_xprt_get(void)
Definition: net.c:161
M0_INTERNAL void m0_conf_diter_fini(struct m0_conf_diter *it)
Definition: diter.c:313
static int pm_event_construct_and_apply(struct m0_poolmach *pm, uint32_t dev_idx, uint32_t state)
Definition: note.c:449
static struct m0_net_test_service svc
Definition: service.c:34
M0_INTERNAL int m0_rconfc_start(struct m0_rconfc *rconfc)
Definition: rconfc.c:2928
static void ast_thread_fini(void)
Definition: note.c:156
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
static char * server_argv[]
Definition: note.c:74
M0_INTERNAL void m0_poolmach_fini(struct m0_poolmach *pm)
Definition: pool_machine.c:426
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
M0_INTERNAL int m0_ha_client_add(struct m0_confc *confc)
Definition: epoch.c:191
static void m0_fi_enable_once(const char *func, const char *tag)
Definition: finject.h:301
M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj)
Definition: confc.c:921
struct m0_rconfc rh_rconfc
Definition: reqh.h:166
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
Definition: pool.h:80
M0_INTERNAL uint32_t m0_poolmach_equeue_length(struct m0_poolmach *pm)
Definition: pool_machine.c:501
M0_INTERNAL void m0_rpc_conn_ha_unsubscribe(struct m0_rpc_conn *conn)
Definition: conn.c:632
M0_INTERNAL int m0_rconfc_init(struct m0_rconfc *rconfc, const struct m0_fid *profile, struct m0_sm_group *sm_group, struct m0_rpc_machine *rmach, m0_rconfc_cb_t expired_cb, m0_rconfc_cb_t ready_cb)
Definition: rconfc.c:2860
#define M0_UT_PATH(name)
Definition: misc.h:41
static void test_ha_session_states(void)
Definition: note.c:585
struct m0_ha_note * nv_note
Definition: note.h:197
M0_INTERNAL void m0_ha_state_accept(const struct m0_ha_nvec *note, bool ignore_same_state)
Definition: note.c:189
static struct m0_sm_group g_grp
Definition: note.c:100
#define SERVER_STOB_NAME
Definition: note.c:43
M0_INTERNAL void m0_sm_asts_run(struct m0_sm_group *grp)
Definition: sm.c:150
struct m0_reqh rcx_reqh
Definition: rpclib.h:144
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
Definition: chan.c:112
void m0_free(void *data)
Definition: memory.c:146
Definition: mutex.h:47
static struct m0_reqh_init_args reqh_args
Definition: note.c:89
static bool test_is_objv(const struct m0_conf_obj *obj)
Definition: note.c:356
static void ha_ut_pver_kind_check(const struct m0_fid *pver_fid, enum m0_conf_pver_kind expected)
Definition: note.c:345
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
static void ha_ut_conf_init(struct m0_reqh *reqh)
Definition: note.c:318
struct m0_fid g_process_fid
Definition: ut.c:689
static void start_rpc_client_and_server(void)
Definition: note.c:111
#define M0_UT_ASSERT(a)
Definition: ut.h:46
struct m0_motr rsx_motr_ctx
Definition: rpclib.h:84
struct m0_conf_obj * cv_real
Definition: obj.h:558
#define FID_F
Definition: fid.h:75
const struct m0_fid * rhia_fid
Definition: reqh.h:242
uint32_t no_state
Definition: note.h:182
Definition: note.c:61
#define M0_UNUSED
Definition: misc.h:380