Motr  M0
pool_machine.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-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 
22 #pragma once
23 
24 #ifndef __MOTR_POOL_MACHINE_H__
25 #define __MOTR_POOL_MACHINE_H__
26 
27 #include "format/format.h" /* m0_be_clink */
28 #include "format/format_xc.h"
29 #include "lib/tlist.h"
30 #include "lib/tlist_xc.h"
31 #include "lib/rwlock.h" /* m0_rwlock */
32 #include "conf/obj.h" /* m0_conf_pver_kind */
33 
39 /* import */
40 struct m0_sm_group;
41 struct m0_dtm;
42 struct m0_dtx;
43 struct m0_be_tx_credit;
44 struct m0_poolnode;
45 struct m0_pooldev;
46 struct m0_pool_spare_usage;
47 struct m0_pools_common;
48 struct m0_poolmach_event;
50 struct m0_confc;
51 struct m0_conf_pver;
52 struct m0_motr;
53 
60 
63 
66 
69 
72 
78 
81 
84 } M0_XCA_ENUM;
85 
86 enum {
87  /* Unused spare slot has this device index */
89 };
90 
102  uint32_t pst_nr_nodes;
103 
106 
108  uint32_t pst_nr_devices;
109 
112 
118 
120  uint32_t pst_nr_spares;
121 
127 
131  uint32_t pst_nr_failures;
132 
138 
141 
146 
152 
155 };
156 
168 struct m0_poolmach {
170 
173 
176 
179 };
180 
185 };
186 
192  uint32_t pe_type M0_XCA_FENUM(
194 
196  uint32_t pe_index;
197 
200 };
201 
209 
215 
216  uint64_t pel_magic;
217 };
218 
219 M0_INTERNAL uint32_t m0_poolmach_equeue_length(struct m0_poolmach *pm);
220 
224 M0_INTERNAL int m0_poolmach_init(struct m0_poolmach *pm,
225  struct m0_pool_version *pver,
226  uint32_t nr_nodes,
227  uint32_t nr_devices,
228  uint32_t nr_spare,
229  uint32_t max_node_failures,
230  uint32_t max_device_failures);
231 
232 M0_INTERNAL int m0_poolmach_init_by_conf(struct m0_poolmach *pm,
233  struct m0_conf_pver *pver);
234 
238 M0_INTERNAL void m0_poolmach_fini(struct m0_poolmach *pm);
239 
245 M0_INTERNAL void m0_poolmach_event_queue_apply(struct m0_poolmach *pmach);
246 
251 M0_INTERNAL void m0_poolmach_failvec_apply(struct m0_poolmach *pmach,
252  const struct m0_ha_nvec *nvec);
253 
261 M0_INTERNAL int m0_poolmach_state_transit(struct m0_poolmach *pm,
262  const struct m0_poolmach_event *event);
266 M0_INTERNAL void m0_poolmach_state_last_cancel(struct m0_poolmach *pm);
267 
274 M0_INTERNAL int m0_poolmach_device_state(struct m0_poolmach *pm,
275  uint32_t device_index,
276  enum m0_pool_nd_state *state_out);
277 
284 M0_INTERNAL int m0_poolmach_node_state(struct m0_poolmach *pm,
285  uint32_t node_index,
286  enum m0_pool_nd_state *state_out);
287 
294 M0_INTERNAL int m0_poolmach_device_node_return(struct m0_poolmach *pm,
295  uint32_t device_index,
296  struct m0_poolnode **node_out);
297 
303 M0_INTERNAL bool
305  uint32_t device_index);
306 
313 M0_INTERNAL int m0_poolmach_sns_repair_spare_query(struct m0_poolmach *pm,
314  uint32_t device_index,
315  uint32_t *spare_slot_out);
316 
325 M0_INTERNAL bool
327  uint32_t spare_slot,
328  bool check_state);
329 
336 M0_INTERNAL int m0_poolmach_sns_rebalance_spare_query(struct m0_poolmach *pm,
337  uint32_t device_index,
338  uint32_t *spare_slot_out);
339 
340 M0_INTERNAL void m0_poolmach_event_dump(const struct m0_poolmach_event *e);
341 M0_INTERNAL void m0_poolmach_event_list_dump(struct m0_poolmach *pm);
342 M0_INTERNAL void m0_poolmach_event_list_dump_locked(struct m0_poolmach *pm);
343 M0_INTERNAL void m0_poolmach_device_state_dump(struct m0_poolmach *pm);
344 M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures(struct m0_poolmach *pm);
345 
347 M0_INTERNAL int m0_poolmach_fid_to_idx(struct m0_poolmach *pm,
348  struct m0_fid *fid, uint32_t *idx);
349 
350 M0_TL_DESCR_DECLARE(poolmach_events, M0_EXTERN);
351 M0_TL_DECLARE(poolmach_events, M0_INTERNAL, struct m0_poolmach_event_link);
352 
357 M0_INTERNAL void m0_poolmach_gob2cob(struct m0_poolmach *pm,
358  const struct m0_fid *gfid,
359  uint32_t idx,
360  struct m0_fid *cob_fid_out);
361 
362 M0_INTERNAL int m0_poolmach_spare_build(struct m0_poolmach *mach,
363  struct m0_pool *pool,
364  enum m0_conf_pver_kind kind);
366 #endif /* __MOTR_POOL_PVER_MACHINE_H__ */
367 
368 /*
369  * Local variables:
370  * c-indentation-style: "K&R"
371  * c-basic-offset: 8
372  * tab-width: 8
373  * fill-column: 80
374  * scroll-step: 1
375  * End:
376  */
377 
struct m0_poolmach_state * pm_state
Definition: pool_machine.h:169
Definition: dtm.h:554
M0_TL_DESCR_DECLARE(poolmach_events, M0_EXTERN)
struct m0_tl pst_event_queue
Definition: pool_machine.h:151
M0_INTERNAL bool m0_poolmach_sns_repair_spare_contains_data(struct m0_poolmach *p, uint32_t spare_slot, bool check_state)
Definition: pool_machine.c:919
M0_INTERNAL int m0_poolmach_state_transit(struct m0_poolmach *pm, const struct m0_poolmach_event *event)
Definition: pool_machine.c:554
uint32_t pst_nr_devices
Definition: pool_machine.h:108
struct m0_be_clink pst_conf_ready
Definition: pool_machine.h:154
struct m0_pool_version * pm_pver
Definition: pool_machine.h:172
M0_INTERNAL void m0_poolmach_event_dump(const struct m0_poolmach_event *e)
M0_INTERNAL int m0_poolmach_init_by_conf(struct m0_poolmach *pm, struct m0_conf_pver *pver)
Definition: pool_machine.c:236
M0_INTERNAL void m0_poolmach_device_state_dump(struct m0_poolmach *pm)
M0_INTERNAL int m0_poolmach_fid_to_idx(struct m0_poolmach *pm, struct m0_fid *fid, uint32_t *idx)
Definition: pool_machine.c:968
struct m0_poolnode * pst_nodes_array
Definition: pool_machine.h:105
static struct m0_addb2_mach * mach
Definition: storage.c:42
M0_INTERNAL int m0_poolmach_device_state(struct m0_poolmach *pm, uint32_t device_index, enum m0_pool_nd_state *state_out)
Definition: pool_machine.c:816
M0_TL_DECLARE(poolmach_events, M0_INTERNAL, struct m0_poolmach_event_link)
m0_conf_pver_kind
Definition: obj.h:516
struct m0_pooldev * pst_devices_array
Definition: pool_machine.h:111
struct m0_fid fid
Definition: di.c:46
M0_INTERNAL int m0_poolmach_spare_build(struct m0_poolmach *mach, struct m0_pool *pool, enum m0_conf_pver_kind kind)
M0_INTERNAL void m0_poolmach_event_list_dump_locked(struct m0_poolmach *pm)
uint32_t pst_nr_spares
Definition: pool_machine.h:120
struct m0_be_clink pst_conf_exp
Definition: pool_machine.h:153
M0_INTERNAL void m0_poolmach_event_list_dump(struct m0_poolmach *pm)
struct m0_fid pver
Definition: idx_dix.c:74
m0_pool_nd_state
Definition: pool_machine.h:57
Definition: tlist.h:251
M0_INTERNAL void m0_poolmach_failvec_apply(struct m0_poolmach *pm, const struct m0_ha_nvec *nvec)
Definition: pool_machine.c:999
M0_INTERNAL bool m0_poolmach_device_is_in_spare_usage_array(struct m0_poolmach *pm, uint32_t device_index)
Definition: pool_machine.c:867
uint32_t pe_type M0_XCA_FENUM(m0_poolmach_event_owner_type)
M0_INTERNAL void m0_poolmach_event_queue_apply(struct m0_poolmach *pm)
M0_INTERNAL int m0_poolmach_device_node_return(struct m0_poolmach *pm, uint32_t device_index, struct m0_poolnode **node_out)
Definition: pool_machine.c:850
M0_INTERNAL int m0_poolmach_init(struct m0_poolmach *pm, struct m0_pool_version *pver, uint32_t nr_nodes, uint32_t nr_devices, uint32_t nr_spare, uint32_t max_node_failures, uint32_t max_device_failures)
Definition: pool_machine.c:380
static struct m0_pool pool
Definition: iter_ut.c:58
M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures(struct m0_poolmach *pm)
Definition: setup.h:354
uint32_t pst_max_node_failures
Definition: pool_machine.h:117
Definition: fid.h:38
uint32_t pst_nr_failures
Definition: pool_machine.h:131
M0_INTERNAL int m0_poolmach_sns_repair_spare_query(struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
Definition: pool_machine.c:875
enum m0_pool_nd_state M0_XCA_ENUM
uint32_t pst_max_device_failures
Definition: pool_machine.h:126
M0_INTERNAL void m0_poolmach_fini(struct m0_poolmach *pm)
Definition: pool_machine.c:426
bool pm_is_initialised
Definition: pool_machine.h:175
Definition: dtm.h:529
Definition: pool.h:80
M0_INTERNAL uint32_t m0_poolmach_equeue_length(struct m0_poolmach *pm)
Definition: pool_machine.c:501
struct m0_rwlock pm_lock
Definition: pool_machine.h:178
uint32_t pst_nr_nodes
Definition: pool_machine.h:102
struct m0_fid gfid
Definition: dir.c:626
enum m0_pool_nd_state pe_state
Definition: pool_machine.h:199
struct m0_tl pst_events_list
Definition: pool_machine.h:145
struct m0_pool_spare_usage * pst_spare_usage_array
Definition: pool_machine.h:137
M0_INTERNAL int m0_poolmach_node_state(struct m0_poolmach *pm, uint32_t node_index, enum m0_pool_nd_state *state_out)
Definition: pool_machine.c:833
M0_INTERNAL int m0_poolmach_sns_rebalance_spare_query(struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
Definition: pool_machine.c:930
M0_INTERNAL void m0_poolmach_gob2cob(struct m0_poolmach *pm, const struct m0_fid *gfid, uint32_t idx, struct m0_fid *cob_fid)
m0_poolmach_event_owner_type
Definition: pool_machine.h:182
M0_INTERNAL void m0_poolmach_state_last_cancel(struct m0_poolmach *pm)
Definition: pool_machine.c:796