22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_POOL 94 uint32_t *idx_devices)
106 if (*idx_devices != 0)
113 pnode->
pn_id =
n->cn_obj.co_id;
118 &
n->cn_obj.co_ha_chan);
242 uint32_t idx_nodes = 0;
243 uint32_t idx_devices = 0;
250 M0_CONF_PVER_SITEVS_FID,
251 M0_CONF_SITEV_RACKVS_FID,
252 M0_CONF_RACKV_ENCLVS_FID,
253 M0_CONF_ENCLV_CTRLVS_FID,
254 M0_CONF_CTRLV_DRIVEVS_FID);
263 &idx_nodes, &idx_devices);
279 M0_POST(idx_devices <= pm->pm_state->pst_nr_devices);
290 uint32_t max_node_failures,
291 uint32_t max_device_failures,
314 .ot_version = M0_POOLNODE_FORMAT_VERSION,
315 .ot_type = M0_FORMAT_TYPE_POOLNODE,
317 offsetof(struct m0_poolnode, pn_footer)
329 .ot_version = M0_POOLDEV_FORMAT_VERSION,
330 .ot_type = M0_FORMAT_TYPE_POOLDEV,
332 offsetof(struct m0_pooldev, pd_footer)
349 M0_POOL_SPARE_USAGE_FORMAT_VERSION,
350 .ot_type = M0_FORMAT_TYPE_POOL_SPARE_USAGE,
352 offsetof(struct m0_pool_spare_usage, psu_footer)
385 uint32_t max_node_failures,
386 uint32_t max_device_failures)
398 (state, nodes_array, devices_array, spare_usage_array))) {
405 state_init(state, nodes_array, nr_nodes, devices_array,
406 nr_devices, spare_usage_array, nr_spare,
407 max_node_failures, max_device_failures, pm);
439 poolmach_events_tlink_del_fini(
scan);
447 if (pool_failed_devs_tlink_is_in(pd))
448 pool_failed_devs_tlink_del_fini(pd);
488 if (new_link ==
NULL) {
493 poolmach_equeue_tlink_init_at_tail(new_link,
521 spare_array[
i].psu_device_state =
event->pe_state;
528 " this pool version is in DUD state;" 529 " event_index=%d event_state=%d",
593 switch (event->pe_type) {
679 M0_ASSERT(M0_IN(spare_array[
i].psu_device_state,
688 M0_ASSERT(!pool_failed_devs_tlink_is_in(pd));
694 if (pool_failed_devs_tlink_is_in(pd))
695 pool_failed_devs_tlist_del(pd);
696 pool_failed_devs_tlink_fini(pd);
700 M0_ASSERT(!pool_failed_devs_tlink_is_in(pd));
714 if (!pool_failed_devs_tlink_is_in(pd) &&
716 pool_failed_devs_tlist_add_tail(
726 spare_array[
i].psu_device_state =
736 "DUD state; event_index=%d event_state=%d",
741 if (!pool_failed_devs_tlink_is_in(pd) &&
744 pool_failed_devs_tlist_add_tail(
755 if (new_link ==
NULL) {
758 *new_link = event_link;
759 poolmach_events_tlink_init_at_tail(new_link,
768 " event_index:%d event_state:%d" 769 " (a node failure/restart" 770 " or expander reset?)",
778 " event_index:%d event_state:%d",
809 poolmach_events_tlink_del_fini(link);
817 uint32_t device_index,
824 return M0_ERR_INFO(-EINVAL,
"device index:%d total devices:%d",
851 uint32_t device_index,
858 return M0_ERR_INFO(-EINVAL,
"device index:%d total devices:%d",
868 uint32_t device_index)
876 uint32_t device_index,
877 uint32_t *spare_slot_out)
902 M0_ASSERT(M0_IN(spare_usage_array[
i].psu_device_state,
924 &
p->pm_state->pst_spare_usage_array[spare_slot];
931 uint32_t device_index,
932 uint32_t *spare_slot_out)
954 M0_ASSERT(M0_IN(spare_usage_array[
i].psu_device_state,
991 e = &
scan->pel_event;
993 poolmach_equeue_tlink_del_fini(
scan);
1007 uint32_t pd_idx = 0;
1015 for (
i = 0;
i < nvec->
nv_nr; ++
i) {
1029 if (!pool_failed_devs_tlink_is_in(pd) &&
1032 pool_failed_devs_tlist_add_tail(
1060 uint32_t pd_idx = 0;
1075 M0_LOG(
M0_DEBUG,
"length :%d", (
int) pool_failed_devs_tlist_length(
1159 event = &
scan->pel_event;
1161 poolmach_equeue_tlink_del_fini(
scan);
1169 #define POOL_TRACE_LEVEL M0_DEBUG 1199 e = &
scan->pel_event;
1209 m0_tl_for (poolmach_equeue, qhead, qscan) {
1261 #undef POOL_TRACE_LEVEL 1262 #undef M0_TRACE_SUBSYSTEM const struct m0_conf_obj_type * m0_conf_obj_type(const struct m0_conf_obj *obj)
union m0_be_clink::@200 bc_u
struct m0_poolmach_state * pm_state
static struct m0_addb2_philter p
M0_INTERNAL void m0_chan_wait(struct m0_clink *link)
static struct m0_clink * ready_clink(struct m0_poolmach_state *state)
#define M0_ALLOC_ARR(arr, nr)
const struct m0_conf_obj_type M0_CONF_OBJV_TYPE
static int poolmach_equeue_add(struct m0_poolmach *pm, const struct m0_poolmach_event *event)
struct m0_tl pst_event_queue
M0_INTERNAL bool m0_poolmach_sns_repair_spare_contains_data(struct m0_poolmach *p, uint32_t spare_slot, bool check_state)
struct m0_format_header pn_header
M0_INTERNAL int m0_poolmach_state_transit(struct m0_poolmach *pm, const struct m0_poolmach_event *event)
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
M0_INTERNAL void m0_clink_del_lock(struct m0_clink *link)
static struct m0_mutex chan_lock
struct m0_be_clink pst_conf_ready
static bool disk_is_in(struct m0_tl *head, struct m0_pooldev *pd)
struct m0_pool_version * pm_pver
M0_INTERNAL void m0_poolmach_event_dump(const struct m0_poolmach_event *e)
M0_TL_DESCR_DEFINE(poolmach_events, "pool machine events list", M0_INTERNAL, struct m0_poolmach_event_link, pel_linkage, pel_magic, M0_POOL_EVENTS_LIST_MAGIC, M0_POOL_EVENTS_HEAD_MAGIC)
#define m0_count(var, nr,...)
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
#define M0_LOG(level,...)
M0_INTERNAL int m0_poolmach_init_by_conf(struct m0_poolmach *pm, struct m0_conf_pver *pver)
static struct net_test_cmd_node * node
M0_INTERNAL void m0_poolmach_device_state_dump(struct m0_poolmach *pm)
M0_INTERNAL void m0_poolnode_clink_del(struct m0_clink *cl)
M0_INTERNAL int m0_poolmach_fid_to_idx(struct m0_poolmach *pm, struct m0_fid *fid, uint32_t *idx)
M0_INTERNAL void m0_rwlock_write_lock(struct m0_rwlock *lock)
M0_INTERNAL int m0_conf_diter_next_sync(struct m0_conf_diter *it, bool(*filter)(const struct m0_conf_obj *obj))
static void poolmach_event_queue_drop(struct m0_poolmach *pm, struct m0_poolmach_event *ev)
struct m0_chan rh_conf_cache_ready
static struct m0_be_emap_cursor it
struct m0_poolnode * pst_nodes_array
static struct m0_addb2_mach * mach
#define m0_exists(var, nr,...)
M0_INTERNAL int m0_poolmach_device_state(struct m0_poolmach *pm, uint32_t device_index, enum m0_pool_nd_state *state_out)
#define container_of(ptr, type, member)
struct m0_poolmach * pn_pm
static int poolmach_spare_inherit(struct m0_poolmach *pm, struct m0_pool *pool)
M0_INTERNAL int m0_ha_failvec_fetch(const struct m0_fid *pool_fid, struct m0_poolmach *pmach, struct m0_chan *chan)
M0_INTERNAL void m0_rwlock_init(struct m0_rwlock *lock)
struct m0_pooldev * pst_devices_array
struct m0_be_clink pd_clink
static int head(struct m0_sm *mach)
M0_INTERNAL int m0_poolmach_spare_build(struct m0_poolmach *mach, struct m0_pool *pool, enum m0_conf_pver_kind kind)
struct m0_poolmach_event pel_event
struct m0_poolnode * pd_node
M0_INTERNAL void m0_poolmach_event_list_dump_locked(struct m0_poolmach *pm)
#define M0_ERR_INFO(rc, fmt,...)
return M0_ERR(-EOPNOTSUPP)
static void state_init(struct m0_poolmach_state *state, struct m0_poolnode *nodes_array, uint32_t nr_nodes, struct m0_pooldev *devices_array, uint32_t nr_devices, struct m0_pool_spare_usage *spare_usage_array, uint32_t nr_spare, uint32_t max_node_failures, uint32_t max_device_failures, struct m0_poolmach *pm)
const struct m0_conf_obj_type M0_CONF_ENCLOSURE_TYPE
struct m0_tlink pel_linkage
struct m0_be_clink pst_conf_exp
struct m0_format_header psu_header
M0_INTERNAL void m0_poolmach_event_list_dump(struct m0_poolmach *pm)
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
struct m0_poolmach * pd_pm
static struct m0_confc * confc
struct m0_format_header pd_header
enum m0_ha_obj_state co_ha_state
M0_INTERNAL void m0_poolmach_failvec_apply(struct m0_poolmach *pm, const struct m0_ha_nvec *nvec)
static struct m0_fid cob_fid
struct m0_conf_cache cc_cache
static void poolmach_init(struct m0_poolmach *pm, struct m0_pool_version *pver, struct m0_poolmach_state *pm_state)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
M0_INTERNAL size_t m0_tlist_length(const struct m0_tl_descr *d, const struct m0_tl *list)
M0_INTERNAL bool m0_poolmach_device_is_in_spare_usage_array(struct m0_poolmach *pm, uint32_t device_index)
struct m0_chan co_ha_chan
const struct m0_conf_obj_type M0_CONF_DRIVE_TYPE
static bool is_enclosurev_or_diskv(const struct m0_conf_obj *obj)
static bool poolmach_conf_expired_cb(struct m0_clink *clink)
M0_INTERNAL void m0_clink_cleanup(struct m0_clink *link)
M0_INTERNAL void m0_rwlock_write_unlock(struct m0_rwlock *lock)
#define M0_CONF_CAST(ptr, type)
struct m0_conf_sdev * ck_sdev
M0_INTERNAL void m0_pooldev_clink_add(struct m0_clink *link, struct m0_chan *chan)
static struct m0_clink clink[RDWR_REQUEST_MAX]
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)
M0_INTERNAL void m0_poolnode_clink_add(struct m0_clink *link, struct m0_chan *chan)
M0_INTERNAL void m0_conf_obj_get_lock(struct m0_conf_obj *obj)
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)
M0_INTERNAL struct m0_reqh * m0_confc2reqh(const struct m0_confc *confc)
static struct m0_pool pool
static struct m0_clink * poolnode_clink(struct m0_poolnode *pnode)
struct m0_conf_node * ce_node
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures(struct m0_poolmach *pm)
M0_INTERNAL struct m0_conf_obj * m0_conf_diter_result(const struct m0_conf_diter *it)
#define m0_conf_diter_init(iter, confc, origin,...)
M0_INTERNAL uint32_t m0_ha2pm_state_map(enum m0_ha_obj_state hastate)
uint32_t pst_max_node_failures
static struct m0_chan chan[RDWR_REQUEST_MAX]
#define M0_FI_ENABLED(tag)
uint32_t psu_device_index
struct m0_chan rh_conf_cache_exp
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL void m0_conf_diter_fini(struct m0_conf_diter *it)
struct m0_be_clink pn_clink
M0_INTERNAL int m0_poolmach_sns_repair_spare_query(struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
static void pool_obj_clink_fini(struct m0_clink *cl)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
uint32_t psu_device_index
uint32_t pst_max_device_failures
M0_INTERNAL void m0_rwlock_read_lock(struct m0_rwlock *lock)
M0_INTERNAL void m0_poolmach_fini(struct m0_poolmach *pm)
M0_INTERNAL void m0_rwlock_fini(struct m0_rwlock *lock)
M0_INTERNAL struct m0_confc * m0_confc_from_obj(const struct m0_conf_obj *obj)
M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj)
struct m0_poolmach_event pel_event
struct m0_rconfc rh_rconfc
#define M0_ASSERT_INFO(cond, fmt,...)
M0_INTERNAL uint32_t m0_poolmach_equeue_length(struct m0_poolmach *pm)
M0_INTERNAL void m0_rwlock_read_unlock(struct m0_rwlock *lock)
static void spare_usage_arr_update(struct m0_poolmach *pm, const struct m0_poolmach_event *event)
M0_INTERNAL void m0_fid_convert_gob2cob(const struct m0_fid *gob_fid, struct m0_fid *cob_fid, uint32_t device_id)
M0_INTERNAL void m0_pooldev_clink_del(struct m0_clink *cl)
struct m0_ha_note * nv_note
enum m0_pool_nd_state pe_state
static bool poolmach_conf_ready_cb(struct m0_clink *clink)
static int scan(struct scanner *s)
struct m0_tl pst_events_list
#define m0_tl_for(name, head, obj)
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
static struct m0_clink * pooldev_clink(struct m0_pooldev *pdev)
static int poolmach_state_update(struct m0_poolmach_state *st, const struct m0_conf_obj *objv_real, uint32_t *idx_nodes, uint32_t *idx_devices)
struct m0_pool_spare_usage * pst_spare_usage_array
M0_TL_DEFINE(poolmach_events, M0_INTERNAL, struct m0_poolmach_event_link)
M0_INTERNAL int m0_poolmach_node_state(struct m0_poolmach *pm, uint32_t node_index, enum m0_pool_nd_state *state_out)
M0_INTERNAL int m0_poolmach_sns_rebalance_spare_query(struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
M0_INTERNAL void m0_poolmach_gob2cob(struct m0_poolmach *pm, const struct m0_fid *gfid, uint32_t idx, struct m0_fid *cob_fid)
#define m0_tl_exists(name, var, head,...)
M0_INTERNAL bool m0_conf_obj_invariant(const struct m0_conf_obj *obj)
struct m0_conf_obj ck_obj
static struct m0_clink * exp_clink(struct m0_poolmach_state *state)
#define M0_IMPOSSIBLE(fmt,...)
struct m0_tl po_failed_devices
M0_INTERNAL void m0_poolmach_state_last_cancel(struct m0_poolmach *pm)