Motr  M0
sys.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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 
58 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_ADDB
59 
60 #include "lib/misc.h" /* M0_IS0, M0_AMB */
61 #include "lib/arith.h" /* M0_CNT_DEC, M0_CNT_INC */
62 #include "lib/errno.h" /* ENOMEM */
63 #include "lib/memory.h" /* M0_ALLOC_PTR, m0_free */
64 #include "lib/finject.h"
65 #include "lib/locality.h"
66 #include "lib/trace.h"
67 #include "lib/thread.h"
68 
69 #include "pool/pool.h" /* pools_common_svc_ctx_tl */
70 #include "module/instance.h" /* m0_get */
71 
72 #include "addb2/addb2.h"
73 #include "addb2/storage.h"
74 #include "addb2/net.h"
75 #include "addb2/identifier.h"
76 #include "addb2/internal.h"
77 #include "addb2/sys.h"
78 
82 struct m0_addb2_sys {
91  struct m0_mutex sy_lock;
107  struct m0_tl sy_queue;
124  struct m0_tl sy_pool;
154 };
155 
156 static void sys_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast);
157 static void sys_post(struct m0_addb2_sys *sys);
158 static void sys_idle(struct m0_addb2_mach *mach);
159 static void sys_lock(struct m0_addb2_sys *sys);
160 static void sys_unlock(struct m0_addb2_sys *sys);
161 static void sys_qlock(struct m0_addb2_sys *sys);
162 static void sys_qunlock(struct m0_addb2_sys *sys);
163 static void sys_balance(struct m0_addb2_sys *sys);
164 static bool sys_invariant(const struct m0_addb2_sys *sys);
165 static bool sys_queue_invariant(const struct m0_addb2_sys *sys);
166 static int sys_submit(struct m0_addb2_mach *mach,
167  struct m0_addb2_trace_obj *obj);
168 static void net_idle(struct m0_addb2_net *net, void *datum);
169 static void net_stop(struct m0_addb2_sys *sys);
170 static void stor_stop(struct m0_addb2_sys *sys);
171 static m0_bcount_t sys_size(const struct m0_addb2_sys *sys);
172 
173 static const struct m0_addb2_mach_ops sys_mach_ops;
174 static const struct m0_addb2_storage_ops sys_stor_ops;
175 
177  const struct m0_addb2_config *conf)
178 {
179  struct m0_addb2_sys *sys;
180  int result;
181 
182  M0_PRE(conf->co_buffer_min <= conf->co_buffer_max);
183  M0_PRE(conf->co_pool_min <= conf->co_pool_max);
184  M0_PRE(conf->co_buffer_size % sizeof(uint64_t) == 0);
185 
186  M0_ALLOC_PTR(sys);
187  if (sys != NULL) {
188  sys->sy_conf = *conf;
189  sys->sy_ast.sa_cb = &sys_ast;
190  m0_mutex_init(&sys->sy_lock);
191  m0_mutex_init(&sys->sy_qlock);
200  sys->sy_astwait.aw_allowed = false;
201  tr_tlist_init(&sys->sy_queue);
202  mach_tlist_init(&sys->sy_pool);
203  mach_tlist_init(&sys->sy_granted);
204  mach_tlist_init(&sys->sy_moribund);
205  mach_tlist_init(&sys->sy_deathrow);
206  m0_list_init(&sys->sy_counters);
207  *out = sys;
208  result = 0;
209  } else
210  result = M0_ERR(-ENOMEM);
211  return result;
212 }
213 
215 {
216  struct m0_addb2_mach *m;
217  struct m0_addb2_trace_obj *to;
218 
219  /*
220  * sys object finalisation is a delicate job, because we have to deal
221  * with various asynchronous activities: concurrent ASTs and back-end
222  * finalisations.
223  */
224 
226  m0_tl_for(mach, &sys->sy_pool, m) {
227  mach_tlist_move_tail(&sys->sy_moribund, m);
229  } m0_tl_endfor;
230  mach_tlist_fini(&sys->sy_pool);
231  /* to keep invariant happy, no concurrency at this point. */
232  sys_lock(sys);
233  sys_balance(sys);
234  sys_unlock(sys);
235  if (sys->sy_queued > 0)
236  M0_LOG(M0_NOTICE, "Records lost: %" PRIi64 "/%zi.",
237  sys->sy_queued, tr_tlist_length(&sys->sy_queue));
238  m0_tl_teardown(tr, &sys->sy_queue, to) {
239  /*
240  * Update the counter *before* calling m0_addb2_trace_done(),
241  * because it might invoke sys_invariant() via sys_idle().
242  */
243  sys->sy_queued -= to->o_tr.tr_nr;
245  }
246  m0_tl_for(mach, &sys->sy_moribund, m) {
248  } m0_tl_endfor;
249  mach_tlist_fini(&sys->sy_moribund);
250  sys_lock(sys);
251  sys_balance(sys);
252  mach_tlist_fini(&sys->sy_deathrow);
253  m0_tl_for(mach, &sys->sy_granted, m) {
254  /* Print still granted machines, there should be none! */
256  } m0_tl_endfor;
257  M0_ASSERT_INFO(sys->sy_total == 0, "%"PRIi64, sys->sy_total);
258  mach_tlist_fini(&sys->sy_granted);
259  net_stop(sys);
260  stor_stop(sys);
261  sys_qlock(sys);
263  sys_qunlock(sys);
264  sys_unlock(sys);
265  tr_tlist_fini(&sys->sy_queue);
266  m0_mutex_fini(&sys->sy_qlock);
267  m0_mutex_fini(&sys->sy_lock);
268  /* Do not finalise &sys->sy_counters: can be non-empty. */
269  m0_free(sys);
270 }
271 
273 {
274  struct m0_addb2_mach *m;
275 
276  sys_lock(sys);
277  m = mach_tlist_pop(&sys->sy_pool);
278  if (m == NULL) {
279  if (sys->sy_total < sys->sy_conf.co_pool_max) {
281  if (m != NULL)
282  M0_CNT_INC(sys->sy_total);
283  else
284  M0_LOG(M0_WARN, "Init: %" PRId64 ".",
285  sys->sy_total);
286  } else
287  M0_LOG(M0_WARN, "Limit: %" PRId64 ".", sys->sy_total);
288  }
289  if (m != NULL)
290  mach_tlist_add(&sys->sy_granted, m);
291  sys_unlock(sys);
292  return m;
293 }
294 
295 void m0_addb2_sys_put(struct m0_addb2_sys *sys, struct m0_addb2_mach *m)
296 {
297  bool kill;
298 
299  sys_lock(sys);
300  M0_PRE(mach_tlist_contains(&sys->sy_granted, m));
301  kill = sys->sy_total > sys->sy_conf.co_pool_min;
302  if (kill)
303  mach_tlist_move_tail(&sys->sy_moribund, m);
304  else
305  mach_tlist_move(&sys->sy_pool, m);
306  sys_balance(sys);
307  sys_unlock(sys);
308  if (kill)
310 }
311 
313 {
314  M0_PRE(sys->sy_net == NULL);
315 
316  sys_lock(sys);
317  sys->sy_net = m0_addb2_net_init();
318  sys_unlock(sys);
319  return sys->sy_net != NULL ? 0 : M0_ERR(-ENOMEM);
320 }
321 
323 {
324  sys_lock(sys);
325  net_stop(sys);
326  sys_unlock(sys);
327 }
328 
330 {
332  struct m0_rpc_conn *conn;
333  int result = 0;
334 
335  if (sys->sy_net == NULL) {
336  result = m0_addb2_sys_net_start(sys);
337  if (result != 0)
338  return M0_ERR(result);
339  }
340 
341  m0_tl_for(pools_common_svc_ctx, head, service) {
342  if (service->sc_type == M0_CST_ADDB2) {
343  conn = &service->sc_rlink.rlk_conn;
344  sys_lock(sys);
345  result = m0_addb2_net_add(sys->sy_net, conn);
346  sys_unlock(sys);
347  if (result != 0) {
349  break;
350  }
351  }
352  } m0_tl_endfor;
353 
354  return result;
355 }
356 
357 int m0_addb2_sys_stor_start(struct m0_addb2_sys *sys, const char *location,
358  uint64_t key, bool mkfs, bool force,
360 {
361  M0_PRE(sys->sy_stor == NULL);
362 
363  sys_lock(sys);
364  sys->sy_stor = m0_addb2_storage_init(location, key, mkfs, force,
365  &sys_stor_ops, size, sys);
366  sys_unlock(sys);
367  return sys->sy_stor != NULL ? 0 : M0_ERR(-ENOMEM);
368 }
369 
371 {
372  sys_lock(sys);
373  stor_stop(sys);
374  sys_unlock(sys);
375 }
376 
378 {
379  sys_qlock(sys);
380  sys->sy_astwait.aw_allowed = true;
381  sys_qunlock(sys);
382 }
383 
385 {
386  sys_qlock(sys);
387  m0_sm_ast_wait(&sys->sy_astwait);
388  M0_ASSERT(sys->sy_ast.sa_next == NULL);
389  sys_qunlock(sys);
390 }
391 
393  struct m0_addb2_trace_obj *obj)
394 {
395  sys_qlock(sys);
396  if (sys->sy_queued + obj->o_tr.tr_nr <= sys->sy_conf.co_queue_max) {
397  sys->sy_queued += obj->o_tr.tr_nr;
398  tr_tlink_init_at_tail(obj, &sys->sy_queue);
399  sys_post(sys);
400  } else {
401  M0_LOG(M0_DEBUG, "Queue overflow.");
402  obj = NULL;
403  }
404  sys_qunlock(sys);
405  return obj != NULL;
406 }
407 
409 {
410  sys_lock(sys);
411  sys->sy_net = src->sy_net;
412  sys->sy_stor = src->sy_stor;
413  sys_unlock(sys);
414 }
415 
417 {
418  sys_lock(sys);
419  sys_balance(sys);
420  sys->sy_net = NULL;
421  sys->sy_stor = NULL;
422  sys_unlock(sys);
423 }
424 
426  struct m0_addb2_counter *counter, uint64_t id)
427 {
428  counter->co_sensor.s_id = id;
429  sys_lock(sys);
431  &counter->co_sensor.s_linkage.t_link);
432  sys_unlock(sys);
433 }
434 
442 static void sys_balance(struct m0_addb2_sys *sys)
443 {
444  struct m0_addb2_trace_obj *obj;
445  struct m0_addb2_mach *m;
446 
447  M0_PRE(sys_invariant(sys));
448  if (sys->sy_stor != NULL || sys->sy_net != NULL) {
449  sys_qlock(sys);
450  while ((obj = tr_tlist_pop(&sys->sy_queue)) != NULL) {
451  sys->sy_queued -= obj->o_tr.tr_nr;
452  sys_qunlock(sys);
453  if (m0_get()->i_disable_addb2_storage ||
454  (sys->sy_stor != NULL ?
456  m0_addb2_net_submit(sys->sy_net, obj)) == 0)
457  m0_addb2_trace_done(&obj->o_tr);
458  sys_qlock(sys);
459  }
460  sys_qunlock(sys);
461  }
462  m0_tl_teardown(mach, &sys->sy_deathrow, m) {
464  M0_CNT_DEC(sys->sy_total);
465  }
466  M0_POST(sys_invariant(sys));
467 }
468 
470  struct m0_addb2_trace_obj *obj) = NULL;
471 
472 static int sys_submit(struct m0_addb2_mach *m, struct m0_addb2_trace_obj *obj)
473 {
474  struct m0_addb2_sys *sys = m0_addb2_mach_cookie(m);
475 
476  if (M0_FI_ENABLED("trap") && m0_addb2__sys_submit_trap != NULL)
478  return m0_addb2_sys_submit(sys, obj);
479 }
480 
481 static void sys_post(struct m0_addb2_sys *sys)
482 {
484  /*
485  * m0_sm_ast_wait_post() checks for ->aw_allowed, but we have to check
486  * it before calling m0_locality_here(), because m0_addb2_global_fini()
487  * is called after m0_localities_fini().
488  */
489  if (sys->sy_astwait.aw_allowed && sys->sy_ast.sa_next == NULL)
491  m0_locality_here()->lo_grp, &sys->sy_ast);
492 }
493 
502 static void sys_idle(struct m0_addb2_mach *m)
503 {
504  struct m0_addb2_sys *sys = m0_addb2_mach_cookie(m);
505 
506  sys_lock(sys);
507  M0_PRE(mach_tlist_contains(&sys->sy_moribund, m));
508  mach_tlist_move(&sys->sy_deathrow, m);
509  sys_qlock(sys);
510  sys_post(sys);
511  sys_qunlock(sys);
512  sys_unlock(sys);
513 }
514 
515 static void net_stop(struct m0_addb2_sys *sys)
516 {
518  sys_balance(sys);
519  if (sys->sy_net != NULL) {
520  m0_semaphore_init(&sys->sy_wait, 0);
521  m0_addb2_net_stop(sys->sy_net, &net_idle, sys);
522  m0_semaphore_down(&sys->sy_wait);
524  m0_semaphore_fini(&sys->sy_wait);
525  sys->sy_net = NULL;
526  }
527 }
528 
529 static void stor_stop(struct m0_addb2_sys *sys)
530 {
532  sys_balance(sys);
533  if (sys->sy_stor != NULL) {
534  m0_semaphore_init(&sys->sy_wait, 0);
536  sys_unlock(sys);
537  m0_semaphore_down(&sys->sy_wait);
538  sys_lock(sys);
540  m0_semaphore_fini(&sys->sy_wait);
541  sys->sy_stor = NULL;
542  }
543 }
544 
545 void (*m0_addb2__sys_ast_trap)(struct m0_addb2_sys *sys) = NULL;
546 
550 static void sys_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
551 {
552  struct m0_addb2_sys *sys = M0_AMB(sys, ast, sy_ast);
553 
554  if (M0_FI_ENABLED("trap") && m0_addb2__sys_ast_trap != NULL)
556  sys_lock(sys);
557  /*
558  * Add counters one by one, trying to distribute them across localities.
559  */
560  if (!m0_list_is_empty(&sys->sy_counters)) {
561  struct m0_addb2_counter *counter;
562  uint64_t id;
563 
566  id = counter->co_sensor.s_id;
567  m0_list_del(&counter->co_sensor.s_linkage.t_link);
568  M0_SET0(counter);
569  m0_addb2_counter_add(counter, id, -1);
570  }
571  sys_balance(sys);
572  sys_qlock(sys);
574  sys_qunlock(sys);
575  sys_unlock(sys);
576 }
577 
578 M0_INTERNAL bool m0_addb2_net__is_not_locked(const struct m0_addb2_net *net);
579 M0_INTERNAL bool
581 
587 static void sys_lock(struct m0_addb2_sys *sys)
588 {
590 
591  /*
592  * Assert lock ordering: queue lock, net lock and storage lock nest
593  * within sys lock.
594  */
596  M0_PRE(ergo(sys->sy_net != NULL,
598  M0_PRE(ergo(sys->sy_stor != NULL,
600  /*
601  * Clear the addb2 machine, associated with the current
602  * thread. This avoids addb2 re-entrancy and dead-locks. Do this
603  * outside of the lock, just in case m0_mutex_lock() makes addb2
604  * calls.
605  *
606  * The machine is restored in sys_unlock().
607  */
609  m0_mutex_lock(&sys->sy_lock);
610  M0_ASSERT(sys->sy_stash == NULL);
611  sys->sy_stash = cur;
612  M0_ASSERT(sys_invariant(sys));
613 }
614 
615 static void sys_unlock(struct m0_addb2_sys *sys)
616 {
617  struct m0_addb2_mach *cur = sys->sy_stash;
618 
619  M0_ASSERT(sys_invariant(sys));
620 
621  sys->sy_stash = NULL;
622  m0_mutex_unlock(&sys->sy_lock);
624 }
625 
631 static void sys_qlock(struct m0_addb2_sys *sys)
632 {
633  m0_mutex_lock(&sys->sy_qlock);
635 }
636 
642 static void sys_qunlock(struct m0_addb2_sys *sys)
643 {
645  m0_mutex_unlock(&sys->sy_qlock);
646 }
647 
648 static void net_idle(struct m0_addb2_net *net, void *datum)
649 {
650  struct m0_addb2_sys *sys = datum;
651  m0_semaphore_up(&sys->sy_wait);
652 }
653 
654 static void stor_idle(struct m0_addb2_storage *stor)
655 {
657  m0_semaphore_up(&sys->sy_wait);
658 }
659 
660 static m0_bcount_t sys_size(const struct m0_addb2_sys *sys)
661 {
662  return mach_tlist_length(&sys->sy_pool) +
663  mach_tlist_length(&sys->sy_granted) +
664  mach_tlist_length(&sys->sy_moribund) +
665  mach_tlist_length(&sys->sy_deathrow);
666 }
667 
668 static const struct m0_addb2_mach_ops sys_mach_ops = {
670  .apo_idle = &sys_idle
671 };
672 
673 static const struct m0_addb2_storage_ops sys_stor_ops = {
674  .sto_idle = &stor_idle
675 };
676 
677 static bool sys_invariant(const struct m0_addb2_sys *sys)
678 {
679  return _0C(m0_mutex_is_locked(&sys->sy_lock)) &&
680  _0C(m0_thread_tls()->tls_addb2_mach == NULL) && /* sys_lock() */
681  _0C(M0_CHECK_EX(sys_size(sys) == sys->sy_total)) &&
682  _0C(sys->sy_total <= sys->sy_conf.co_pool_max);
683 }
684 
685 static bool sys_queue_invariant(const struct m0_addb2_sys *sys)
686 {
687  return _0C(m0_mutex_is_locked(&sys->sy_qlock)) &&
688  _0C(sys->sy_queued <= sys->sy_conf.co_queue_max) &&
689  _0C(M0_CHECK_EX(sys->sy_queued == m0_tl_reduce(tr, t,
690  &sys->sy_queue,
691  0, + t->o_tr.tr_nr)));
692 }
693 
694 #undef M0_TRACE_SUBSYSTEM
695 
698 /*
699  * Local variables:
700  * c-indentation-style: "K&R"
701  * c-basic-offset: 8
702  * tab-width: 8
703  * fill-column: 80
704  * scroll-step: 1
705  * End:
706  */
707 /*
708  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
709  */
struct m0_addb2_config sy_conf
Definition: sys.c:86
uint64_t id
Definition: cob.h:2380
struct m0_sm_ast_wait sy_astwait
Definition: sys.c:120
static void sys_idle(struct m0_addb2_mach *mach)
Definition: sys.c:502
static struct m0_addb2_storage * stor
Definition: storage.c:41
struct m0_addb2_storage * sy_stor
Definition: sys.c:95
M0_INTERNAL void m0_addb2_net_fini(struct m0_addb2_net *net)
Definition: net.c:142
#define M0_PRE(cond)
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
void m0_addb2_sys_net_stop(struct m0_addb2_sys *sys)
Definition: sys.c:322
static m0_bcount_t sys_size(const struct m0_addb2_sys *sys)
Definition: sys.c:660
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
struct m0_tl sy_pool
Definition: sys.c:124
void m0_addb2_sys_sm_stop(struct m0_addb2_sys *sys)
Definition: sys.c:384
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
#define ergo(a, b)
Definition: misc.h:293
void m0_addb2_counter_add(struct m0_addb2_counter *counter, uint64_t label, int idx)
Definition: counter.c:48
void(* sa_cb)(struct m0_sm_group *grp, struct m0_sm_ast *)
Definition: sm.h:506
M0_INTERNAL void m0_list_init(struct m0_list *head)
Definition: list.c:29
void m0_addb2_sys_sm_start(struct m0_addb2_sys *sys)
Definition: sys.c:377
struct m0_addb2_mach * tls_addb2_mach
Definition: thread.h:68
static struct m0_sm_group * grp
Definition: bytecount.c:38
#define M0_LOG(level,...)
Definition: trace.h:167
M0_INTERNAL void m0_sm_ast_wait(struct m0_sm_ast_wait *wait)
Definition: sm.c:950
M0_INTERNAL bool m0_mutex_is_not_locked(const struct m0_mutex *mutex)
Definition: mutex.c:101
static void sys_ast(struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: sys.c:550
void(* sto_idle)(struct m0_addb2_storage *stor)
Definition: storage.h:74
static const struct m0_addb2_storage_ops sys_stor_ops
Definition: sys.c:174
static void sys_qunlock(struct m0_addb2_sys *sys)
Definition: sys.c:642
static const struct m0_addb2_mach_ops sys_mach_ops
Definition: sys.c:173
struct m0_addb2_net * sy_net
Definition: sys.c:99
void m0_addb2_mach_fini(struct m0_addb2_mach *mach)
Definition: addb2.c:560
M0_INTERNAL void m0_list_del(struct m0_list_link *old)
Definition: list.c:147
M0_INTERNAL void * m0_addb2_storage_cookie(const struct m0_addb2_storage *stor)
Definition: kaddb2.c:57
M0_INTERNAL void m0_sm_ast_wait_init(struct m0_sm_ast_wait *wait, struct m0_mutex *ch_guard)
Definition: sm.c:903
struct m0_tlink s_linkage
Definition: addb2.h:314
M0_INTERNAL void m0_addb2_storage_stop(struct m0_addb2_storage *stor)
Definition: kaddb2.c:66
void m0_addb2_sys_attach(struct m0_addb2_sys *sys, struct m0_addb2_sys *src)
Definition: sys.c:408
Definition: conf.py:1
static struct m0_addb2_mach * mach
Definition: storage.c:42
uint64_t m0_bcount_t
Definition: types.h:77
unsigned co_pool_max
Definition: sys.h:126
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
Definition: sm.h:504
M0_INTERNAL bool m0_addb2_net__is_not_locked(const struct m0_addb2_net *net)
Definition: net.c:266
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
M0_INTERNAL bool m0_addb2_storage__is_not_locked(const struct m0_addb2_storage *stor)
Definition: kaddb2.c:70
bool aw_allowed
Definition: sm.h:839
unsigned co_pool_min
Definition: sys.h:122
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL void m0_addb2__mach_print(const struct m0_addb2_mach *m)
Definition: addb2.c:1139
void(* m0_addb2__sys_submit_trap)(struct m0_addb2_sys *sys, struct m0_addb2_trace_obj *obj)
Definition: sys.c:469
const char * location
Definition: storage.c:50
M0_INTERNAL struct m0_addb2_net * m0_addb2_net_init(void)
Definition: net.c:128
struct m0_addb2_trace o_tr
Definition: addb2.h:451
#define m0_tl_endfor
Definition: tlist.h:700
#define M0_CHECK_EX(cond)
static int head(struct m0_sm *mach)
Definition: sm.c:468
M0_INTERNAL struct m0_thread_tls * m0_thread_tls(void)
Definition: kthread.c:67
struct m0_tl sy_deathrow
Definition: sys.c:136
static struct m0_sm_ast ast[NR]
Definition: locality.c:44
struct m0_addb2_mach * sy_stash
Definition: sys.c:153
void m0_addb2_trace_done(const struct m0_addb2_trace *ctrace)
Definition: addb2.c:650
M0_INTERNAL void m0_addb2_storage_fini(struct m0_addb2_storage *stor)
Definition: kaddb2.c:63
return M0_ERR(-EOPNOTSUPP)
void m0_addb2_sys_fini(struct m0_addb2_sys *sys)
Definition: sys.c:214
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
#define m0_tl_teardown(name, head, obj)
Definition: tlist.h:708
void m0_addb2_sys_detach(struct m0_addb2_sys *sys)
Definition: sys.c:416
void(* m0_addb2__sys_ast_trap)(struct m0_addb2_sys *sys)
Definition: sys.c:545
m0_bcount_t sy_total
Definition: sys.c:140
int m0_addb2_sys_init(struct m0_addb2_sys **out, const struct m0_addb2_config *conf)
Definition: sys.c:176
#define M0_ASSERT(cond)
struct crate_conf * conf
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
Definition: mutex.c:95
struct m0_sm_ast sy_ast
Definition: sys.c:119
void m0_addb2_mach_stop(struct m0_addb2_mach *mach)
Definition: addb2.c:630
static struct m0_thread t[8]
Definition: service_ut.c:1230
static int counter
Definition: mutex.c:32
Definition: tlist.h:251
static void sys_post(struct m0_addb2_sys *sys)
Definition: sys.c:481
struct m0_tl sy_moribund
Definition: sys.c:132
unsigned co_queue_max
Definition: sys.h:118
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
int m0_addb2_sys_submit(struct m0_addb2_sys *sys, struct m0_addb2_trace_obj *obj)
Definition: sys.c:392
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
#define M0_POST(cond)
struct m0_tl sy_granted
Definition: sys.c:128
struct m0_sm_ast * sa_next
Definition: sm.h:509
static void net_idle(struct m0_addb2_net *net, void *datum)
Definition: sys.c:648
int(* apo_submit)(struct m0_addb2_mach *mach, struct m0_addb2_trace_obj *tobj)
Definition: addb2.h:368
M0_INTERNAL int m0_addb2_net_submit(struct m0_addb2_net *net, struct m0_addb2_trace_obj *obj)
Definition: net.c:204
struct m0_rpc_conn conn
Definition: fsync.c:96
M0_INTERNAL bool m0_list_is_empty(const struct m0_list *head)
Definition: list.c:42
static void sys_lock(struct m0_addb2_sys *sys)
Definition: sys.c:587
int m0_addb2_sys_net_start_with(struct m0_addb2_sys *sys, struct m0_tl *head)
Definition: sys.c:329
static void stor_idle(struct m0_addb2_storage *stor)
Definition: sys.c:654
#define PRId64
Definition: types.h:57
M0_INTERNAL struct m0_locality * m0_locality_here(void)
Definition: locality.c:146
struct m0_mutex sy_qlock
Definition: sys.c:118
Definition: list.h:72
struct m0_addb2_sensor co_sensor
Definition: counter.h:55
M0_INTERNAL int m0_addb2_net_add(struct m0_addb2_net *net, struct m0_rpc_conn *conn)
Definition: net.c:166
static void stor_stop(struct m0_addb2_sys *sys)
Definition: sys.c:529
M0_INTERNAL void m0_sm_ast_wait_post(struct m0_sm_ast_wait *wait, struct m0_sm_group *grp, struct m0_sm_ast *ast)
Definition: sm.c:961
struct m0_addb2_mach * m0_addb2_sys_get(struct m0_addb2_sys *sys)
Definition: sys.c:272
M0_INTERNAL struct m0_addb2_storage * m0_addb2_storage_init(const char *location, uint64_t key, bool mkfs, bool force, const struct m0_addb2_storage_ops *ops, m0_bcount_t size, void *cookie)
Definition: kaddb2.c:42
#define M0_CNT_INC(cnt)
Definition: arith.h:226
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
void m0_addb2_sys_counter_add(struct m0_addb2_sys *sys, struct m0_addb2_counter *counter, uint64_t id)
Definition: sys.c:425
struct m0_list_link t_link
Definition: tlist.h:266
void * m0_addb2_mach_cookie(const struct m0_addb2_mach *mach)
Definition: addb2.c:645
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
#define PRIi64
Definition: types.h:59
static void sys_balance(struct m0_addb2_sys *sys)
Definition: sys.c:442
static void net_stop(struct m0_addb2_sys *sys)
Definition: sys.c:515
m0_bcount_t sy_queued
Definition: sys.c:111
int m0_addb2_sys_stor_start(struct m0_addb2_sys *sys, const char *location, uint64_t key, bool mkfs, bool force, m0_bcount_t size)
Definition: sys.c:357
struct m0_tl sy_queue
Definition: sys.c:107
M0_INTERNAL void m0_sm_ast_wait_fini(struct m0_sm_ast_wait *wait)
Definition: sm.c:910
M0_INTERNAL int m0_addb2_storage_submit(struct m0_addb2_storage *stor, struct m0_addb2_trace_obj *obj)
Definition: kaddb2.c:50
m0_bcount_t size
Definition: di.c:39
#define _0C(exp)
Definition: assert.h:311
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
struct m0_semaphore sy_wait
Definition: sys.c:144
static int sys_submit(struct m0_addb2_mach *mach, struct m0_addb2_trace_obj *obj)
Definition: sys.c:472
int m0_addb2_sys_net_start(struct m0_addb2_sys *sys)
Definition: sys.c:312
#define M0_CNT_DEC(cnt)
Definition: arith.h:219
#define M0_ASSERT_INFO(cond, fmt,...)
M0_INTERNAL void m0_addb2_net_stop(struct m0_addb2_net *net, void(*callback)(struct m0_addb2_net *, void *), void *datum)
Definition: net.c:225
static struct m0_addb2_net * net
Definition: net.c:27
void m0_addb2_sys_put(struct m0_addb2_sys *sys, struct m0_addb2_mach *m)
Definition: sys.c:295
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
#define out(...)
Definition: gen.c:41
static void sys_qlock(struct m0_addb2_sys *sys)
Definition: sys.c:631
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
static struct m0_list_link * m0_list_first(const struct m0_list *head)
Definition: list.h:191
M0_INTERNAL void m0_list_add_tail(struct m0_list *head, struct m0_list_link *new)
Definition: list.c:119
uint64_t tr_nr
Definition: addb2.h:442
void m0_addb2_sys_stor_stop(struct m0_addb2_sys *sys)
Definition: sys.c:370
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
static void sys_unlock(struct m0_addb2_sys *sys)
Definition: sys.c:615
void m0_free(void *data)
Definition: memory.c:146
Definition: mutex.h:47
struct m0_list sy_counters
Definition: sys.c:148
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
struct m0_pdclust_src_addr src
Definition: fd.c:108
M0_INTERNAL void m0_sm_ast_wait_signal(struct m0_sm_ast_wait *wait)
Definition: sm.c:985
static bool sys_queue_invariant(const struct m0_addb2_sys *sys)
Definition: sys.c:685
struct m0_mutex sy_lock
Definition: sys.c:91
void m0_addb2_mach_wait(struct m0_addb2_mach *mach)
Definition: addb2.c:639
Definition: trace.h:478
struct m0_addb2_mach * m0_addb2_mach_init(const struct m0_addb2_mach_ops *ops, void *cookie)
Definition: addb2.c:521
Definition: idx_mock.c:47
static bool sys_invariant(const struct m0_addb2_sys *sys)
Definition: sys.c:677