Motr  M0
helper.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 <stdlib.h> /* system */
24 #include <sys/stat.h> /* mkdir */
25 #include <sys/types.h> /* mkdir */
26 #include <pthread.h> /* pthread_once */
27 #include <unistd.h> /* syscall */
28 #include <sys/syscall.h> /* syscall */
29 #include <unistd.h> /* chdir, get_current_dir_name */
30 
31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT
32 #include "lib/trace.h"
33 #include "lib/memory.h" /* m0_alloc */
34 #include "lib/misc.h" /* M0_BITS, ARRAY_SIZE */
35 #include "lib/arith.h" /* M0_CNT_INC */
36 #include "lib/errno.h" /* ENOMEM */
37 #include "lib/finject.h" /* M0_FI_ENABLED */
38 #include "rpc/rpclib.h" /* m0_rpc_server_start */
39 #include "net/net.h" /* m0_net_xprt */
40 #include "module/instance.h" /* m0_get */
41 #include "conf/obj.h" /* M0_CONF_PROCESS_TYPE */
42 #include "stob/domain.h" /* m0_stob_domain_create */
43 
44 #include "ut/stob.h" /* m0_ut_stob_linux_get */
45 #include "be/ut/helper.h" /* m0_be_ut_backend */
46 #include "be/tx_internal.h" /* m0_be_tx__reg_area */
47 #include "be/seg0.h" /* m0_be_0type_register */
48 
52  .bt_name = "m0_ut_be_backend_bobtype",
53  .bt_magix_offset = offsetof(struct m0_be_ut_backend, but_magix),
54  .bt_magix = M0_BE_TX_ENGINE_MAGIC,
55  .bt_check = NULL,
56 };
57 
60  pid_t sgt_tid;
65 };
66 
70  struct m0_reqh **buh_reqh;
71  pthread_once_t buh_once_control;
73  void *buh_addr;
74  int64_t buh_id;
75 };
76 
78  /* because there is no m0_mutex static initializer */
79  .buh_once_control = PTHREAD_ONCE_INIT,
80 };
81 
82 static void be_ut_helper_fini(void)
83 {
85 }
86 
87 /* XXX call this function from m0_init()? */
88 static void be_ut_helper_init(void)
89 {
90  struct be_ut_helper_struct *h = &be_ut_helper;
91 
92  h->buh_addr = (void *) BE_UT_SEG_START_ADDR;
95 
96  atexit(&be_ut_helper_fini); /* XXX REFACTORME */
97 }
98 
99 static void be_ut_helper_init_once(void)
100 {
101  int rc;
102 
104  M0_ASSERT(rc == 0);
105 }
106 
108 {
109  struct be_ut_helper_struct *h = &be_ut_helper;
110  void *addr;
111 
113 
115 
117  addr = h->buh_addr;
118  h->buh_addr += size;
120 
121  return addr;
122 }
123 
124 M0_INTERNAL uint64_t m0_be_ut_seg_allocate_id(void)
125 {
126  struct be_ut_helper_struct *h = &be_ut_helper;
127  uint64_t id;
128 
130 
132  id = h->buh_id++;
134 
135  return id;
136 }
137 
138 /*
139  * XXX m0_be_ut_reqh_create() function shall be removed after m0_reqh is
140  * modularized (i.e., initialised/finalised using m0_module API).
141  */
142 M0_INTERNAL void m0_be_ut_reqh_create(struct m0_reqh **pptr)
143 {
144  struct be_ut_helper_struct *h = &be_ut_helper;
145  struct m0_fid fid = M0_FID_TINIT(
147  0, 1);
148  int rc;
149 
150  M0_PRE(*pptr == NULL && h->buh_reqh == NULL);
151 
153 
154  M0_ALLOC_PTR(*pptr);
155  /*
156  * We don't bother with error handling here, because be_ut_helper
157  * is a kludge and should be removed.
158  */
159  M0_ASSERT(*pptr != NULL);
160  rc = M0_REQH_INIT(*pptr, .rhia_fid = &fid);
161  M0_ASSERT(rc == 0);
162  /*
163  * Remember the address of allocated pointer, so that it can be
164  * freed in m0_be_ut_reqh_destroy().
165  */
166  h->buh_reqh = pptr;
167 }
168 
169 M0_INTERNAL void m0_be_ut_reqh_destroy(void)
170 {
171  struct be_ut_helper_struct *h = &be_ut_helper;
172 
173  if (h->buh_reqh != NULL) {
174  m0_reqh_fini(*h->buh_reqh);
175  m0_free0(h->buh_reqh);
176  h->buh_reqh = NULL;
177  }
178 }
179 
180 static pid_t gettid_impl(void)
181 {
182  return syscall(SYS_gettid);
183 }
184 
186 {
187  struct m0_sm_group *grp = &sgt->sgt_grp;
188  bool need_to_up_asts_run_sem;
189 
190  while (!m0_semaphore_trydown(&sgt->sgt_stop_sem)) {
193  need_to_up_asts_run_sem =
196  if (need_to_up_asts_run_sem)
199  }
200 }
201 
203  bool lock_new)
204 {
205  struct m0_be_ut_sm_group_thread *sgt;
206  int rc;
207 
208  M0_ALLOC_PTR(*sgtp);
209  sgt = *sgtp;
210  if (sgt != NULL) {
211  sgt->sgt_tid = gettid_impl();
212  sgt->sgt_lock_new = lock_new;
213 
214  m0_sm_group_init(&sgt->sgt_grp);
217  rc = M0_THREAD_INIT(&sgt->sgt_thread,
218  struct m0_be_ut_sm_group_thread *, NULL,
220  "be_ut sgt");
221  if (rc == 0) {
222  if (sgt->sgt_lock_new)
223  m0_sm_group_lock(&sgt->sgt_grp);
224  } else {
226  m0_sm_group_fini(&sgt->sgt_grp);
227  m0_free(sgt);
228  }
229  } else {
230  rc = -ENOMEM;
231  }
232  return rc;
233 }
234 
236 {
237  int rc;
238 
240 
242  if (sgt->sgt_lock_new)
244 
245  rc = m0_thread_join(&sgt->sgt_thread);
246  M0_ASSERT(rc == 0);
247  m0_thread_fini(&sgt->sgt_thread);
248 
251  m0_sm_group_fini(&sgt->sgt_grp);
252  m0_free(sgt);
253 }
254 
255 #define M0_BE_LOG_NAME "M0_BE:LOG"
256 #define M0_BE_SEG0_NAME "M0_BE:SEG0"
257 #define M0_BE_SEG_NAME "M0_BE:SEG%08lu"
258 
260 {
261  extern struct m0_be_0type m0_stob_ad_0type;
262  extern struct m0_be_0type m0_be_cob0;
263  extern struct m0_be_0type m0_be_active_record0;
264  extern struct m0_be_0type m0_be_dtm0;
265 
266  static struct m0_atomic64 dom_key = { .a_value = 0xbef11e };
267  static const struct m0_be_0type *zts[] = {
269  &m0_be_cob0,
271  &m0_be_dtm0,
272  };
273  struct m0_reqh *reqh = cfg->bc_engine.bec_reqh;
274 
275  *cfg = (struct m0_be_domain_cfg) {
276  .bc_engine = {
277  .bec_tx_active_max = 0x100,
278  .bec_group_nr = 2,
279  .bec_group_cfg = {
280  .tgc_tx_nr_max = 128,
281  .tgc_seg_nr_max = 256,
282  .tgc_size_max = M0_BE_TX_CREDIT(1 << 18, 44UL << 20),
283  .tgc_payload_max = 1 << 24,
284  },
285  .bec_tx_size_max = M0_BE_TX_CREDIT(1 << 18, 44UL << 20),
286  .bec_tx_payload_max = 1 << 21,
287  .bec_group_freeze_timeout_min = 1ULL * M0_TIME_ONE_MSEC,
288  .bec_group_freeze_timeout_max = 50ULL * M0_TIME_ONE_MSEC,
289  .bec_group_freeze_timeout_limit = 60000ULL * M0_TIME_ONE_MSEC,
290  .bec_reqh = reqh,
291  .bec_wait_for_recovery = true,
292  },
293  .bc_log = {
294  .lc_store_cfg = {
295  .lsc_stob_id = {
296  /*
297  * .si_domain_fid is set by the log
298  * store
299  */
300  .si_fid = {
301  .f_container = 0,
302  .f_key = BE_UT_LOG_ID,
303  }
304  },
305  .lsc_stob_domain_key =
306  m0_atomic64_add_return(&dom_key, 1),
307  .lsc_size = 1 << 27,
308  .lsc_stob_create_cfg = NULL,
309  .lsc_stob_dont_zero = true,
310  .lsc_rbuf_nr = 3,
311  /* other fields are filled by domain and log */
312  },
313  .lc_sched_cfg = {
314  .lsch_io_sched_cfg = {
315  },
316  },
317  .lc_full_threshold = 20 * (1 << 20),
318  .lc_skip_recovery = false,
319  /* other fields are filled by the domain */
320  },
321  .bc_0types = zts,
322  .bc_0types_nr = ARRAY_SIZE(zts),
323  .bc_stob_domain_location = "linuxstob:./be_segments",
324  .bc_stob_domain_cfg_init = NULL,
325  .bc_seg0_stob_key = BE_UT_SEG_START_ID - 1,
326  .bc_mkfs_mode = false,
327  .bc_stob_domain_cfg_create = NULL,
328  .bc_stob_domain_key = m0_atomic64_add_return(&dom_key, 1),
329  .bc_seg0_cfg = {
330  .bsc_stob_key = BE_UT_SEG_START_ID - 1,
331  .bsc_size = 1 << 20,
332  .bsc_preallocate = false,
333  .bsc_addr = m0_be_ut_seg_allocate_addr(1 << 20),
334  .bsc_stob_create_cfg = NULL,
335  },
336  .bc_seg_cfg = NULL,
337  .bc_seg_nr = 0,
338  .bc_pd_cfg = {
339  .bpdc_seg_io_nr = 0x2,
340  },
341  .bc_log_discard_cfg = {
342  .ldsc_items_max = 0x100,
343  .ldsc_items_threshold = 0x80,
344  .ldsc_loc = m0_locality0_get(),
345  .ldsc_sync_timeout = M0_TIME_ONE_SECOND * 5ULL,
346  },
347  .bc_zone_pcnt = { [M0_BAP_NORMAL] = 100 }
348  };
349 }
350 
352  const struct m0_be_domain_cfg *cfg,
353  bool mkfs)
354 {
355  static bool mkfs_executed = false;
356  struct m0_be_domain_cfg *c;
357  int rc;
358 
360  if (!mkfs_executed && cfg == NULL &&
362  mkfs = mkfs_executed = true;
363 
364  ut_be->but_sm_groups_unlocked = false;
366 
367  if (cfg == NULL)
369  else
370  /*
371  * Make a copy of `cfg': it can be an automatic variable,
372  * which scope we should not rely on.
373  */
374  ut_be->but_dom_cfg = *cfg;
375  c = &ut_be->but_dom_cfg;
376 
377  /* Create reqh, if necessary. */
378  if (c->bc_engine.bec_reqh == NULL)
379  m0_be_ut_reqh_create(&c->bc_engine.bec_reqh);
380 
381  /* Use m0_be_ut_backend's stob domain location, if possible. */
383  c->bc_stob_domain_location = ut_be->but_stob_domain_location;
384 
385  c->bc_mkfs_mode = mkfs;
386 
387 check_mkfs:
391  if (!c->bc_mkfs_mode && rc == -ENOENT) {
393  M0_SET0(&ut_be->but_dom);
394  c->bc_mkfs_mode = true;
395  goto check_mkfs;
396  }
397  if (rc != 0)
399 
400  return rc;
401 }
402 
403 
404 M0_INTERNAL int
406  const struct m0_be_domain_cfg *cfg)
407 {
408  struct m0_be_domain *dom;
409  struct m0_be_domain_cfg *c;
410  int rc = 0;
411 
412  M0_PRE(cfg != NULL);
413  ut_be->but_dom_cfg = *cfg;
414 
415  c = &ut_be->but_dom_cfg;
416  dom = &ut_be->but_dom;
417 
418  /* Use m0_be_ut_backend's stob domain location, if possible. */
420  c->bc_stob_domain_location = ut_be->but_stob_domain_location;
421 
422  c->bc_mkfs_mode = true;
423 
424  c->bc_log.lc_got_space_cb = m0_be_engine_got_log_space_cb;
425  c->bc_log.lc_full_cb = m0_be_engine_full_log_cb;
426  c->bc_log.lc_lock = &dom->bd_engine_lock;
427 
428  be_domain_log_cleanup(c->bc_stob_domain_location, &c->bc_log, c->bc_mkfs_mode);
429 
430  rc = m0_be_log_create(m0_be_domain_log(dom), &c->bc_log);
431 
433 
434  return rc;
435 }
436 
438 {
439  int rc = m0_be_ut_backend_init_cfg(ut_be, NULL, true);
440  M0_ASSERT(rc == 0);
441 }
442 
444 {
452 }
453 
454 M0_INTERNAL void
456  const struct m0_be_0type_seg_cfg *seg_cfg,
457  struct m0_be_seg **out)
458 {
459  int rc;
460 
462  M0_ASSERT(rc == 0);
463 }
464 
465 M0_INTERNAL void
468  bool preallocate,
469  const char *stob_create_cfg,
470  struct m0_be_seg **out)
471 {
472  struct m0_be_0type_seg_cfg seg_cfg = {
474  .bsc_size = size,
475  .bsc_preallocate = preallocate,
476  .bsc_addr = m0_be_ut_seg_allocate_addr(size),
477  .bsc_stob_create_cfg = stob_create_cfg,
478  };
479  m0_be_ut_backend_seg_add(ut_be, &seg_cfg, out);
480 }
481 
482 M0_INTERNAL void
484  struct m0_be_seg *seg)
485 {
486  struct m0_be_tx_credit cred = {};
487  struct m0_be_domain *dom = &ut_be->but_dom;
489  struct m0_be_tx tx = {};
490  int rc;
491 
492  m0_be_ut_tx_init(&tx, ut_be);
496  m0_be_tx_prep(&tx, &cred);
498  M0_ASSERT(rc == 0);
500  M0_ASSERT(rc == 0);
501  m0_be_tx_close_sync(&tx);
502  m0_be_tx_fini(&tx);
505 }
506 
508  struct m0_be_ut_sm_group_thread *sgt)
509 {
510  struct m0_be_ut_sm_group_thread **sgt_arr;
511  size_t size = ut_be->but_sgt_size;
512 
513  M0_ALLOC_ARR(sgt_arr, size + 1);
514  M0_ASSERT(sgt_arr != NULL);
515 
516  m0_forall(i, size, sgt_arr[i] = ut_be->but_sgt[i], true);
517  sgt_arr[size] = sgt;
518 
520  ut_be->but_sgt = sgt_arr;
521  ++ut_be->but_sgt_size;
522 }
523 
525 {
526  size_t i;
527  pid_t tid = gettid_impl();
528 
529  for (i = 0; i < ut_be->but_sgt_size; ++i) {
530  if (ut_be->but_sgt[i]->sgt_tid == tid)
531  break;
532  }
533  return i;
534 }
535 
536 static struct m0_sm_group *
538 {
539  struct m0_be_ut_sm_group_thread *sgt;
540  struct m0_sm_group *grp;
541  pid_t tid = gettid_impl();
542  unsigned i;
543  int rc;
544 
546  grp = NULL;
547  for (i = 0; i < ut_be->but_sgt_size; ++i) {
548  sgt = ut_be->but_sgt[i];
549  if (sgt->sgt_tid == tid) {
550  grp = &sgt->sgt_grp;
551  break;
552  }
553  }
554  if (grp == NULL) {
555  rc = m0_be_ut_sm_group_thread_init(&sgt, lock_new);
556  M0_ASSERT(rc == 0);
558  grp = &sgt->sgt_grp;
559  }
561  M0_POST(grp != NULL);
562  return grp;
563 }
564 
565 struct m0_sm_group *
567 {
570 }
571 
573 {
574  struct m0_be_ut_sm_group_thread *sgt;
575  struct m0_sm_group *grp;
576 
578  sgt = container_of(grp, struct m0_be_ut_sm_group_thread, sgt_grp);
582 }
583 
585  bool unlocked_new)
586 {
587  ut_be->but_sm_groups_unlocked = unlocked_new;
588 }
589 
591 {
592  size_t index;
593  size_t i;
594 
597  if (index != ut_be->but_sgt_size) {
599  for (i = index + 1; i < ut_be->but_sgt_size; ++i)
600  ut_be->but_sgt[i - 1] = ut_be->but_sgt[i];
601  --ut_be->but_sgt_size;
602  }
604 }
605 
606 static void be_ut_tx_lock_if(struct m0_sm_group *grp,
607  struct m0_be_ut_backend *ut_be)
608 {
611 }
612 
613 static void be_ut_tx_unlock_if(struct m0_sm_group *grp,
614  struct m0_be_ut_backend *ut_be)
615 {
618 }
619 
621 {
623 
624  M0_SET0(tx);
626  m0_be_tx_init(tx, 0, &ut_be->but_dom, grp, NULL, NULL, NULL, NULL);
628 }
629 
631  struct m0_be_ut_backend *ut_be,
633 {
634  struct m0_be_0type_seg_cfg seg_cfg;
635  int rc;
636 
637  if (ut_be == NULL) {
644  M0_ASSERT(rc == 0);
646  M0_ASSERT(rc == 0);
647  } else {
648  seg_cfg = (struct m0_be_0type_seg_cfg){
650  .bsc_size = size,
651  .bsc_preallocate = false,
652  .bsc_addr = m0_be_ut_seg_allocate_addr(size),
653  .bsc_stob_create_cfg = NULL,
654  };
656  }
657 
659 }
660 
662 {
663  struct m0_stob *stob = ut_seg->bus_seg->bs_stob;
664  int rc;
665 
666  if (ut_seg->bus_backend == NULL) {
669  M0_ASSERT(rc == 0);
672 
673  m0_ut_stob_put(stob, false);
674  } else {
676  }
677 }
678 
679 M0_INTERNAL void m0_be_ut_alloc(struct m0_be_ut_backend *ut_be,
680  struct m0_be_ut_seg *ut_seg,
681  void **ptr,
683 {
685 
686  M0_BE_UT_TRANSACT(ut_be, tx, cred,
688  M0_BE_OP_SYNC(op, m0_be_alloc(a, tx, &op, ptr, size)));
689  M0_ASSERT(*ptr != NULL);
690 }
691 
692 M0_INTERNAL void m0_be_ut_free(struct m0_be_ut_backend *ut_be,
693  struct m0_be_ut_seg *ut_seg,
694  void *ptr)
695 {
697 
698  M0_BE_UT_TRANSACT(ut_be, tx, cred,
699  m0_be_allocator_credit(a, M0_BAO_FREE, 0, 0, &cred),
700  M0_BE_OP_SYNC(op, m0_be_free(a, tx, &op, ptr)));
701 }
702 
704 {
707 }
708 
710  struct m0_be_ut_backend *ut_be,
711  bool init)
712 {
713  struct m0_be_tx_credit credit = {};
714  struct m0_be_allocator *a;
715  struct m0_be_tx tx;
716  uint32_t percent[M0_BAP_NR] = { [M0_BAP_NORMAL] = 100 };
717  int rc;
718 
720 
721  if (ut_be != NULL) {
722  m0_be_ut_tx_init(&tx, ut_be);
725  0, 0, &credit);
726  m0_be_tx_prep(&tx, &credit);
727  rc = m0_be_tx_open_sync(&tx);
728  M0_ASSERT(rc == 0);
729  }
730 
731  if (init) {
733  M0_ASSERT(rc == 0);
734  if (M0_FI_ENABLED("repair_zone_50")) {
735  percent[M0_BAP_REPAIR] = 50;
736  percent[M0_BAP_NORMAL] = 50;
737  }
738  rc = m0_be_allocator_create(a, ut_be == NULL ? NULL : &tx,
739  percent, ARRAY_SIZE(percent));
740  M0_ASSERT(rc == 0);
741  } else {
742  m0_be_allocator_destroy(a, ut_be == NULL ? NULL : &tx);
744  }
745 
746  if (ut_be != NULL) {
747  m0_be_tx_close_sync(&tx);
748  m0_be_tx_fini(&tx);
750  }
751 }
752 
754  struct m0_be_ut_backend *ut_be)
755 {
757 }
758 
760  struct m0_be_ut_backend *ut_be)
761 {
763 }
764 
765 #undef M0_TRACE_SUBSYSTEM
766 
767 /*
768  * Local variables:
769  * c-indentation-style: "K&R"
770  * c-basic-offset: 8
771  * tab-width: 8
772  * fill-column: 80
773  * scroll-step: 1
774  * End:
775  */
776 /*
777  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
778  */
void * buh_addr
Definition: helper.c:73
void m0_be_ut_backend_new_grp_lock_state_set(struct m0_be_ut_backend *ut_be, bool unlocked_new)
Definition: helper.c:584
uint64_t id
Definition: cob.h:2380
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
Definition: chan.c:336
#define M0_PRE(cond)
#define M0_ALLOC_ARR(arr, nr)
Definition: memory.h:84
static void be_ut_tx_lock_if(struct m0_sm_group *grp, struct m0_be_ut_backend *ut_be)
Definition: helper.c:606
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
struct m0_sm_group * m0_be_ut_backend_sm_group_lookup(struct m0_be_ut_backend *ut_be)
Definition: helper.c:566
#define NULL
Definition: misc.h:38
struct m0_semaphore sgt_asts_run_sem
Definition: helper.c:61
M0_INTERNAL void m0_be_seg_fini(struct m0_be_seg *seg)
Definition: stubs.c:128
M0_INTERNAL bool m0_semaphore_trydown(struct m0_semaphore *semaphore)
Definition: semaphore.c:60
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
M0_INTERNAL int m0_be_domain_seg_create(struct m0_be_domain *dom, struct m0_be_tx *tx, const struct m0_be_0type_seg_cfg *seg_cfg, struct m0_be_seg **out)
Definition: domain.c:550
#define M0_REQH_INIT(reqh,...)
Definition: reqh.h:262
static struct m0_sm_group * grp
Definition: bytecount.c:38
uint8_t ft_id
Definition: fid.h:101
M0_INTERNAL void * m0_be_ut_seg_allocate_addr(m0_bcount_t size)
Definition: helper.c:107
M0_INTERNAL void m0_be_seg_init(struct m0_be_seg *seg, struct m0_stob *stob, struct m0_be_domain *dom, uint64_t seg_id)
Definition: stubs.c:118
struct m0_be_seg * bus_seg
Definition: helper.h:119
M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
Definition: stubs.c:163
M0_INTERNAL int m0_be_seg_create(struct m0_be_seg *seg, m0_bcount_t size, void *addr)
Definition: seg.c:224
int64_t buh_id
Definition: helper.c:74
struct m0_clink s_clink
Definition: sm.h:516
Allocator.
Definition: alloc.h:132
#define M0_BE_OP_SYNC(op_obj, action)
Definition: op.h:190
struct m0_mutex but_sgt_lock
Definition: helper.h:56
void m0_be_ut_seg_allocator_init(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be)
Definition: helper.c:753
char * but_stob_domain_location
Definition: helper.h:58
struct m0_be_0type m0_stob_ad_0type
Definition: ad.c:159
M0_INTERNAL void m0_be_tx_prep(struct m0_be_tx *tx, const struct m0_be_tx_credit *credit)
Definition: stubs.c:175
struct m0_be_ut_seg ut_seg
Definition: ad.c:73
uint64_t m0_bcount_t
Definition: types.h:77
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
M0_INTERNAL void m0_be_ut_backend_seg_add2(struct m0_be_ut_backend *ut_be, m0_bcount_t size, bool preallocate, const char *stob_create_cfg, struct m0_be_seg **out)
Definition: helper.c:466
M0_INTERNAL void m0_be_ut_reqh_create(struct m0_reqh **pptr)
Definition: helper.c:142
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
struct m0_be_0type m0_be_dtm0
Definition: helper.c:54
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
Definition: sm.c:65
uint64_t bec_tx_active_max
Definition: engine.h:59
bool but_sm_groups_unlocked
Definition: helper.h:57
const char * bt_name
Definition: bob.h:73
M0_INTERNAL void m0_be_seg_close(struct m0_be_seg *seg)
Definition: stubs.c:140
M0_INTERNAL void m0_be_domain_seg_destroy_credit(struct m0_be_domain *dom, struct m0_be_seg *seg, struct m0_be_tx_credit *cred)
Definition: domain.c:539
struct m0_fid fid
Definition: di.c:46
void m0_be_ut_seg_init(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be, m0_bcount_t size)
Definition: helper.c:630
op
Definition: libdemo.c:64
#define M0_BE_TX_CREDIT(nr, size)
Definition: tx_credit.h:94
M0_INTERNAL int m0_pagesize_get(void)
Definition: memory.c:233
M0_INTERNAL void m0_be_ut_backend_seg_del(struct m0_be_ut_backend *ut_be, struct m0_be_seg *seg)
Definition: helper.c:483
struct m0_reqh * bec_reqh
Definition: engine.h:84
void m0_be_ut_seg_reload(struct m0_be_ut_seg *ut_seg)
Definition: helper.c:703
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
struct m0_mutex buh_seg_lock
Definition: helper.c:72
static void be_ut_helper_fini(void)
Definition: helper.c:82
static char * addr
Definition: node_k.c:37
int i
Definition: dir.c:1033
M0_INTERNAL struct m0_stob * m0_ut_stob_linux_get(void)
Definition: stob.c:169
M0_INTERNAL void m0_be_engine_got_log_space_cb(struct m0_be_log *log)
Definition: engine.c:860
M0_INTERNAL int m0_be_ut_backend_init_cfg(struct m0_be_ut_backend *ut_be, const struct m0_be_domain_cfg *cfg, bool mkfs)
Definition: helper.c:351
M0_INTERNAL void m0_bob_init(const struct m0_bob_type *bt, void *bob)
Definition: bob.c:61
struct m0_be_ut_backend ut_be
Definition: ad.c:72
void m0_be_ut_backend_thread_exit(struct m0_be_ut_backend *ut_be)
Definition: helper.c:590
M0_INTERNAL void m0_be_log_close(struct m0_be_log *log)
Definition: log.c:287
uint64_t bsc_stob_key
Definition: domain.h:70
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90
struct m0_be_0type m0_be_cob0
Definition: cob.c:111
Definition: stob.h:163
const struct m0_fid_type cot_ftype
Definition: obj.h:314
static struct m0_stob * stob
Definition: storage.c:39
#define m0_free0(pptr)
Definition: memory.h:77
struct m0_be_0type m0_be_active_record0
Definition: active_record.c:65
#define M0_ASSERT(cond)
void m0_be_ut_backend_sm_group_asts_run(struct m0_be_ut_backend *ut_be)
Definition: helper.c:572
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
Definition: sm.c:53
M0_INTERNAL void m0_be_ut_free(struct m0_be_ut_backend *ut_be, struct m0_be_ut_seg *ut_seg, void *ptr)
Definition: helper.c:692
M0_INTERNAL void m0_be_ut_reqh_destroy(void)
Definition: helper.c:169
static struct m0_addb2_callback c
Definition: consumer.c:41
M0_INTERNAL struct m0_be_allocator * m0_be_seg_allocator(struct m0_be_seg *seg)
Definition: stubs.c:113
M0_INTERNAL void m0_bob_fini(const struct m0_bob_type *bt, void *bob)
Definition: bob.c:68
M0_INTERNAL void m0_be_ut_alloc(struct m0_be_ut_backend *ut_be, struct m0_be_ut_seg *ut_seg, void **ptr, m0_bcount_t size)
Definition: helper.c:679
M0_INTERNAL void m0_be_alloc(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void **ptr, m0_bcount_t size)
Definition: alloc.c:1091
void m0_thread_fini(struct m0_thread *q)
Definition: thread.c:92
pthread_once_t buh_once_control
Definition: helper.c:71
static struct m0_stob_domain * dom
Definition: storage.c:38
static size_t be_ut_backend_sm_group_find(struct m0_be_ut_backend *ut_be)
Definition: helper.c:524
M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
Definition: stubs.c:199
M0_INTERNAL struct m0_be_log * m0_be_domain_log(struct m0_be_domain *dom)
Definition: domain.c:471
static void be_ut_helper_init_once(void)
Definition: helper.c:99
M0_INTERNAL void m0_clink_signal(struct m0_clink *clink)
Definition: chan.c:326
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
static pid_t gettid_impl(void)
Definition: helper.c:180
M0_INTERNAL int m0_be_log_create(struct m0_be_log *log, struct m0_be_log_cfg *log_cfg)
Definition: log.c:292
struct m0_sm_group * sm_grp
Definition: sm.h:321
struct m0_be_ut_sm_group_thread ** but_sgt
Definition: helper.h:54
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
static struct m0_sm_group * be_ut_backend_sm_group_lookup(struct m0_be_ut_backend *ut_be, bool lock_new)
Definition: helper.c:537
M0_INTERNAL int m0_be_tx_exclusive_open_sync(struct m0_be_tx *tx)
Definition: tx.c:594
#define M0_POST(cond)
void m0_be_ut_seg_fini(struct m0_be_ut_seg *ut_seg)
Definition: helper.c:661
Definition: xcode.h:73
struct m0_reqh ** buh_reqh
Definition: helper.c:70
struct m0_be_ut_backend * bus_backend
Definition: helper.h:120
Definition: reqh.h:94
static void be_ut_sm_group_thread_func(struct m0_be_ut_sm_group_thread *sgt)
Definition: helper.c:185
struct m0_net_xprt * buh_net_xprt
Definition: helper.c:68
M0_INTERNAL void m0_be_allocator_destroy(struct m0_be_allocator *a, struct m0_be_tx *tx)
Definition: alloc.c:883
void m0_be_ut_seg_allocator_fini(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be)
Definition: helper.c:759
static void be_ut_tx_unlock_if(struct m0_sm_group *grp, struct m0_be_ut_backend *ut_be)
Definition: helper.c:613
struct m0_sm t_sm
Definition: tx.h:281
Definition: seg.h:66
struct m0_be_domain but_dom
Definition: helper.h:47
M0_INTERNAL void m0_ut_stob_put(struct m0_stob *stob, bool destroy)
Definition: stob.c:185
struct m0_semaphore sgt_stop_sem
Definition: helper.c:62
static void m0_be_ut_sm_group_thread_fini(struct m0_be_ut_sm_group_thread *sgt)
Definition: helper.c:235
M0_INTERNAL void m0_be_tx_init(struct m0_be_tx *tx, uint64_t tid, struct m0_be_domain *dom, struct m0_sm_group *sm_group, m0_be_tx_cb_t persistent, m0_be_tx_cb_t discarded, void(*filler)(struct m0_be_tx *tx, void *payload), void *datum)
Definition: stubs.c:150
#define m0_forall(var, nr,...)
Definition: misc.h:112
struct m0_module bd_module
Definition: domain.h:134
size_t but_sgt_size
Definition: helper.h:55
int init(struct workload *w)
struct m0_be_domain_cfg but_dom_cfg
Definition: helper.h:53
struct m0_sm_group sgt_grp
Definition: helper.c:63
M0_INTERNAL int m0_be_ut_backend_log_resize(struct m0_be_ut_backend *ut_be, const struct m0_be_domain_cfg *cfg)
Definition: helper.c:405
struct m0_rpc_server_ctx buh_rpc_sctx
Definition: helper.c:69
struct m0_reqh reqh
Definition: rm_foms.c:48
M0_INTERNAL struct m0_locality * m0_locality0_get(void)
Definition: locality.c:169
M0_INTERNAL void m0_be_domain_module_setup(struct m0_be_domain *dom, const struct m0_be_domain_cfg *cfg)
Definition: domain.c:952
M0_INTERNAL void m0_be_free(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void *ptr)
Definition: alloc.c:1151
#define M0_BE_UT_TRANSACT(__ut_be, __tx, __cred, __credit_func, __action_func)
Definition: helper.h:159
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
Definition: fid.h:38
void m0_be_ut_backend_fini(struct m0_be_ut_backend *ut_be)
Definition: helper.c:443
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static void be_ut_helper_init(void)
Definition: helper.c:88
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
const struct m0_bob_type m0_ut_be_backend_bobtype
Definition: helper.c:49
M0_INTERNAL int m0_be_seg_destroy(struct m0_be_seg *seg)
Definition: seg.c:243
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
void m0_be_ut_tx_init(struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be)
Definition: helper.c:620
atomic64_t a_value
Definition: atomic64.h:38
M0_INTERNAL uint64_t m0_be_ut_seg_allocate_id(void)
Definition: helper.c:124
M0_INTERNAL int m0_be_seg_open(struct m0_be_seg *seg)
Definition: stubs.c:132
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
static struct m0_be_seg * seg
Definition: btree.c:40
struct m0_thread sgt_thread
Definition: helper.c:59
struct m0_stob * bs_stob
Definition: seg.h:68
M0_INTERNAL int m0_be_allocator_create(struct m0_be_allocator *a, struct m0_be_tx *tx, uint32_t *zone_percent, uint32_t zones_nr)
Definition: alloc.c:821
M0_INTERNAL void m0_be_engine_full_log_cb(struct m0_be_log *log)
Definition: engine.c:874
M0_INTERNAL int m0_be_allocator_init(struct m0_be_allocator *a, struct m0_be_seg *seg)
Definition: alloc.c:719
M0_INTERNAL void be_domain_log_cleanup(const char *stob_domain_location, struct m0_be_log_cfg *log_cfg, bool create)
Definition: domain.c:363
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
const struct m0_conf_obj_type M0_CONF_PROCESS_TYPE
Definition: process.c:161
#define out(...)
Definition: gen.c:41
static void be_ut_seg_allocator_initfini(struct m0_be_seg *seg, struct m0_be_ut_backend *ut_be, bool init)
Definition: helper.c:709
void m0_be_ut_backend_cfg_default(struct m0_be_domain_cfg *cfg)
Definition: helper.c:259
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
M0_INTERNAL void m0_be_allocator_credit(struct m0_be_allocator *a, enum m0_be_allocator_op optype, m0_bcount_t size, unsigned shift, struct m0_be_tx_credit *accum)
Definition: alloc.c:900
M0_BOB_DEFINE(M0_INTERNAL, &m0_ut_be_backend_bobtype, m0_be_ut_backend)
M0_INTERNAL void m0_sm_asts_run(struct m0_sm_group *grp)
Definition: sm.c:150
M0_INTERNAL int m0_be_domain_seg_destroy(struct m0_be_domain *dom, struct m0_be_tx *tx, struct m0_be_seg *seg)
Definition: domain.c:621
void m0_free(void *data)
Definition: memory.c:146
Definition: mutex.h:47
struct m0_be_engine_cfg bc_engine
Definition: domain.h:79
int32_t rc
Definition: trigger_fop.h:47
static int m0_be_ut_sm_group_thread_init(struct m0_be_ut_sm_group_thread **sgtp, bool lock_new)
Definition: helper.c:202
#define ARRAY_SIZE(a)
Definition: misc.h:45
#define offsetof(typ, memb)
Definition: misc.h:29
static uint64_t m0_align(uint64_t val, uint64_t alignment)
Definition: arith.h:170
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
Definition: module.c:142
static void be_ut_sm_group_thread_add(struct m0_be_ut_backend *ut_be, struct m0_be_ut_sm_group_thread *sgt)
Definition: helper.c:507
void m0_be_ut_backend_init(struct m0_be_ut_backend *ut_be)
Definition: helper.c:437
static int64_t m0_atomic64_add_return(struct m0_atomic64 *a, int64_t d)
M0_INTERNAL void m0_be_ut_backend_seg_add(struct m0_be_ut_backend *ut_be, const struct m0_be_0type_seg_cfg *seg_cfg, struct m0_be_seg **out)
Definition: helper.c:455
M0_INTERNAL void m0_be_allocator_fini(struct m0_be_allocator *a)
Definition: alloc.c:745
static struct be_ut_helper_struct be_ut_helper
Definition: helper.c:77
M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)
Definition: stubs.c:205
Definition: tx.h:280
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131