Motr  M0
domain.h
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 #pragma once
24 
25 #ifndef __MOTR_BE_DOMAIN_H__
26 #define __MOTR_BE_DOMAIN_H__
27 
28 #include "be/engine.h" /* m0_be_engine */
29 #include "be/seg0.h" /* m0_be_0type */
30 #include "be/log.h" /* m0_be_log_cfg */
31 #include "be/pd.h" /* m0_be_pd */
32 #include "be/log_discard.h" /* m0_be_log_discard */
33 #include "stob/stob.h" /* m0_stob_id */
34 #include "stob/stob_xc.h"
35 
36 #include "lib/tlist.h" /* m0_tl */
37 #include "module/module.h"
38 
64 struct m0_stob_id;
65 struct m0_be_tx;
66 struct m0_be_0type;
67 struct m0_be_log;
68 
70  uint64_t bsc_stob_key;
73  void *bsc_addr;
74  const char *bsc_stob_create_cfg;
75 } M0_XCA_RECORD M0_XCA_DOMAIN(be);
76 
81  const struct m0_be_0type **bc_0types;
82  unsigned bc_0types_nr;
97  uint64_t bc_seg0_stob_key;
104 
105  /*
106  * Next fields are for mkfs mode only.
107  * They are completely ignored in normal mode.
108  */
109 
128  unsigned bc_seg_nr;
131 };
132 
133 struct m0_be_domain {
141  struct m0_tl bd_0types;
144  struct m0_tl bd_segs;
149  struct m0_be_pd bd_pd;
151 };
152 
154 enum {
174 };
175 /*
176  * To iterate segment objects
177  * */
178 M0_INTERNAL int m0_be_segobj_opt_next(struct m0_be_seg *dict,
179  const struct m0_be_0type *objtype,
180  struct m0_buf *opt,
181  char **suffix);
182 M0_INTERNAL int m0_be_segobj_opt_begin(struct m0_be_seg *dict,
183  const struct m0_be_0type *objtype,
184  struct m0_buf *opt,
185  char **suffix);
186 M0_INTERNAL void m0_be_domain_module_setup(struct m0_be_domain *dom,
187  const struct m0_be_domain_cfg *cfg);
188 M0_INTERNAL void
189 be_domain_log_cleanup(const char *stob_domain_location,
190  struct m0_be_log_cfg *log_cfg, bool create);
191 
192 /*
193  * Temporary solution until segment I/O is implemented using direct I/O.
194  */
195 M0_INTERNAL void
196 m0_be_domain_cleanup_by_location(const char *stob_domain_location);
197 
198 M0_INTERNAL struct m0_be_tx *m0_be_domain_tx_find(struct m0_be_domain *dom,
199  uint64_t id);
200 
201 M0_INTERNAL struct m0_be_engine *m0_be_domain_engine(struct m0_be_domain *dom);
202 M0_INTERNAL
204 /* TODO remove the function after BE log becomes a part of BE domain */
205 M0_INTERNAL struct m0_be_log *m0_be_domain_log(struct m0_be_domain *dom);
206 M0_INTERNAL bool m0_be_domain_is_locked(const struct m0_be_domain *dom);
207 
211 M0_INTERNAL struct m0_be_seg *m0_be_domain_seg(const struct m0_be_domain *dom,
212  const void *addr);
216 M0_INTERNAL struct m0_be_seg *
217 m0_be_domain_seg_by_id(const struct m0_be_domain *dom, uint64_t id);
218 
222 M0_INTERNAL struct m0_be_seg *
224 
225 M0_INTERNAL void
227  const struct m0_be_0type_seg_cfg *seg_cfg,
228  struct m0_be_tx_credit *cred);
229 M0_INTERNAL void m0_be_domain_seg_destroy_credit(struct m0_be_domain *dom,
230  struct m0_be_seg *seg,
231  struct m0_be_tx_credit *cred);
232 
233 M0_INTERNAL int
235  struct m0_be_tx *tx,
236  const struct m0_be_0type_seg_cfg *seg_cfg,
237  struct m0_be_seg **out);
251 M0_INTERNAL int m0_be_domain_seg_destroy(struct m0_be_domain *dom,
252  struct m0_be_tx *tx,
253  struct m0_be_seg *seg);
254 
255 /* for internal be-usage only */
256 M0_INTERNAL void m0_be_domain__0type_register(struct m0_be_domain *dom,
257  struct m0_be_0type *type);
258 M0_INTERNAL void m0_be_domain__0type_unregister(struct m0_be_domain *dom,
259  struct m0_be_0type *type);
260 
261 M0_INTERNAL void m0_be_domain_tx_size_max(struct m0_be_domain *dom,
262  struct m0_be_tx_credit *cred,
263  m0_bcount_t *payload_size);
264 
265 M0_INTERNAL void m0_be_domain__group_limits(struct m0_be_domain *dom,
266  uint32_t *group_nr,
267  uint32_t *tx_per_group);
268 
273 M0_INTERNAL bool m0_be_domain_is_stob_log(struct m0_be_domain *dom,
274  const struct m0_stob_id *stob_id);
279 M0_INTERNAL bool m0_be_domain_is_stob_seg(struct m0_be_domain *dom,
280  const struct m0_stob_id *stob_id);
281 
290 M0_INTERNAL struct m0_be_seg *
292  void *addr);
293 
301 M0_INTERNAL bool m0_be_domain_seg_is_valid(struct m0_be_domain *dom,
302  struct m0_be_seg *seg);
303 
304 
306 #endif /* __MOTR_BE_DOMAIN_H__ */
307 
308 /*
309  * Local variables:
310  * c-indentation-style: "K&R"
311  * c-basic-offset: 8
312  * tab-width: 8
313  * fill-column: 80
314  * scroll-step: 1
315  * End:
316  */
317 /*
318  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
319  */
M0_INTERNAL void m0_be_domain_seg_create_credit(struct m0_be_domain *dom, const struct m0_be_0type_seg_cfg *seg_cfg, struct m0_be_tx_credit *cred)
Definition: domain.c:510
M0_INTERNAL void m0_be_domain__0type_unregister(struct m0_be_domain *dom, struct m0_be_0type *type)
Definition: domain.c:655
M0_INTERNAL bool m0_be_domain_is_stob_log(struct m0_be_domain *dom, const struct m0_stob_id *stob_id)
Definition: domain.c:975
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
M0_INTERNAL bool m0_be_domain_is_locked(const struct m0_be_domain *dom)
Definition: domain.c:641
struct m0_be_0type_seg_cfg bc_seg0_cfg
Definition: domain.h:120
struct m0_tl bd_0types
Definition: domain.h:141
static void create(void)
Definition: service_ut.c:546
struct m0_be_pd bd_pd
Definition: domain.h:149
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg0_get(struct m0_be_domain *dom)
Definition: domain.c:466
uint32_t bc_zone_pcnt[M0_BAP_NR]
Definition: domain.h:103
M0_INTERNAL void m0_be_domain__0type_register(struct m0_be_domain *dom, struct m0_be_0type *type)
Definition: domain.c:647
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg_by_addr(struct m0_be_domain *dom, void *addr)
Definition: domain.c:999
M0_INTERNAL bool m0_be_domain_is_stob_seg(struct m0_be_domain *dom, const struct m0_stob_id *stob_id)
Definition: domain.c:986
struct m0_be_domain_cfg bd_cfg
Definition: domain.h:135
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_stob * bd_seg0_stob
Definition: domain.h:146
Definition: buf.h:37
M0_INTERNAL struct m0_be_engine * m0_be_domain_engine(struct m0_be_domain *dom)
Definition: domain.c:461
m0_bcount_t bsc_size
Definition: domain.h:72
uint64_t bsc_stob_key
Definition: domain.h:70
const char * bsc_stob_create_cfg
Definition: domain.h:74
Definition: stob.h:163
struct m0_be_0type bd_0type_seg
Definition: domain.h:148
uint64_t bc_stob_domain_key
Definition: domain.h:116
Definition: tlist.h:251
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg(const struct m0_be_domain *dom, const void *addr)
Definition: domain.c:476
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL struct m0_be_log * m0_be_domain_log(struct m0_be_domain *dom)
Definition: domain.c:471
M0_INTERNAL void m0_be_domain_cleanup_by_location(const char *stob_domain_location)
Definition: domain.c:442
Definition: xcode.h:73
struct m0_be_seg bd_seg0
Definition: domain.h:145
const char * bc_stob_domain_cfg_init
Definition: domain.h:92
Definition: seg.h:66
M0_INTERNAL void m0_be_domain__group_limits(struct m0_be_domain *dom, uint32_t *group_nr, uint32_t *tx_per_group)
Definition: domain.c:968
struct m0_be_0type * bd_0types_allocated
Definition: domain.h:142
M0_INTERNAL bool m0_be_domain_seg_is_valid(struct m0_be_domain *dom, struct m0_be_seg *seg)
Definition: domain.c:1015
struct m0_module bd_module
Definition: domain.h:134
struct m0_be_pd_cfg bc_pd_cfg
Definition: domain.h:129
const struct m0_be_0type ** bc_0types
Definition: domain.h:81
struct m0_be_log_discard_cfg bc_log_discard_cfg
Definition: domain.h:130
struct m0_tl bd_segs
Definition: domain.h:144
struct m0_mutex bd_lock
Definition: domain.h:140
M0_INTERNAL void m0_be_domain_module_setup(struct m0_be_domain *dom, const struct m0_be_domain_cfg *cfg)
Definition: domain.c:952
struct m0_stob_domain * bd_stob_domain
Definition: domain.h:147
struct m0_be_0type_seg_cfg * bc_seg_cfg
Definition: domain.h:126
Definition: pd.h:64
M0_INTERNAL void m0_be_domain_tx_size_max(struct m0_be_domain *dom, struct m0_be_tx_credit *cred, m0_bcount_t *payload_size)
Definition: domain.c:961
void * bsc_addr
Definition: domain.h:73
uint64_t bc_seg0_stob_key
Definition: domain.h:97
const char * bc_stob_domain_location
Definition: domain.h:87
struct m0_be_domain_cfg M0_XCA_DOMAIN
struct m0_be_log_cfg bc_log
Definition: domain.h:118
static struct m0_be_seg * seg
Definition: btree.c:40
bool bsc_preallocate
Definition: domain.h:71
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg_first(const struct m0_be_domain *dom)
Definition: domain.c:486
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 int m0_be_segobj_opt_next(struct m0_be_seg *dict, const struct m0_be_0type *objtype, struct m0_buf *opt, char **suffix)
Definition: domain.c:89
Definition: log.h:261
#define out(...)
Definition: gen.c:41
const char * bc_stob_domain_cfg_create
Definition: domain.h:111
struct m0_be_engine bd_engine
Definition: domain.h:136
int type
Definition: dir.c:1031
M0_INTERNAL struct m0_be_seg * m0_be_domain_seg_by_id(const struct m0_be_domain *dom, uint64_t id)
Definition: domain.c:493
struct m0_mutex bd_engine_lock
Definition: domain.h:138
struct m0_be_log_discard bd_log_discard
Definition: domain.h:150
bool bc_mkfs_mode
Definition: domain.h:98
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
Definition: mutex.h:47
M0_INTERNAL int m0_be_segobj_opt_begin(struct m0_be_seg *dict, const struct m0_be_0type *objtype, struct m0_buf *opt, char **suffix)
Definition: domain.c:97
struct m0_be_engine_cfg bc_engine
Definition: domain.h:79
unsigned bc_seg_nr
Definition: domain.h:128
M0_INTERNAL struct m0_be_tx * m0_be_domain_tx_find(struct m0_be_domain *dom, uint64_t id)
Definition: domain.c:455
static struct m0_be_ut_backend be
Definition: service_ut.c:59
unsigned bc_0types_nr
Definition: domain.h:82
Definition: tx.h:280