libmultipath: fix (max_)polling_interval setting logic
[multipath-tools/.git] / libmultipath / config.h
1 #ifndef _CONFIG_H
2 #define _CONFIG_H
3
4 #include <sys/types.h>
5 #include <stdint.h>
6 #include <urcu.h>
7 #include <inttypes.h>
8 #include "byteorder.h"
9
10 #define ORIGIN_DEFAULT 0
11 #define ORIGIN_CONFIG  1
12
13 /*
14  * In kernel, fast_io_fail == 0 means immediate failure on rport delete.
15  * OTOH '0' means not-configured in various places in multipath-tools.
16  */
17 #define MP_FAST_IO_FAIL_UNSET (0)
18 #define MP_FAST_IO_FAIL_OFF (-1)
19 #define MP_FAST_IO_FAIL_ZERO (-2)
20
21 enum devtypes {
22         DEV_NONE,
23         DEV_DEVT,
24         DEV_DEVNODE,
25         DEV_DEVMAP,
26         DEV_UEVENT
27 };
28
29 enum mpath_cmds {
30         CMD_NONE,
31         CMD_CREATE,
32         CMD_DRY_RUN,
33         CMD_LIST_SHORT,
34         CMD_LIST_LONG,
35         CMD_VALID_PATH,
36         CMD_REMOVE_WWID,
37         CMD_RESET_WWIDS,
38         CMD_ADD_WWID,
39         CMD_USABLE_PATHS,
40         CMD_DUMP_CONFIG,
41 };
42
43 enum force_reload_types {
44         FORCE_RELOAD_NONE,
45         FORCE_RELOAD_YES,
46         FORCE_RELOAD_WEAK,
47 };
48
49 struct hwentry {
50         char * vendor;
51         char * product;
52         char * revision;
53         char * uid_attribute;
54         char * getuid;
55         char * features;
56         char * hwhandler;
57         char * selector;
58         char * checker_name;
59         char * prio_name;
60         char * prio_args;
61         char * alias_prefix;
62
63         int pgpolicy;
64         int pgfailback;
65         int rr_weight;
66         int no_path_retry;
67         int minio;
68         int minio_rq;
69         int flush_on_last_del;
70         int fast_io_fail;
71         unsigned int dev_loss;
72         int user_friendly_names;
73         int retain_hwhandler;
74         int detect_prio;
75         int detect_checker;
76         int deferred_remove;
77         int delay_watch_checks;
78         int delay_wait_checks;
79         int san_path_err_threshold;
80         int san_path_err_forget_rate;
81         int san_path_err_recovery_time;
82         int marginal_path_err_sample_time;
83         int marginal_path_err_rate_threshold;
84         int marginal_path_err_recheck_gap_time;
85         int marginal_path_double_failed_time;
86         int skip_kpartx;
87         int max_sectors_kb;
88         int ghost_delay;
89         int all_tg_pt;
90         int vpd_vendor_id;
91         char * bl_product;
92 };
93
94 struct mpentry {
95         char * wwid;
96         char * alias;
97         char * uid_attribute;
98         char * getuid;
99         char * selector;
100         char * features;
101
102         char * prio_name;
103         char * prio_args;
104         int prkey_source;
105         struct be64 reservation_key;
106         uint8_t sa_flags;
107         int pgpolicy;
108         int pgfailback;
109         int rr_weight;
110         int no_path_retry;
111         int minio;
112         int minio_rq;
113         int flush_on_last_del;
114         int attribute_flags;
115         int user_friendly_names;
116         int deferred_remove;
117         int delay_watch_checks;
118         int delay_wait_checks;
119         int san_path_err_threshold;
120         int san_path_err_forget_rate;
121         int san_path_err_recovery_time;
122         int marginal_path_err_sample_time;
123         int marginal_path_err_rate_threshold;
124         int marginal_path_err_recheck_gap_time;
125         int marginal_path_double_failed_time;
126         int skip_kpartx;
127         int max_sectors_kb;
128         int ghost_delay;
129         uid_t uid;
130         gid_t gid;
131         mode_t mode;
132 };
133
134 struct config {
135         struct rcu_head rcu;
136         int verbosity;
137         int pgpolicy_flag;
138         int pgpolicy;
139         int minio;
140         int minio_rq;
141         unsigned int checkint;
142         unsigned int max_checkint;
143         bool use_watchdog;
144         int pgfailback;
145         int remove;
146         int rr_weight;
147         int no_path_retry;
148         int user_friendly_names;
149         int bindings_read_only;
150         int max_fds;
151         int force_reload;
152         int queue_without_daemon;
153         int checker_timeout;
154         int flush_on_last_del;
155         int attribute_flags;
156         int fast_io_fail;
157         unsigned int dev_loss;
158         int log_checker_err;
159         int allow_queueing;
160         int find_multipaths;
161         uid_t uid;
162         gid_t gid;
163         mode_t mode;
164         int reassign_maps;
165         int retain_hwhandler;
166         int detect_prio;
167         int detect_checker;
168         int force_sync;
169         int deferred_remove;
170         int processed_main_config;
171         int delay_watch_checks;
172         int delay_wait_checks;
173         int san_path_err_threshold;
174         int san_path_err_forget_rate;
175         int san_path_err_recovery_time;
176         int marginal_path_err_sample_time;
177         int marginal_path_err_rate_threshold;
178         int marginal_path_err_recheck_gap_time;
179         int marginal_path_double_failed_time;
180         int uxsock_timeout;
181         int strict_timing;
182         int retrigger_tries;
183         int retrigger_delay;
184         int delayed_reconfig;
185         int uev_wait_timeout;
186         int skip_kpartx;
187         int remove_retries;
188         int max_sectors_kb;
189         int ghost_delay;
190         int find_multipaths_timeout;
191         int marginal_pathgroups;
192         unsigned int version[3];
193         unsigned int sequence_nr;
194
195         char * multipath_dir;
196         char * selector;
197         struct _vector uid_attrs;
198         char * uid_attribute;
199         char * getuid;
200         char * features;
201         char * hwhandler;
202         char * bindings_file;
203         char * wwids_file;
204         char * prkeys_file;
205         char * prio_name;
206         char * prio_args;
207         char * checker_name;
208         char * alias_prefix;
209         char * partition_delim;
210         char * config_dir;
211         int prkey_source;
212         int all_tg_pt;
213         struct be64 reservation_key;
214         uint8_t sa_flags;
215
216         vector keywords;
217         vector mptable;
218         vector hwtable;
219         struct hwentry *overrides;
220
221         vector blist_devnode;
222         vector blist_wwid;
223         vector blist_device;
224         vector blist_property;
225         vector blist_protocol;
226         vector elist_devnode;
227         vector elist_wwid;
228         vector elist_device;
229         vector elist_property;
230         vector elist_protocol;
231         char *enable_foreign;
232 };
233
234 extern struct udev * udev;
235
236 int find_hwe (const struct _vector *hwtable,
237               const char * vendor, const char * product, const char *revision,
238               vector result);
239 struct mpentry * find_mpe (vector mptable, char * wwid);
240 char * get_mpe_wwid (vector mptable, char * alias);
241
242 struct hwentry * alloc_hwe (void);
243 struct mpentry * alloc_mpe (void);
244
245 void free_hwe (struct hwentry * hwe);
246 void free_hwtable (vector hwtable);
247 void free_mpe (struct mpentry * mpe);
248 void free_mptable (vector mptable);
249
250 int store_hwe (vector hwtable, struct hwentry *);
251
252 struct config *load_config (char * file);
253 struct config * alloc_config (void);
254 void free_config (struct config * conf);
255 extern struct config *get_multipath_config(void);
256 extern void put_multipath_config(void *);
257
258 int parse_uid_attrs(char *uid_attrs, struct config *conf);
259 char *get_uid_attribute_by_attrs(struct config *conf,
260                                  const char *path_dev);
261
262 #endif