Motr  M0
stubs.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 "lib/errno.h" /* EINVAL */
24 #include "lib/memory.h" /* m0_alloc() */
25 #include "be/domain.h" /* m0_be_domain_cfg */
26 #include "be/tx.h" /* m0_be_tx_state */
27 #include "be/seg_internal.h" /* m0_be_seg_hdr */
28 
29 #include "be/ut/helper.h" /* m0_be_ut_backend, m0_be_ut_seg */
30 
31 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_BE
32 #include "lib/trace.h"
33 
34 struct m0_be_btree;
35 struct m0_be_btree_kv_ops;
36 struct m0_be_btree_cursor;
37 struct m0_be_queue;
38 struct m0_buf;
39 
40 /* fake segment header. */
41 static struct m0_be_seg_hdr khdr;
42 
43 M0_INTERNAL void m0_be_alloc(struct m0_be_allocator *a,
44  struct m0_be_tx *tx,
45  struct m0_be_op *op,
46  void **ptr,
48 {
49  *ptr = m0_alloc(size);
50 }
51 
52 M0_INTERNAL void m0_be_alloc_aligned(struct m0_be_allocator *a,
53  struct m0_be_tx *tx,
54  struct m0_be_op *op,
55  void **ptr,
57  unsigned shift,
58  uint64_t zonemask)
59 {
60  m0_be_alloc(a, tx, op, ptr, size);
61 }
62 
63 M0_INTERNAL void m0_be_allocator_credit(struct m0_be_allocator *a,
64  enum m0_be_allocator_op optype,
66  unsigned shift,
67  struct m0_be_tx_credit *accum)
68 {
69 }
70 
71 M0_INTERNAL void m0_be_free(struct m0_be_allocator *a,
72  struct m0_be_tx *tx,
73  struct m0_be_op *op,
74  void *ptr)
75 {
76  m0_free(ptr);
77 }
78 
79 M0_INTERNAL void m0_be_free_aligned(struct m0_be_allocator *a,
80  struct m0_be_tx *tx,
81  struct m0_be_op *op,
82  void *ptr)
83 {
84  m0_be_free(a, tx, op, ptr);
85 }
86 
87 M0_INTERNAL void m0_be_op_init(struct m0_be_op *op)
88 {
89  op->bo_sm.sm_state = M0_BOS_INIT;
90 }
91 
92 M0_INTERNAL void m0_be_op_fini(struct m0_be_op *op)
93 {
94 }
95 
96 M0_INTERNAL void m0_be_op_wait(struct m0_be_op *op)
97 {
98 }
99 
100 M0_INTERNAL void m0_be_op_active(struct m0_be_op *op)
101 {
102 }
103 
104 M0_INTERNAL void m0_be_op_done(struct m0_be_op *op)
105 {
106 }
107 
108 M0_INTERNAL bool m0_be_op_is_done(struct m0_be_op *op)
109 {
110  return true;
111 }
112 
113 M0_INTERNAL struct m0_be_allocator *m0_be_seg_allocator(struct m0_be_seg *seg)
114 {
115  return NULL;
116 }
117 
118 M0_INTERNAL void m0_be_seg_init(struct m0_be_seg *seg,
119  struct m0_stob *stob,
120  struct m0_be_domain *dom,
121  uint64_t seg_id)
122 {
123  seg->bs_stob = stob;
124  seg->bs_domain = dom;
125  seg->bs_id = seg_id;
126 }
127 
128 M0_INTERNAL void m0_be_seg_fini(struct m0_be_seg *seg)
129 {
130 }
131 
132 M0_INTERNAL int m0_be_seg_open(struct m0_be_seg *seg)
133 {
134  seg->bs_size = sizeof khdr;
135  seg->bs_addr = &khdr;
137  return 0;
138 }
139 
140 M0_INTERNAL void m0_be_seg_close(struct m0_be_seg *seg)
141 {
142 }
143 
144 M0_INTERNAL bool m0_be_seg_contains(const struct m0_be_seg *seg,
145  const void *addr)
146 {
147  return true;
148 }
149 
150 M0_INTERNAL void m0_be_tx_init(struct m0_be_tx *tx,
151  uint64_t tid,
152  struct m0_be_domain *dom,
153  struct m0_sm_group *sm_group,
154  m0_be_tx_cb_t persistent,
155  m0_be_tx_cb_t discarded,
156  void (*filler)(struct m0_be_tx *tx,
157  void *payload),
158  void *datum)
159 {
161 }
162 
163 M0_INTERNAL void m0_be_tx_fini(struct m0_be_tx *tx)
164 {
165 }
166 
167 M0_INTERNAL void m0_be_tx_get(struct m0_be_tx *tx)
168 {
169 }
170 
171 M0_INTERNAL void m0_be_tx_put(struct m0_be_tx *tx)
172 {
173 }
174 
175 M0_INTERNAL void m0_be_tx_prep(struct m0_be_tx *tx,
176  const struct m0_be_tx_credit *credit)
177 {
178 }
179 
180 M0_INTERNAL void m0_be_tx_payload_prep(struct m0_be_tx *tx, m0_bcount_t size)
181 {
182 }
183 
184 M0_INTERNAL void m0_be_tx_open(struct m0_be_tx *tx)
185 {
187 }
188 
189 M0_INTERNAL void
190 m0_be_tx_capture(struct m0_be_tx *tx, const struct m0_be_reg *reg)
191 {
192 }
193 
194 M0_INTERNAL void m0_be_tx_close(struct m0_be_tx *tx)
195 {
196  tx->t_sm.sm_state = M0_BTS_DONE;
197 }
198 
199 M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
200 {
201  m0_be_tx_open(tx);
202  return 0;
203 }
204 
205 M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)
206 {
207  m0_be_tx_close(tx);
208 }
209 
210 M0_INTERNAL enum m0_be_tx_state m0_be_tx_state(const struct m0_be_tx *tx)
211 {
212  return tx->t_sm.sm_state;
213 }
214 
215 M0_INTERNAL int m0_be_tx_timedwait(struct m0_be_tx *tx, uint64_t states,
216  m0_time_t deadline)
217 {
218  return 0;
219 }
220 
221 M0_INTERNAL bool m0_be_seg__invariant(const struct m0_be_seg *seg)
222 {
223  return true;
224 }
225 
226 /* UT stubs */
228 {
229 }
230 
232  const struct m0_be_domain_cfg *cfg,
233  bool mkfs)
234 {
235  return 0;
236 }
237 
239 {
240 }
241 
243 {
244 }
245 
247  struct m0_be_ut_backend *ut_be)
248 {
249 }
250 
252  struct m0_be_ut_backend *ut_be)
253 {
254 }
255 
257  struct m0_be_ut_backend *ut_be,
259 {
265 }
266 
268 {
270 }
271 
273 {
274 }
275 
276 struct m0_sm_group *
278 {
279  return NULL;
280 }
281 
283 {
284 }
285 
287 {
288 }
289 
290 M0_INTERNAL struct m0_be_seg *m0_be_domain_seg0_get(struct m0_be_domain *dom)
291 {
292  return NULL;
293 }
294 
295 int m0_be_tx_fol_add(struct m0_be_tx *tx, struct m0_fol_rec *rec)
296 {
297  return M0_ERR(-EINVAL);
298 }
299 
300 M0_INTERNAL void m0_be_ut_alloc(struct m0_be_ut_backend *ut_be,
301  struct m0_be_ut_seg *ut_seg,
302  void **ptr,
304 {
306 }
307 
308 M0_INTERNAL void m0_be_ut_free(struct m0_be_ut_backend *ut_be,
309  struct m0_be_ut_seg *ut_seg,
310  void *ptr)
311 {
313 }
314 
315 M0_INTERNAL void m0_be_queue_put(struct m0_be_queue *bq,
316  struct m0_be_op *op,
317  const struct m0_buf *data)
318 {
319 }
320 
321 M0_INTERNAL void m0_be_queue_lock(struct m0_be_queue *bq)
322 {
323 }
324 
325 M0_INTERNAL void m0_be_queue_unlock(struct m0_be_queue *bq)
326 {
327 }
328 
329 
330 #undef M0_TRACE_SUBSYSTEM
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg0_get(struct m0_be_domain *dom)
Definition: stubs.c:290
void * bs_addr
Definition: seg.h:71
void m0_be_ut_seg_fini(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:267
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
struct m0_be_domain * bs_domain
Definition: seg.h:82
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: stubs.c:231
void m0_be_ut_seg_reload(struct m0_be_ut_seg *ut_seg)
Definition: stubs.c:272
M0_INTERNAL enum m0_be_tx_state m0_be_tx_state(const struct m0_be_tx *tx)
Definition: stubs.c:210
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_be_seg_fini(struct m0_be_seg *seg)
Definition: stubs.c:128
M0_INTERNAL int m0_be_tx_timedwait(struct m0_be_tx *tx, uint64_t states, m0_time_t deadline)
Definition: stubs.c:215
m0_be_tx_state
Definition: tx.h:214
uint64_t bs_id
Definition: seg.h:67
uint64_t m0_time_t
Definition: time.h:37
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_bcount_t bs_size
Definition: seg.h:69
Allocator.
Definition: alloc.h:132
struct m0_bufvec data
Definition: di.c:40
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
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: stubs.c:256
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL bool m0_be_seg__invariant(const struct m0_be_seg *seg)
Definition: stubs.c:221
M0_INTERNAL void m0_be_alloc_aligned(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void **ptr, m0_bcount_t size, unsigned shift, uint64_t zonemask)
Definition: stubs.c:52
M0_INTERNAL void m0_be_seg_close(struct m0_be_seg *seg)
Definition: stubs.c:140
op
Definition: libdemo.c:64
void m0_be_ut_seg_allocator_fini(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be)
Definition: stubs.c:251
Definition: buf.h:37
void m0_be_ut_backend_cfg_default(struct m0_be_domain_cfg *cfg)
Definition: stubs.c:227
struct m0_be_ut_backend ut_be
Definition: ad.c:72
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_be_queue_unlock(struct m0_be_queue *bq)
Definition: stubs.c:325
Definition: stob.h:163
static struct m0_stob * stob
Definition: storage.c:39
#define M0_ASSERT(cond)
M0_INTERNAL struct m0_be_allocator * m0_be_seg_allocator(struct m0_be_seg *seg)
Definition: stubs.c:113
M0_INTERNAL void m0_be_queue_put(struct m0_be_queue *bq, struct m0_be_op *op, const struct m0_buf *data)
Definition: stubs.c:315
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: stubs.c:43
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL int m0_be_tx_open_sync(struct m0_be_tx *tx)
Definition: stubs.c:199
m0_be_allocator_op
Definition: alloc.h:196
void m0_be_ut_backend_init(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:238
void m0_be_ut_seg_allocator_init(struct m0_be_ut_seg *ut_seg, struct m0_be_ut_backend *ut_be)
Definition: stubs.c:246
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_be_tx_close(struct m0_be_tx *tx)
Definition: stubs.c:194
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: stubs.c:300
Definition: xcode.h:73
struct m0_sm_group * m0_be_ut_backend_sm_group_lookup(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:277
M0_INTERNAL void m0_be_op_done(struct m0_be_op *op)
Definition: stubs.c:104
M0_INTERNAL void m0_be_tx_get(struct m0_be_tx *tx)
Definition: stubs.c:167
struct m0_sm t_sm
Definition: tx.h:281
Definition: seg.h:66
Definition: seg.h:142
struct m0_be_domain but_dom
Definition: helper.h:47
M0_INTERNAL bool m0_be_seg_contains(const struct m0_be_seg *seg, const void *addr)
Definition: stubs.c:144
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
M0_INTERNAL void m0_be_op_active(struct m0_be_op *op)
Definition: stubs.c:100
M0_INTERNAL void m0_be_free(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void *ptr)
Definition: stubs.c:71
int bs_state
Definition: seg.h:83
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL void m0_be_tx_open(struct m0_be_tx *tx)
Definition: stubs.c:184
void m0_be_ut_tx_init(struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be)
Definition: stubs.c:286
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL void m0_be_op_fini(struct m0_be_op *op)
Definition: stubs.c:92
void m0_be_ut_backend_fini(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:242
M0_INTERNAL void m0_be_free_aligned(struct m0_be_allocator *a, struct m0_be_tx *tx, struct m0_be_op *op, void *ptr)
Definition: stubs.c:79
M0_INTERNAL void m0_be_queue_lock(struct m0_be_queue *bq)
Definition: stubs.c:321
M0_INTERNAL void m0_be_tx_put(struct m0_be_tx *tx)
Definition: stubs.c:171
M0_INTERNAL int m0_be_seg_open(struct m0_be_seg *seg)
Definition: stubs.c:132
static struct m0_be_seg_hdr khdr
Definition: stubs.c:41
M0_INTERNAL void m0_be_ut_free(struct m0_be_ut_backend *ut_be, struct m0_be_ut_seg *ut_seg, void *ptr)
Definition: stubs.c:308
static struct m0_be_seg * seg
Definition: btree.c:40
struct m0_stob * bs_stob
Definition: seg.h:68
M0_INTERNAL void m0_be_tx_capture(struct m0_be_tx *tx, const struct m0_be_reg *reg)
Definition: stubs.c:190
M0_INTERNAL void m0_be_tx_payload_prep(struct m0_be_tx *tx, m0_bcount_t size)
Definition: stubs.c:180
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: stubs.c:63
Definition: op.h:74
int m0_be_tx_fol_add(struct m0_be_tx *tx, struct m0_fol_rec *rec)
Definition: stubs.c:295
M0_INTERNAL void m0_be_op_init(struct m0_be_op *op)
Definition: stubs.c:87
void m0_free(void *data)
Definition: memory.c:146
Definition: op.h:57
uint32_t sm_state
Definition: sm.h:307
void(* m0_be_tx_cb_t)(const struct m0_be_tx *tx)
Definition: tx.h:277
M0_INTERNAL bool m0_be_op_is_done(struct m0_be_op *op)
Definition: stubs.c:108
static struct m0_sm_state_descr states[C_NR]
Definition: sm.c:512
void m0_be_ut_backend_thread_exit(struct m0_be_ut_backend *ut_be)
Definition: stubs.c:282
M0_INTERNAL void m0_be_op_wait(struct m0_be_op *op)
Definition: stubs.c:96
M0_INTERNAL void m0_be_tx_close_sync(struct m0_be_tx *tx)
Definition: stubs.c:205
const uint64_t payload[]
Definition: base.c:65
Definition: tx.h:280