Motr  M0
domain.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2014-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_STOB_DOMAIN_H__
26 #define __MOTR_STOB_DOMAIN_H__
27 
28 #include "lib/types.h" /* uint64_t */
29 #include "lib/tlist.h" /* m0_tlink */
30 #include "fid/fid.h" /* m0_fid */
31 
32 #include "stob/cache.h" /* m0_stob_cache */
33 
40 struct m0_stob_type;
41 struct m0_stob_domain_ops;
42 struct m0_stob;
43 struct m0_stob_id;
44 struct m0_stob_io;
45 struct m0_be_tx_credit;
46 struct m0_fid;
47 struct m0_dtx;
48 struct m0_indexvec;
49 
94  const struct m0_stob_domain_ops *sd_ops;
96  struct m0_fid sd_id;
97  char *sd_location;
102  uint64_t sd_magic;
105  void *sd_private;
106 };
107 
111  void (*sdo_fini)(struct m0_stob_domain *dom);
116  struct m0_stob *(*sdo_stob_alloc)(struct m0_stob_domain *dom,
117  const struct m0_fid *stob_fid);
124  struct m0_stob *stob);
126  int (*sdo_stob_cfg_parse)(const char *str_cfg_create,
127  void **cfg_create);
132  void (*sdo_stob_cfg_free)(void *cfg_create);
135  struct m0_stob_domain *dom,
136  const struct m0_fid *stob_fid);
139  struct m0_be_tx_credit *accum);
142  struct m0_stob_domain *dom,
143  struct m0_dtx *dtx,
144  const struct m0_fid *stob_fid,
145  void *cfg);
147  void (*sdo_stob_write_credit)(const struct m0_stob_domain *dom,
148  const struct m0_stob_io *io,
149  struct m0_be_tx_credit *accum);
150 };
151 
153 M0_INTERNAL int m0_stob_domain_init(const char *location,
154  const char *str_cfg_init,
155  struct m0_stob_domain **out);
156 M0_INTERNAL void m0_stob_domain_fini(struct m0_stob_domain *dom);
157 M0_INTERNAL bool m0_stob_domain__invariant(struct m0_stob_domain *dom);
158 
159 
169 M0_INTERNAL int m0_stob_domain_create(const char *location,
170  const char *str_cfg_init,
171  uint64_t dom_key,
172  const char *str_cfg_create,
173  struct m0_stob_domain **out);
182 M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom);
183 
197 M0_INTERNAL int m0_stob_domain_destroy_location(const char *location);
198 
208 M0_INTERNAL int m0_stob_domain_create_or_init(const char *location,
209  const char *str_cfg_init,
210  uint64_t dom_key,
211  const char *str_cfg_create,
212  struct m0_stob_domain **out);
217 M0_INTERNAL struct m0_stob_domain *
218 m0_stob_domain_find(const struct m0_fid *dom_id);
220 M0_INTERNAL struct m0_stob_domain *
223 M0_INTERNAL struct m0_stob_domain *
224 m0_stob_domain_find_by_stob_id(const struct m0_stob_id *stob_id);
225 
227 M0_INTERNAL const struct m0_fid *
230 M0_INTERNAL const char *
233 M0_INTERNAL bool m0_stob_domain_is_of_type(const struct m0_stob_domain *dom,
234  const struct m0_stob_type *dt);
240 M0_INTERNAL void m0_stob_domain__id_set(struct m0_stob_domain *dom,
241  struct m0_fid *dom_id);
242 M0_INTERNAL void m0_stob_domain__dom_id_make(struct m0_fid *dom_id,
243  uint8_t type_id,
244  uint64_t dom_container,
245  uint64_t dom_key);
246 
248 M0_INTERNAL uint8_t m0_stob_domain__type_id(const struct m0_fid *dom_id);
250 M0_INTERNAL uint64_t m0_stob_domain__dom_key(const struct m0_fid *dom_id);
251 
253 M0_INTERNAL bool m0_stob_domain__dom_key_is_valid(uint64_t dom_key);
254 
255 M0_INTERNAL struct m0_stob_cache *
257 
258 M0_INTERNAL struct m0_stob *
260  const struct m0_fid *stob_fid);
261 M0_INTERNAL void m0_stob_domain__stob_free(struct m0_stob_domain *dom,
262  struct m0_stob *stob);
264 #endif /* __MOTR_STOB_DOMAIN_H__ */
265 
266 /*
267  * Local variables:
268  * c-indentation-style: "K&R"
269  * c-basic-offset: 8
270  * tab-width: 8
271  * fill-column: 80
272  * scroll-step: 1
273  * End:
274  */
275 /*
276  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
277  */
M0_INTERNAL void m0_stob_domain__stob_free(struct m0_stob_domain *dom, struct m0_stob *stob)
Definition: stob.c:58
Definition: dtm.h:554
M0_INTERNAL uint64_t m0_stob_domain__dom_key(const struct m0_fid *dom_id)
Definition: domain.c:322
M0_INTERNAL struct m0_stob_domain * m0_stob_domain_find(const struct m0_fid *dom_id)
Definition: domain.c:278
M0_INTERNAL void m0_stob_domain__dom_id_make(struct m0_fid *dom_id, uint8_t type_id, uint64_t dom_container, uint64_t dom_key)
Definition: domain.c:327
M0_INTERNAL const struct m0_fid * m0_stob_domain_id_get(const struct m0_stob_domain *dom)
Definition: domain.c:300
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
Definition: domain.c:227
void(* sdo_stob_free)(struct m0_stob_domain *dom, struct m0_stob *stob)
Definition: domain.h:123
M0_INTERNAL bool m0_stob_domain_is_of_type(const struct m0_stob_domain *dom, const struct m0_stob_type *dt)
Definition: domain.c:349
void(* sdo_fini)(struct m0_stob_domain *dom)
Definition: domain.h:111
char * sd_location
Definition: domain.h:97
const char * location
Definition: storage.c:50
void(* sdo_stob_create_credit)(struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
Definition: domain.h:138
M0_INTERNAL struct m0_stob_domain * m0_stob_domain_find_by_location(const char *location)
Definition: domain.c:284
void(* sdo_stob_cfg_free)(void *cfg_create)
Definition: domain.h:132
M0_INTERNAL bool m0_stob_domain__dom_key_is_valid(uint64_t dom_key)
Definition: domain.c:344
M0_INTERNAL int m0_stob_domain_create(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
Definition: domain.c:217
M0_INTERNAL struct m0_stob_cache * m0_stob_domain__cache(struct m0_stob_domain *dom)
Definition: stob.c:46
Definition: stob.h:163
static struct m0_stob * stob
Definition: storage.c:39
struct m0_tlink sd_domain_linkage
Definition: domain.h:100
struct m0_stob_cache sd_cache
Definition: domain.h:103
static struct m0_stob_domain * dom
Definition: storage.c:38
int(* sdo_stob_create)(struct m0_stob *stob, struct m0_stob_domain *dom, struct m0_dtx *dtx, const struct m0_fid *stob_fid, void *cfg)
Definition: domain.h:141
Definition: io.h:285
static struct m0_stob_io io
Definition: ad.c:59
M0_INTERNAL struct m0_stob_domain * m0_stob_domain_find_by_stob_id(const struct m0_stob_id *stob_id)
Definition: domain.c:294
char * sd_location_data
Definition: domain.h:98
M0_INTERNAL void m0_stob_domain_fini(struct m0_stob_domain *dom)
Definition: domain.c:204
uint64_t sd_magic
Definition: domain.h:102
M0_INTERNAL int m0_stob_domain_destroy_location(const char *location)
Definition: domain.c:242
struct m0_fid sd_id
Definition: domain.h:96
struct m0_stob_type * sd_type
Definition: domain.h:95
M0_INTERNAL int m0_stob_domain_init(const char *location, const char *str_cfg_init, struct m0_stob_domain **out)
Definition: domain.c:195
Definition: fid.h:38
M0_INTERNAL int m0_stob_domain_create_or_init(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
Definition: domain.c:262
M0_INTERNAL const char * m0_stob_domain_location_get(const struct m0_stob_domain *dom)
Definition: domain.c:306
M0_INTERNAL struct m0_stob * m0_stob_domain__stob_alloc(struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
Definition: stob.c:52
void * sd_private
Definition: domain.h:105
M0_INTERNAL void m0_stob_domain__id_set(struct m0_stob_domain *dom, struct m0_fid *dom_id)
Definition: domain.c:311
int(* sdo_stob_cfg_parse)(const char *str_cfg_create, void **cfg_create)
Definition: domain.h:126
M0_INTERNAL bool m0_stob_domain__invariant(struct m0_stob_domain *dom)
Definition: domain.c:335
void(* sdo_stob_write_credit)(const struct m0_stob_domain *dom, const struct m0_stob_io *io, struct m0_be_tx_credit *accum)
Definition: domain.h:147
int(* sdo_stob_init)(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
Definition: domain.h:134
const struct m0_stob_domain_ops * sd_ops
Definition: domain.h:94
#define out(...)
Definition: gen.c:41
M0_INTERNAL uint8_t m0_stob_domain__type_id(const struct m0_fid *dom_id)
Definition: domain.c:317