Motr  M0
type.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_TYPE_H__
26 #define __MOTR_STOB_TYPE_H__
27 
28 #include "lib/tlist.h" /* m0_tl */
29 #include "lib/types.h" /* uint64_t */
30 #include "lib/mutex.h" /* m0_mutex */
31 
32 #include "fid/fid.h" /* m0_fid_type */
33 
40 struct m0_stob_domain;
41 struct m0_stob_type_ops;
42 
44 struct m0_stob_types {
45  struct m0_tl sts_stypes;
46 };
47 
48 M0_INTERNAL int m0_stob_types_init(void);
49 M0_INTERNAL void m0_stob_types_fini(void);
50 
59 struct m0_stob_type {
60  const struct m0_stob_type_ops *st_ops;
62  struct m0_tl st_domains;
66  uint64_t st_magic;
67  void *st_private;
68 };
69 
73  void (*sto_register)(struct m0_stob_type *type);
75  void (*sto_deregister)(struct m0_stob_type *type);
77  int (*sto_domain_cfg_init_parse)(const char *str_cfg_init,
78  void **cfg_init);
83  void (*sto_domain_cfg_init_free)(void *cfg_init);
85  int (*sto_domain_cfg_create_parse)(const char *str_cfg_create,
86  void **cfg_create);
91  void (*sto_domain_cfg_create_free)(void *cfg_create);
94  const char *location_data,
95  void *cfg_init,
96  struct m0_stob_domain **out);
109  const char *location_data,
110  uint64_t dom_key,
111  void *cfg_create);
114  const char *location_data);
115 };
116 
122 M0_INTERNAL void m0_stob_type_register(struct m0_stob_type *type);
124 M0_INTERNAL void m0_stob_type_deregister(struct m0_stob_type *type);
125 
127 M0_INTERNAL struct m0_stob_type *
128 m0_stob_type_by_dom_id(const struct m0_fid *id);
130 M0_INTERNAL struct m0_stob_type *m0_stob_type_by_name(const char *name);
132 M0_INTERNAL uint8_t m0_stob_type_id_by_name(const char *name);
133 
135 M0_INTERNAL uint8_t m0_stob_type_id_get(const struct m0_stob_type *type);
137 M0_INTERNAL const char *m0_stob_type_name_get(struct m0_stob_type *type);
138 
144 M0_INTERNAL void m0_stob_type__dom_add(struct m0_stob_type *type,
145  struct m0_stob_domain *dom);
151 M0_INTERNAL void m0_stob_type__dom_del(struct m0_stob_type *type,
152  struct m0_stob_domain *dom);
159 M0_INTERNAL struct m0_stob_domain *
160 m0_stob_type__dom_find(struct m0_stob_type *type, const struct m0_fid *dom_id);
161 
167 M0_INTERNAL struct m0_stob_domain *
169  const char *location);
170 
172 #endif /* __MOTR_STOB_TYPE_H__ */
173 
174 /*
175  * Local variables:
176  * c-indentation-style: "K&R"
177  * c-basic-offset: 8
178  * tab-width: 8
179  * fill-column: 80
180  * scroll-step: 1
181  * End:
182  */
183 /*
184  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
185  */
struct m0_tl st_domains
Definition: type.h:62
M0_INTERNAL struct m0_stob_type * m0_stob_type_by_dom_id(const struct m0_fid *id)
Definition: type.c:122
void(* sto_register)(struct m0_stob_type *type)
Definition: type.h:73
M0_INTERNAL void m0_stob_type_register(struct m0_stob_type *type)
Definition: type.c:144
M0_INTERNAL uint8_t m0_stob_type_id_get(const struct m0_stob_type *type)
Definition: type.c:164
M0_INTERNAL struct m0_stob_domain * m0_stob_type__dom_find(struct m0_stob_type *type, const struct m0_fid *dom_id)
Definition: type.c:191
const char * location
Definition: storage.c:50
M0_INTERNAL void m0_stob_type__dom_del(struct m0_stob_type *type, struct m0_stob_domain *dom)
Definition: type.c:182
int(* sto_domain_init)(struct m0_stob_type *type, const char *location_data, void *cfg_init, struct m0_stob_domain **out)
Definition: type.h:93
M0_INTERNAL void m0_stob_type__dom_add(struct m0_stob_type *type, struct m0_stob_domain *dom)
Definition: type.c:174
const char * name
Definition: trace.c:110
struct m0_tl sts_stypes
Definition: type.h:45
M0_INTERNAL struct m0_stob_domain * m0_stob_type__dom_find_by_location(struct m0_stob_type *type, const char *location)
Definition: type.c:204
Definition: tlist.h:251
static struct m0_stob_domain * dom
Definition: storage.c:38
struct m0_mutex st_domains_lock
Definition: type.h:63
int(* sto_domain_cfg_init_parse)(const char *str_cfg_init, void **cfg_init)
Definition: type.h:77
M0_INTERNAL uint8_t m0_stob_type_id_by_name(const char *name)
Definition: type.c:139
M0_INTERNAL void m0_stob_types_fini(void)
Definition: type.c:115
int(* sto_domain_cfg_create_parse)(const char *str_cfg_create, void **cfg_create)
Definition: type.h:85
M0_INTERNAL const char * m0_stob_type_name_get(struct m0_stob_type *type)
Definition: type.c:169
uint64_t st_magic
Definition: type.h:66
M0_INTERNAL int m0_stob_types_init(void)
Definition: type.c:94
M0_INTERNAL struct m0_stob_type * m0_stob_type_by_name(const char *name)
Definition: type.c:131
Definition: fid.h:38
void(* sto_deregister)(struct m0_stob_type *type)
Definition: type.h:75
void(* sto_domain_cfg_create_free)(void *cfg_create)
Definition: type.h:91
void(* sto_domain_cfg_init_free)(void *cfg_init)
Definition: type.h:83
int(* sto_domain_destroy)(struct m0_stob_type *type, const char *location_data)
Definition: type.h:113
struct m0_tlink st_type_linkage
Definition: type.h:65
#define out(...)
Definition: gen.c:41
int type
Definition: dir.c:1031
const struct m0_stob_type_ops * st_ops
Definition: type.h:60
void * st_private
Definition: type.h:67
Definition: mutex.h:47
M0_INTERNAL void m0_stob_type_deregister(struct m0_stob_type *type)
Definition: type.c:155
struct m0_fid_type st_fidt
Definition: type.h:61
int(* sto_domain_create)(struct m0_stob_type *type, const char *location_data, uint64_t dom_key, void *cfg_create)
Definition: type.h:108