Motr  M0
global.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 
29 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_ADDB
30 
31 #include "lib/trace.h"
32 #include "lib/uuid.h" /* m0_node_uuid */
33 #include "lib/errno.h" /* ENOMEM */
34 #include "lib/thread.h" /* m0_thread_tls */
35 #include "lib/memory.h"
36 #include "module/instance.h"
37 #include "addb2/sys.h"
38 #include "addb2/identifier.h" /* M0_AVI_THREAD */
39 #include "addb2/addb2.h"
40 
41 #define SYS() (m0_addb2_module_get()->am_sys)
42 
43 M0_INTERNAL void m0_addb2_global_thread_enter(void)
44 {
45  struct m0_addb2_sys *sys = SYS();
46  struct m0_thread_tls *tls = m0_thread_tls();
47 
49  if (sys != NULL) {
55  }
56 }
57 
58 M0_INTERNAL void m0_addb2_global_thread_leave(void)
59 {
60  struct m0_addb2_sys *sys = SYS();
61  struct m0_thread_tls *tls = m0_thread_tls();
63 
64  if (mach != NULL) {
65  M0_ASSERT(sys != NULL);
71  m0_addb2_sys_put(sys, mach);
72  }
73 }
74 
75 M0_INTERNAL int m0_addb2_global_init(void)
76 {
77  int result;
78 
79  result = m0_addb2_sys_init((struct m0_addb2_sys **)&SYS(),
80  &(struct m0_addb2_config) {
81  .co_queue_max = 4 * 1024 * 1024,
82  .co_pool_min = 1024,
83  .co_pool_max = 1024 * 1024
84  });
85  if (result == 0)
87  return result;
88 }
89 
90 M0_INTERNAL void m0_addb2_global_fini(void)
91 {
92  struct m0_addb2_sys *sys = SYS();
93 
95  if (sys != NULL)
96  m0_addb2_sys_fini(sys);
97 }
98 
99 M0_INTERNAL struct m0_addb2_sys *m0_addb2_global_get(void)
100 {
101  return SYS();
102 }
103 
104 #undef SYS
105 #undef M0_TRACE_SUBSYSTEM
106 
109 /*
110  * Local variables:
111  * c-indentation-style: "K&R"
112  * c-basic-offset: 8
113  * tab-width: 8
114  * fill-column: 80
115  * scroll-step: 1
116  * End:
117  */
118 /*
119  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
120  */
#define M0_PRE(cond)
#define NULL
Definition: misc.h:38
struct m0_addb2_mach * tls_addb2_mach
Definition: thread.h:68
#define M0_ADDB2_PUSH(id,...)
Definition: addb2.h:261
static struct m0_addb2_mach * mach
Definition: storage.c:42
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL struct m0_thread_tls * m0_thread_tls(void)
Definition: kthread.c:67
#define SYS()
Definition: global.c:41
void m0_addb2_sys_fini(struct m0_addb2_sys *sys)
Definition: sys.c:214
void m0_addb2_push(uint64_t id, int n, const uint64_t *value)
Definition: addb2.c:412
M0_INTERNAL void m0_addb2_global_thread_leave(void)
Definition: global.c:58
int m0_addb2_sys_init(struct m0_addb2_sys **out, const struct m0_addb2_config *conf)
Definition: sys.c:176
#define M0_ASSERT(cond)
#define M0_ADDB2_OBJ(obj)
Definition: addb2.h:276
M0_INTERNAL void m0_addb2_global_thread_enter(void)
Definition: global.c:43
static __thread struct m0_thread_tls * tls
Definition: uthread.c:66
struct m0_addb2_sensor tls_clock
Definition: thread.h:70
void m0_addb2_clock_add(struct m0_addb2_sensor *clock, uint64_t label, int idx)
Definition: counter.c:109
void m0_addb2_pop(uint64_t id)
Definition: addb2.c:440
struct m0_addb2_mach * m0_addb2_sys_get(struct m0_addb2_sys *sys)
Definition: sys.c:272
M0_INTERNAL struct m0_addb2_sys * m0_addb2_global_get(void)
Definition: global.c:99
M0_INTERNAL struct m0_uint128 m0_node_uuid
Definition: uuid.c:126
struct m0_thread * tls_self
Definition: thread.h:69
struct m0_thread_handle t_h
Definition: thread.h:112
void m0_addb2_sys_put(struct m0_addb2_sys *sys, struct m0_addb2_mach *m)
Definition: sys.c:295
M0_INTERNAL uint64_t m0_pid(void)
Definition: kthread.c:290
M0_INTERNAL void m0_addb2_global_fini(void)
Definition: global.c:90
M0_INTERNAL int m0_addb2_global_init(void)
Definition: global.c:75