#include <stdio.h>
#include "lib/errno.h"
#include "lib/memory.h"
#include "lib/mutex.h"
#include "lib/misc.h"
#include "lib/assert.h"
#include "lib/tlist.h"
#include "lib/finject.h"
#include "lib/finject_internal.h"
#include "motr/magic.h"
#include "lib/trace.h"
Go to the source code of this file.
|
| M0_TL_DESCR_DEFINE (fi_dynamic_ids, "finject_dynamic_id", static, struct fi_dynamic_id, fdi_tlink, fdi_magic, M0_FI_DYNAMIC_ID_MAGIC, M0_FI_DYNAMIC_ID_HEAD_MAGIC) |
|
| M0_TL_DEFINE (fi_dynamic_ids, static, struct fi_dynamic_id) |
|
M0_INTERNAL const struct m0_fi_fpoint_state * | m0_fi_states_get (void) |
|
M0_INTERNAL uint32_t | m0_fi_states_get_free_idx (void) |
|
static uint32_t | fi_state_idx (const struct m0_fi_fpoint_state *s) |
|
static void | fi_state_info_init (struct m0_fi_fpoint_state_info *si) |
|
M0_INTERNAL void | m0_fi_states_get_state_info (const struct m0_fi_fpoint_state *s, struct m0_fi_fpoint_state_info *si) |
|
M0_INTERNAL int | m0_fi_add_dyn_id (char *str) |
|
static void | fi_dynamic_ids_fini (void) |
|
M0_INTERNAL void | fi_states_init (void) |
|
M0_INTERNAL void | fi_states_fini (void) |
|
static bool | fi_fpoint_id_eq (const struct m0_fi_fpoint_id *id1, const struct m0_fi_fpoint_id *id2) |
|
static struct m0_fi_fpoint_state * | __fi_state_find (const struct m0_fi_fpoint_id *fp_id) |
|
static struct m0_fi_fpoint_state * | fi_state_find (struct m0_fi_fpoint_id *fp_id) |
|
static struct m0_fi_fpoint_state * | fi_state_alloc (struct m0_fi_fpoint_id *id) |
|
static bool | fi_state_always (struct m0_fi_fpoint_state *fps) |
|
static void | fi_disable_state (struct m0_fi_fpoint_state *fps) |
|
static bool | fi_state_oneshot (struct m0_fi_fpoint_state *fps) |
|
M0_INTERNAL uint32_t | fi_random (void) |
|
static bool | fi_state_random (struct m0_fi_fpoint_state *fps) |
|
static bool | fi_state_off_n_on_m (struct m0_fi_fpoint_state *fps) |
|
static bool | fi_state_user_func (struct m0_fi_fpoint_state *fps) |
|
M0_INTERNAL const char * | m0_fi_fpoint_type_name (enum m0_fi_fpoint_type type) |
|
M0_INTERNAL enum m0_fi_fpoint_type | m0_fi_fpoint_type_from_str (const char *type_name) |
|
static void | fi_enable_state (struct m0_fi_fpoint_state *fp_state, const struct m0_fi_fpoint_data *fp_data) |
|
void | m0_fi_register (struct m0_fi_fault_point *fp) |
|
bool | m0_fi_enabled (struct m0_fi_fpoint_state *fps) |
|
M0_INTERNAL void | m0_fi_enable_generic (const char *fp_func, const char *fp_tag, const struct m0_fi_fpoint_data *fp_data) |
|
M0_INTERNAL void | m0_fi_disable (const char *fp_func, const char *fp_tag) |
|
◆ M0_TRACE_SUBSYSTEM
#define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB |
◆ anonymous enum
Enumerator |
---|
FI_STATES_ARRAY_SIZE | |
Definition at line 44 of file finject.c.
◆ __fi_state_find()
Searches for m0_fi_fpoint_state structure in global fi_states array by fault point ID.
- Parameters
-
fp_id | Pointer to fault point ID |
- Returns
- Pointer to m0_fi_fpoint_state object, which has fps_id equal to the provided fp_id, if any
-
NULL, if no such state object exists
Definition at line 241 of file finject.c.
◆ fi_disable_state()
◆ fi_dynamic_ids_fini()
static void fi_dynamic_ids_fini |
( |
void |
| ) |
|
|
static |
◆ fi_enable_state()
◆ fi_fpoint_id_eq()
Checks equality of two fault point ids.
- Parameters
-
id1 | Pointer to first ID |
id2 | Pointer to second ID |
- Returns
- true, if provided IDs are equal
-
false otherwise
Definition at line 223 of file finject.c.
◆ fi_random()
M0_INTERNAL uint32_t fi_random |
( |
void |
| ) |
|
Returns random value in range [0..FI_RAND_PROB_SCALE]
Definition at line 56 of file finject_init.c.
◆ fi_state_alloc()
"Allocates" and initializes state structure in fi_states array.
Definition at line 273 of file finject.c.
◆ fi_state_always()
Triggering algorithm for M0_FI_ALWAYS type
Definition at line 289 of file finject.c.
◆ fi_state_find()
◆ fi_state_idx()
◆ fi_state_info_init()
◆ fi_state_off_n_on_m()
Triggering algorithm for M0_FI_OFF_N_ON_M type
Definition at line 318 of file finject.c.
◆ fi_state_oneshot()
Triggering algorithm for M0_FI_ONESHOT type
Definition at line 299 of file finject.c.
◆ fi_state_random()
Triggering algorithm for M0_FI_RANDOM type
Definition at line 310 of file finject.c.
◆ fi_state_user_func()
Triggering algorithm for M0_FI_FUNC type
Definition at line 343 of file finject.c.
◆ fi_states_fini()
M0_INTERNAL void fi_states_fini |
( |
void |
| ) |
|
◆ fi_states_init()
M0_INTERNAL void fi_states_init |
( |
void |
| ) |
|
◆ m0_fi_add_dyn_id()
M0_INTERNAL int m0_fi_add_dyn_id |
( |
char * |
str | ) |
|
Add a dynamically allocated fault point ID string to persistent storage, which will be cleaned during m0_fi_fini() execution.
This function aimed to be used together with m0_fi_enable_xxx() functions.
Definition at line 171 of file finject.c.
◆ m0_fi_fpoint_type_name()
Returns the name of fault point type
Definition at line 357 of file finject.c.
◆ m0_fi_states_get()
A read-only "getter" of global fi_states array, which stores all FP states.
The fi_states array is a private data of lib/finject.c and it should not be modified by external code. This function deliberately returns a const pointer to emphasize this. The main purpose of this function is to provide the FP states information to m0ctl driver, which displays it via debugfs.
- Returns
- A constant pointer to global fi_states array.
Definition at line 88 of file finject.c.
◆ m0_fi_states_get_free_idx()
M0_INTERNAL uint32_t m0_fi_states_get_free_idx |
( |
void |
| ) |
|
A read-only "getter" of global fi_states_free_idx index of fi_states array.
- Returns
- Current value of fi_states_free_idx variable.
Definition at line 94 of file finject.c.
◆ m0_fi_states_get_state_info()
◆ M0_TL_DEFINE()
◆ M0_TL_DESCR_DEFINE()
◆ fi_dynamic_ids
struct m0_tl fi_dynamic_ids |
|
static |
A storage for fault point ID strings, which are allocated dynamically in runtime.
Almost always ID string is a C string-literal with a static storage duration. But in some rare cases ID strings need to be allocated dynamically (for example when enabling FP via debugfs). To prevent memleaks in such cases, all dynamically allocated ID strings are stored in this linked list, using m0_fi_add_dyn_id(), which is cleaned in fi_states_fini().
Definition at line 74 of file finject.c.
◆ fi_states
◆ fi_states_free_idx
uint32_t fi_states_free_idx |
◆ fi_states_mutex
◆ fi_trigger_funcs
Initial value:= {
}
static bool fi_state_always(struct m0_fi_fpoint_state *fps)
static bool fi_state_random(struct m0_fi_fpoint_state *fps)
static bool fi_state_user_func(struct m0_fi_fpoint_state *fps)
static bool fi_state_off_n_on_m(struct m0_fi_fpoint_state *fps)
static bool fi_state_oneshot(struct m0_fi_fpoint_state *fps)
Definition at line 377 of file finject.c.
◆ fi_type_names
◆ m0_fi_states_headline
const char* m0_fi_states_headline[] |
Initial value:= {
" Idx | Enb |TotHits|TotTrig|Hits|Trig| Type | Data | Module | File name | Line | Func name | Tag\n",
"-----+-----+-------+-------+----+----+----------+----------+--------+----------------------------------------+------+-----------------------------------+----------\n",
}
Definition at line 77 of file finject.c.
◆ m0_fi_states_print_format
const char m0_fi_states_print_format[] |
Initial value:=
" %-3u %c %-7u %-7u %-4u %-4u %-10s %-10s %-8s %-40s %-4u %-35s %s\n"
Definition at line 83 of file finject.c.