Motr  M0
helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 #pragma once
22 #ifndef __MOTR_CONF_HELPERS_H__
23 #define __MOTR_CONF_HELPERS_H__
24 
25 #include "conf/obj.h"
26 
27 struct m0_confc;
28 struct m0_rconfc;
29 struct m0_fid;
30 struct m0_reqh;
31 
32 struct m0_confc_args {
34  const char *ca_profile;
36  char *ca_confstr;
41 };
42 
44 M0_INTERNAL int m0_conf_device_cid_to_fid(struct m0_confc *confc, uint64_t cid,
45  struct m0_fid *out);
46 
56 M0_INTERNAL int m0_conf_pver_get(struct m0_confc *confc,
57  const struct m0_fid *pool,
58  struct m0_conf_pver **out);
59 
60 /*
61  * m0_conf_service_get() / m0_conf_sdev_get() / m0_conf_drive_get()
62  * finds conf object by its fid and returns this object opened.
63  *
64  * Caller is responsible for m0_confc_close()ing the returned object.
65  */
66 #define M0_CONF_OBJ_GETTERS \
67  X(m0_conf_service); \
68  X(m0_conf_sdev); \
69  X(m0_conf_drive)
70 
71 #define X(type) \
72 M0_INTERNAL int type ## _get(struct m0_confc *confc, \
73  const struct m0_fid *fid, \
74  struct type **out)
76 #undef X
77 
79 M0_INTERNAL int m0_conf_full_load(struct m0_conf_root *r);
80 
87 M0_INTERNAL int m0_confc_root_open(struct m0_confc *confc,
88  struct m0_conf_root **root);
89 
97 M0_INTERNAL int m0_confc_profile_open(struct m0_confc *confc,
98  const struct m0_fid *fid,
99  struct m0_conf_profile **out);
100 
109 M0_INTERNAL int m0_confc_service_find(struct m0_confc *confc,
111  const char *ep,
112  struct m0_conf_obj **result);
113 
114 M0_INTERNAL struct m0_reqh *m0_conf_obj2reqh(const struct m0_conf_obj *obj);
115 
116 M0_INTERNAL struct m0_reqh *m0_confc2reqh(const struct m0_confc *confc);
117 
118 M0_INTERNAL bool m0_conf_obj_is_pool(const struct m0_conf_obj *obj);
119 
121 M0_INTERNAL struct m0_conf_pver **m0_conf_pvers(const struct m0_conf_obj *obj);
122 
123 /* XXX TODO: Move to motr/ha.c as a static function. */
124 M0_INTERNAL bool m0_conf_service_is_top_rms(const struct m0_conf_service *svc);
125 
135 M0_INTERNAL bool m0_disk_is_of_type(const struct m0_conf_obj *obj,
136  uint64_t svc_types);
137 M0_INTERNAL bool m0_is_cas_disk(const struct m0_conf_obj *obj);
138 M0_INTERNAL bool m0_is_ios_disk(const struct m0_conf_obj *obj);
139 
149 M0_INTERNAL int m0_conf_devices_count(struct m0_confc *confc,
150  uint64_t svc_types,
151  uint32_t *nr_devices);
152 
153 M0_INTERNAL void m0_confc_expired_cb(struct m0_rconfc *rconfc);
154 M0_INTERNAL void m0_confc_ready_cb(struct m0_rconfc *rconfc);
155 
160 M0_INTERNAL bool m0_conf_service_ep_is_known(const struct m0_conf_obj *svc_obj,
161  const char *ep_addr);
162 
166 M0_INTERNAL int m0_conf_process2service_get(struct m0_confc *confc,
167  const struct m0_fid *process_fid,
169  struct m0_fid *sfid);
170 
171 /* --------------------------------- >8 --------------------------------- */
172 
188 M0_INTERNAL int m0_conf_objs_ha_update(struct m0_ha_nvec *nvec);
189 
193 M0_INTERNAL int m0_conf_obj_ha_update(const struct m0_fid *obj_fid);
194 
202 M0_INTERNAL int m0_conf_confc_ha_update(struct m0_confc *confc);
203 
211 M0_INTERNAL int m0_conf_confc_ha_update_async(struct m0_confc *confc,
212  struct m0_ha_nvec *nvec,
213  struct m0_chan *chan);
214 
215 #endif /* __MOTR_CONF_HELPERS_H__ */
struct m0_sm_group * ca_group
Definition: helpers.h:38
M0_INTERNAL int m0_conf_confc_ha_update(struct m0_confc *confc)
Definition: helpers.c:658
m0_conf_service_type
Definition: schema.h:194
static const char * ep_addr
Definition: rpc_machine.c:35
char * ca_confstr
Definition: helpers.h:36
M0_INTERNAL bool m0_is_cas_disk(const struct m0_conf_obj *obj)
Definition: helpers.c:440
static struct foo * obj
Definition: tlist.c:302
M0_INTERNAL int m0_confc_service_find(struct m0_confc *confc, enum m0_conf_service_type stype, const char *ep, struct m0_conf_obj **result)
Definition: helpers.c:304
struct m0_fid fid
Definition: di.c:46
M0_INTERNAL int m0_conf_objs_ha_update(struct m0_ha_nvec *nvec)
Definition: helpers.c:557
Definition: sock.c:754
struct m0_conf_root * root
Definition: note.c:50
M0_INTERNAL int m0_conf_pver_get(struct m0_confc *confc, const struct m0_fid *pool, struct m0_conf_pver **out)
Definition: helpers.c:71
M0_INTERNAL bool m0_is_ios_disk(const struct m0_conf_obj *obj)
Definition: helpers.c:435
M0_INTERNAL bool m0_conf_service_is_top_rms(const struct m0_conf_service *svc)
Definition: helpers.c:319
M0_INTERNAL bool m0_conf_service_ep_is_known(const struct m0_conf_obj *svc_obj, const char *ep_addr)
Definition: helpers.c:197
static const struct socktype stype[]
Definition: sock.c:1156
M0_INTERNAL int m0_conf_confc_ha_update_async(struct m0_confc *confc, struct m0_ha_nvec *nvec, struct m0_chan *chan)
Definition: helpers.c:606
M0_INTERNAL int m0_conf_device_cid_to_fid(struct m0_confc *confc, uint64_t cid, struct m0_fid *out)
Definition: helpers.c:100
static struct m0_confc * confc
Definition: file.c:94
M0_INTERNAL struct m0_reqh * m0_confc2reqh(const struct m0_confc *confc)
Definition: helpers.c:342
M0_INTERNAL bool m0_disk_is_of_type(const struct m0_conf_obj *obj, uint64_t svc_types)
Definition: helpers.c:418
Definition: reqh.h:94
#define M0_CONF_OBJ_GETTERS
Definition: helpers.h:66
Definition: chan.h:229
M0_INTERNAL int m0_conf_full_load(struct m0_conf_root *r)
Definition: helpers.c:165
M0_INTERNAL int m0_conf_process2service_get(struct m0_confc *confc, const struct m0_fid *process_fid, enum m0_conf_service_type stype, struct m0_fid *sfid)
Definition: helpers.c:518
M0_INTERNAL int m0_confc_root_open(struct m0_confc *confc, struct m0_conf_root **root)
Definition: helpers.c:219
struct m0_rpc_machine * ca_rmach
Definition: helpers.h:40
static struct m0_pool pool
Definition: iter_ut.c:58
static struct m0_chan chan[RDWR_REQUEST_MAX]
Definition: fid.h:38
static int r[NR]
Definition: thread.c:46
M0_INTERNAL struct m0_conf_pver ** m0_conf_pvers(const struct m0_conf_obj *obj)
Definition: helpers.c:400
static struct m0_net_test_service svc
Definition: service.c:34
M0_INTERNAL int m0_confc_profile_open(struct m0_confc *confc, const struct m0_fid *fid, struct m0_conf_profile **out)
Definition: helpers.c:234
M0_INTERNAL bool m0_conf_obj_is_pool(const struct m0_conf_obj *obj)
Definition: helpers.c:66
static struct m0_rconfc * rconfc(struct m0_client *m0c)
Definition: client_init.c:310
M0_INTERNAL struct m0_reqh * m0_conf_obj2reqh(const struct m0_conf_obj *obj)
Definition: helpers.c:351
#define out(...)
Definition: gen.c:41
const char * ca_profile
Definition: helpers.h:34
M0_INTERNAL void m0_confc_expired_cb(struct m0_rconfc *rconfc)
Definition: helpers.c:465
M0_INTERNAL int m0_conf_devices_count(struct m0_confc *confc, uint64_t svc_types, uint32_t *nr_devices)
Definition: helpers.c:450
static const char * process_fid
Definition: idx_dix.c:73
M0_INTERNAL void m0_confc_ready_cb(struct m0_rconfc *rconfc)
Definition: helpers.c:488
M0_INTERNAL int m0_conf_obj_ha_update(const struct m0_fid *obj_fid)
Definition: helpers.c:587