Motr  M0
finject_internal.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LIB_FINJECT_INTERNAL_H__
26 #define __MOTR_LIB_FINJECT_INTERNAL_H__
27 
28 #include "lib/mutex.h" /* m0_mutex */
29 
36  const char *fpi_func;
38  const char *fpi_tag;
39 };
40 
41 struct m0_fi_fpoint_state;
42 typedef bool (*fp_state_func_t)(struct m0_fi_fpoint_state *fps);
43 
62  /* Mutex, used to keep "state" structure in consistent state */
68 };
69 
71  uint32_t si_idx;
72  char si_enb;
73  uint32_t si_total_hit_cnt;
75  uint32_t si_hit_cnt;
76  uint32_t si_trigger_cnt;
77  const char *si_type;
78  char si_data[64];
79  const char *si_module;
80  const char *si_file;
81  const char *si_func;
82  const char *si_tag;
83  uint32_t si_line_num;
84 };
85 
86 #ifdef ENABLE_FAULT_INJECTION
87 
88 extern struct m0_mutex fi_states_mutex;
89 
90 static inline bool fi_state_enabled(const struct m0_fi_fpoint_state *state)
91 {
92  /*
93  * If fps_trigger_func is not set, then FP state is considered to be
94  * "disabled"
95  */
96  return state->fps_trigger_func != NULL;
97 }
98 
109 M0_INTERNAL const struct m0_fi_fpoint_state *m0_fi_states_get(void);
110 
116 M0_INTERNAL uint32_t m0_fi_states_get_free_idx(void);
117 
121 M0_INTERNAL void m0_fi_states_get_state_info(const struct m0_fi_fpoint_state *s,
123  *si);
124 
125 extern const char *m0_fi_states_headline[];
126 extern const char m0_fi_states_print_format[];
127 
134 M0_INTERNAL int m0_fi_add_dyn_id(char *str);
135 
139 M0_INTERNAL const char *m0_fi_fpoint_type_name(enum m0_fi_fpoint_type type);
140 
144 M0_INTERNAL enum m0_fi_fpoint_type m0_fi_fpoint_type_from_str(const char
145  *type_name);
146 
147 M0_INTERNAL void fi_states_init(void);
148 M0_INTERNAL void fi_states_fini(void);
149 
150 #endif /* ENABLE_FAULT_INJECTION */
151 
152 #endif /* __MOTR_LIB_FINJECT_INTERNAL_H__ */
153 
struct m0_fi_fpoint_id fps_id
#define NULL
Definition: misc.h:38
M0_INTERNAL uint32_t m0_fi_states_get_free_idx(void)
Definition: finject.c:94
M0_INTERNAL void fi_states_fini(void)
Definition: finject.c:204
fp_state_func_t fps_trigger_func
M0_INTERNAL enum m0_fi_fpoint_type m0_fi_fpoint_type_from_str(const char *type_name)
Definition: finject.c:364
const char m0_fi_states_print_format[]
Definition: finject.c:83
const char * m0_fi_states_headline[]
Definition: finject.c:77
M0_INTERNAL const struct m0_fi_fpoint_state * m0_fi_states_get(void)
Definition: finject.c:88
uint32_t fps_total_trigger_cnt
M0_INTERNAL void m0_fi_states_get_state_info(const struct m0_fi_fpoint_state *s, struct m0_fi_fpoint_state_info *si)
Definition: finject.c:123
M0_INTERNAL int m0_fi_add_dyn_id(char *str)
Definition: finject.c:171
struct m0_fi_fpoint_data fps_data
bool(* fp_state_func_t)(struct m0_fi_fpoint_state *fps)
struct m0_mutex fi_states_mutex
Definition: finject.c:50
const char * fpi_tag
static bool fi_state_enabled(const struct m0_fi_fpoint_state *state)
M0_INTERNAL void fi_states_init(void)
Definition: finject.c:199
const char * fpi_func
struct m0_fi_fault_point * fps_fp
M0_INTERNAL const char * m0_fi_fpoint_type_name(enum m0_fi_fpoint_type type)
Definition: finject.c:357
m0_fi_fpoint_type
Definition: finject.h:93
int type
Definition: dir.c:1031
struct m0_mutex fps_mutex
Definition: mutex.h:47
static struct m0_addb2_source * s
Definition: consumer.c:39
static struct sync_interactions si
Definition: sync.c:121