Motr  M0
Pool machine

Data Structures

struct  poolmach_equeue_link
 
struct  m0_poolmach_state
 
struct  m0_poolmach
 
struct  m0_poolmach_event
 
struct  m0_poolmach_event_link
 

Macros

#define POOL_TRACE_LEVEL   M0_DEBUG
 

Enumerations

enum  m0_pool_nd_state {
  M0_PNDS_UNKNOWN, M0_PNDS_ONLINE, M0_PNDS_FAILED, M0_PNDS_OFFLINE,
  M0_PNDS_SNS_REPAIRING, M0_PNDS_SNS_REPAIRED, M0_PNDS_SNS_REBALANCING, M0_PNDS_NR
}
 
enum  { POOL_PM_SPARE_SLOT_UNUSED = 0xFFFFFFFF }
 
enum  m0_poolmach_event_owner_type { M0_POOL_NODE, M0_POOL_DEVICE }
 

Functions

 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)
 
 M0_TL_DEFINE (poolmach_events, M0_INTERNAL, struct m0_poolmach_event_link)
 
 M0_TL_DESCR_DEFINE (poolmach_equeue, "pool machine events queue", static, struct poolmach_equeue_link, pel_linkage, pel_magic, 100, 101)
 
 M0_TL_DEFINE (poolmach_equeue, static, struct poolmach_equeue_link)
 
static struct m0_clinkpoolnode_clink (struct m0_poolnode *pnode)
 
static struct m0_clinkpooldev_clink (struct m0_pooldev *pdev)
 
static struct m0_clinkexp_clink (struct m0_poolmach_state *state)
 
static struct m0_clinkready_clink (struct m0_poolmach_state *state)
 
static bool is_enclosurev_or_diskv (const struct m0_conf_obj *obj)
 
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)
 
static bool poolmach_conf_expired_cb (struct m0_clink *clink)
 
static bool poolmach_conf_ready_cb (struct m0_clink *clink)
 
M0_INTERNAL int m0_poolmach_init_by_conf (struct m0_poolmach *pm, struct m0_conf_pver *pver)
 
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)
 
static void poolmach_init (struct m0_poolmach *pm, struct m0_pool_version *pver, struct m0_poolmach_state *pm_state)
 
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)
 
static void pool_obj_clink_fini (struct m0_clink *cl)
 
M0_INTERNAL void m0_poolmach_fini (struct m0_poolmach *pm)
 
static bool disk_is_in (struct m0_tl *head, struct m0_pooldev *pd)
 
static int poolmach_equeue_add (struct m0_poolmach *pm, const struct m0_poolmach_event *event)
 
M0_INTERNAL uint32_t m0_poolmach_equeue_length (struct m0_poolmach *pm)
 
static void spare_usage_arr_update (struct m0_poolmach *pm, const struct m0_poolmach_event *event)
 
M0_INTERNAL int m0_poolmach_state_transit (struct m0_poolmach *pm, const struct m0_poolmach_event *event)
 
M0_INTERNAL void m0_poolmach_state_last_cancel (struct m0_poolmach *pm)
 
M0_INTERNAL int m0_poolmach_device_state (struct m0_poolmach *pm, uint32_t device_index, enum m0_pool_nd_state *state_out)
 
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_device_node_return (struct m0_poolmach *pm, uint32_t device_index, struct m0_poolnode **node_out)
 
M0_INTERNAL bool m0_poolmach_device_is_in_spare_usage_array (struct m0_poolmach *pm, uint32_t device_index)
 
M0_INTERNAL int m0_poolmach_sns_repair_spare_query (struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
 
M0_INTERNAL bool m0_poolmach_sns_repair_spare_contains_data (struct m0_poolmach *p, uint32_t spare_slot, bool check_state)
 
M0_INTERNAL int m0_poolmach_sns_rebalance_spare_query (struct m0_poolmach *pm, uint32_t device_index, uint32_t *spare_slot_out)
 
M0_INTERNAL int m0_poolmach_fid_to_idx (struct m0_poolmach *pm, struct m0_fid *fid, uint32_t *idx)
 
static void poolmach_event_queue_drop (struct m0_poolmach *pm, struct m0_poolmach_event *ev)
 
M0_INTERNAL void m0_poolmach_failvec_apply (struct m0_poolmach *pm, const struct m0_ha_nvec *nvec)
 
static int poolmach_spare_inherit (struct m0_poolmach *pm, struct m0_pool *pool)
 
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_queue_apply (struct m0_poolmach *pm)
 
M0_INTERNAL void m0_poolmach_event_dump (const struct m0_poolmach_event *e)
 
M0_INTERNAL void m0_poolmach_event_list_dump (struct m0_poolmach *pm)
 
M0_INTERNAL void m0_poolmach_event_list_dump_locked (struct m0_poolmach *pm)
 
M0_INTERNAL void m0_poolmach_device_state_dump (struct m0_poolmach *pm)
 
M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures (struct m0_poolmach *pm)
 
M0_INTERNAL void m0_poolmach_gob2cob (struct m0_poolmach *pm, const struct m0_fid *gfid, uint32_t idx, struct m0_fid *cob_fid)
 
 M0_TL_DESCR_DECLARE (poolmach_events, M0_EXTERN)
 
 M0_TL_DECLARE (poolmach_events, M0_INTERNAL, struct m0_poolmach_event_link)
 

Variables

struct poolmach_equeue_link M0_XCA_DOMAIN
 
static int lno = 0
 
enum m0_pool_nd_state M0_XCA_ENUM
 

Detailed Description

Macro Definition Documentation

◆ POOL_TRACE_LEVEL

#define POOL_TRACE_LEVEL   M0_DEBUG

Definition at line 1169 of file pool_machine.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
POOL_PM_SPARE_SLOT_UNUSED 

Definition at line 86 of file pool_machine.h.

◆ m0_pool_nd_state

A state that a pool node/device can be in.

Enumerator
M0_PNDS_UNKNOWN 

a node/device is unknown

M0_PNDS_ONLINE 

a node/device is online and serving IO

M0_PNDS_FAILED 

a node/device is considered failed

M0_PNDS_OFFLINE 

a node/device turned off-line by an administrative request

M0_PNDS_SNS_REPAIRING 

a node/device is active in sns repair.

M0_PNDS_SNS_REPAIRED 

a node/device completed sns repair. Its data is re-constructed on its corresponding spare space

M0_PNDS_SNS_REBALANCING 

a node/device is active in sns re-balance.

M0_PNDS_NR 

number of state

Definition at line 57 of file pool_machine.h.

◆ m0_poolmach_event_owner_type

Event owner type, node or device.

Enumerator
M0_POOL_NODE 
M0_POOL_DEVICE 

Definition at line 182 of file pool_machine.h.

Function Documentation

◆ disk_is_in()

static bool disk_is_in ( struct m0_tl head,
struct m0_pooldev pd 
)
static

Definition at line 473 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exp_clink()

static struct m0_clink* exp_clink ( struct m0_poolmach_state state)
static

Definition at line 73 of file pool_machine.c.

Here is the caller graph for this function:

◆ is_enclosurev_or_diskv()

static bool is_enclosurev_or_diskv ( const struct m0_conf_obj obj)
static

Definition at line 83 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_device_is_in_spare_usage_array()

M0_INTERNAL bool m0_poolmach_device_is_in_spare_usage_array ( struct m0_poolmach pm,
uint32_t  device_index 
)

Returns true if device is in the spare usage array of pool machine.

Parameters
pmPool machine pointer in which spare usage array is populated.
device_indexIndex of device which needs to be searched.

Definition at line 867 of file pool_machine.c.

Here is the caller graph for this function:

◆ m0_poolmach_device_node_return()

M0_INTERNAL int m0_poolmach_device_node_return ( struct m0_poolmach pm,
uint32_t  device_index,
struct m0_poolnode **  node_out 
)

Returns the parent node object of the specified device in the pool.

Parameters
pmpool machine.
device_indexthe index of the device to query.
node_outthe parent node object.

Definition at line 850 of file pool_machine.c.

Here is the caller graph for this function:

◆ m0_poolmach_device_state()

M0_INTERNAL int m0_poolmach_device_state ( struct m0_poolmach pm,
uint32_t  device_index,
enum m0_pool_nd_state state_out 
)

Query the current state of a specified device.

Parameters
pmpool machine.
device_indexthe index of the device to query.
state_outthe output state.

Definition at line 816 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_device_state_dump()

M0_INTERNAL void m0_poolmach_device_state_dump ( struct m0_poolmach pm)

Definition at line 1221 of file pool_machine.c.

◆ m0_poolmach_equeue_length()

M0_INTERNAL uint32_t m0_poolmach_equeue_length ( struct m0_poolmach pm)

Definition at line 501 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_event_dump()

M0_INTERNAL void m0_poolmach_event_dump ( const struct m0_poolmach_event e)

Definition at line 1171 of file pool_machine.c.

◆ m0_poolmach_event_list_dump()

M0_INTERNAL void m0_poolmach_event_list_dump ( struct m0_poolmach pm)

Definition at line 1180 of file pool_machine.c.

Here is the call graph for this function:

◆ m0_poolmach_event_list_dump_locked()

M0_INTERNAL void m0_poolmach_event_list_dump_locked ( struct m0_poolmach pm)

Definition at line 1189 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_event_queue_apply()

M0_INTERNAL void m0_poolmach_event_queue_apply ( struct m0_poolmach pmach)

Applies a set of pending events arranged in chronological order to pool machine.

Precondition
(pmach->pm_state->pst_su_initialised)

Definition at line 1150 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_failvec_apply()

M0_INTERNAL void m0_poolmach_failvec_apply ( struct m0_poolmach pmach,
const struct m0_ha_nvec nvec 
)

Applies events from failure vector to pool machine.

Precondition
(!pmach->pm_state->pst_su_initialised)

Definition at line 999 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_fid_to_idx()

M0_INTERNAL int m0_poolmach_fid_to_idx ( struct m0_poolmach pm,
struct m0_fid fid,
uint32_t *  idx 
)

Returns the index within pool machine for a device with given fid.

Definition at line 968 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_fini()

M0_INTERNAL void m0_poolmach_fini ( struct m0_poolmach pm)

Finalises the pool machine.

Definition at line 426 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_gob2cob()

M0_INTERNAL void m0_poolmach_gob2cob ( struct m0_poolmach pm,
const struct m0_fid gfid,
uint32_t  idx,
struct m0_fid cob_fid_out 
)

Returns the idx-th component object of a global object according to the pool machine.

Definition at line 1244 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_init()

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 
)

Initialises the pool machine that stores its state in volatile memory.

Definition at line 380 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_init_by_conf()

M0_INTERNAL int m0_poolmach_init_by_conf ( struct m0_poolmach pm,
struct m0_conf_pver pver 
)

Definition at line 236 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_node_state()

M0_INTERNAL int m0_poolmach_node_state ( struct m0_poolmach pm,
uint32_t  node_index,
enum m0_pool_nd_state state_out 
)

Query the current state of a specified node.

Parameters
pmpool machine.
node_indexthe index of the node to query.
state_outthe output state.

Definition at line 833 of file pool_machine.c.

Here is the call graph for this function:

◆ m0_poolmach_nr_dev_failures()

M0_INTERNAL uint64_t m0_poolmach_nr_dev_failures ( struct m0_poolmach pm)

Definition at line 1234 of file pool_machine.c.

Here is the caller graph for this function:

◆ m0_poolmach_sns_rebalance_spare_query()

M0_INTERNAL int m0_poolmach_sns_rebalance_spare_query ( struct m0_poolmach pm,
uint32_t  device_index,
uint32_t *  spare_slot_out 
)

Query the {sns rebalance, spare slot} pair of a specified device.

Parameters
pmpool machine.
device_indexthe index of the device to query.
spare_slot_outthe output spair slot.

Definition at line 930 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_sns_repair_spare_contains_data()

M0_INTERNAL bool m0_poolmach_sns_repair_spare_contains_data ( struct m0_poolmach pm,
uint32_t  spare_slot,
bool  check_state 
)

Returns true if the spare slot now contains data. This case would be true when repair has already been invoked atleast once, due to which some failed data unit has been repaired onto the given spare slot.

Parameters
pmpool machine.
spare_slotthe slot index which needs to be checked.
check_statecheck the device state before making the decision.

Definition at line 919 of file pool_machine.c.

◆ m0_poolmach_sns_repair_spare_query()

M0_INTERNAL int m0_poolmach_sns_repair_spare_query ( struct m0_poolmach pm,
uint32_t  device_index,
uint32_t *  spare_slot_out 
)

Query the {sns repair, spare slot} pair of a specified device.

Parameters
pmpool machine.
device_indexthe index of the device to query.
spare_slot_outthe output spair slot.

Definition at line 875 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_spare_build()

M0_INTERNAL int m0_poolmach_spare_build ( struct m0_poolmach mach,
struct m0_pool pool,
enum m0_conf_pver_kind  kind 
)

Definition at line 1116 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_state_last_cancel()

M0_INTERNAL void m0_poolmach_state_last_cancel ( struct m0_poolmach pm)

Remove last pool machine event.

Definition at line 796 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_poolmach_state_transit()

M0_INTERNAL int m0_poolmach_state_transit ( struct m0_poolmach pm,
const struct m0_poolmach_event event 
)

The state transition path:

  +--------> OFFLINE
  |            |
  |            |
  v            v

ONLINE –—> FAILED <–> SNS_REPAIRING –> SNS_REPAIRED ^ ^ | | | v | SNS_REBALANCING | | ^ | | v +---------———<----------------———+

Change the pool machine state according to this event.

Parameters
eventthe event to drive the state change. This event will be copied into pool machine state, and it can be used or released by caller after call.
Todo:
If this is a new node join event, the index might larger than the current number. Then we need to create a new larger array to hold nodes info.
Todo:
Add ADDB error message here.

Definition at line 554 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ M0_TL_DECLARE()

M0_TL_DECLARE ( poolmach_events  ,
M0_INTERNAL  ,
struct m0_poolmach_event_link   
)

◆ M0_TL_DEFINE() [1/2]

M0_TL_DEFINE ( poolmach_events  ,
M0_INTERNAL  ,
struct m0_poolmach_event_link   
)

◆ M0_TL_DEFINE() [2/2]

M0_TL_DEFINE ( poolmach_equeue  ,
static  ,
struct poolmach_equeue_link   
)

◆ M0_TL_DESCR_DECLARE()

M0_TL_DESCR_DECLARE ( poolmach_events  ,
M0_EXTERN   
)

◆ M0_TL_DESCR_DEFINE() [1/2]

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   
)

◆ M0_TL_DESCR_DEFINE() [2/2]

M0_TL_DESCR_DEFINE ( poolmach_equeue  ,
"pool machine events queue ,
static  ,
struct poolmach_equeue_link  ,
pel_linkage  ,
pel_magic  ,
100  ,
101   
)

◆ pool_obj_clink_fini()

static void pool_obj_clink_fini ( struct m0_clink cl)
inlinestatic

Definition at line 412 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pooldev_clink()

static struct m0_clink* pooldev_clink ( struct m0_pooldev pdev)
static

Definition at line 68 of file pool_machine.c.

Here is the caller graph for this function:

◆ poolmach_conf_expired_cb()

static bool poolmach_conf_expired_cb ( struct m0_clink clink)
static

Definition at line 160 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_conf_ready_cb()

static bool poolmach_conf_ready_cb ( struct m0_clink clink)
static

Definition at line 203 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_equeue_add()

static int poolmach_equeue_add ( struct m0_poolmach pm,
const struct m0_poolmach_event event 
)
static

Definition at line 479 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_event_queue_drop()

static void poolmach_event_queue_drop ( struct m0_poolmach pm,
struct m0_poolmach_event ev 
)
static

Definition at line 983 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_init()

static void poolmach_init ( struct m0_poolmach pm,
struct m0_pool_version pver,
struct m0_poolmach_state pm_state 
)
static

Definition at line 365 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_spare_inherit()

static int poolmach_spare_inherit ( struct m0_poolmach pm,
struct m0_pool pool 
)
static

Definition at line 1054 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolmach_state_update()

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 
)
static

Definition at line 91 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poolnode_clink()

static struct m0_clink* poolnode_clink ( struct m0_poolnode pnode)
static

Definition at line 63 of file pool_machine.c.

Here is the caller graph for this function:

◆ ready_clink()

static struct m0_clink* ready_clink ( struct m0_poolmach_state state)
static

Definition at line 78 of file pool_machine.c.

Here is the caller graph for this function:

◆ spare_usage_arr_update()

static void spare_usage_arr_update ( struct m0_poolmach pm,
const struct m0_poolmach_event event 
)
static

Definition at line 507 of file pool_machine.c.

Here is the caller graph for this function:

◆ state_init()

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 
)
static

Definition at line 283 of file pool_machine.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ lno

int lno = 0
static

Definition at line 1166 of file pool_machine.c.

◆ M0_XCA_DOMAIN

struct poolmach_equeue_link M0_XCA_DOMAIN

◆ M0_XCA_ENUM

enum m0_pool_nd_state M0_XCA_ENUM