2ab7b42c1e59d0070bc2eb0901134b6183aae9b5
[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         char * bl_product;
91 };
92
93 struct mpentry {
94         char * wwid;
95         char * alias;
96         char * uid_attribute;
97         char * getuid;
98         char * selector;
99         char * features;
100
101         char * prio_name;
102         char * prio_args;
103         int prkey_source;
104         struct be64 reservation_key;
105         uint8_t sa_flags;
106         int pgpolicy;
107         int pgfailback;
108         int rr_weight;
109         int no_path_retry;
110         int minio;
111         int minio_rq;
112         int flush_on_last_del;
113         int attribute_flags;
114         int user_friendly_names;
115         int deferred_remove;
116         int delay_watch_checks;
117         int delay_wait_checks;
118         int san_path_err_threshold;
119         int san_path_err_forget_rate;
120         int san_path_err_recovery_time;
121         int marginal_path_err_sample_time;
122         int marginal_path_err_rate_threshold;
123         int marginal_path_err_recheck_gap_time;
124         int marginal_path_double_failed_time;
125         int skip_kpartx;
126         int max_sectors_kb;
127         int ghost_delay;
128         uid_t uid;
129         gid_t gid;
130         mode_t mode;
131 };
132
133 struct config {
134         struct rcu_head rcu;
135         int verbosity;
136         int pgpolicy_flag;
137         int pgpolicy;
138         int minio;
139         int minio_rq;
140         unsigned int checkint;
141         unsigned int max_checkint;
142         int pgfailback;
143         int remove;
144         int rr_weight;
145         int no_path_retry;
146         int user_friendly_names;
147         int bindings_read_only;
148         int max_fds;
149         int force_reload;
150         int queue_without_daemon;
151         int checker_timeout;
152         int flush_on_last_del;
153         int attribute_flags;
154         int fast_io_fail;
155         unsigned int dev_loss;
156         int log_checker_err;
157         int allow_queueing;
158         int find_multipaths;
159         uid_t uid;
160         gid_t gid;
161         mode_t mode;
162         int reassign_maps;
163         int retain_hwhandler;
164         int detect_prio;
165         int detect_checker;
166         int force_sync;
167         int deferred_remove;
168         int processed_main_config;
169         int delay_watch_checks;
170         int delay_wait_checks;
171         int san_path_err_threshold;
172         int san_path_err_forget_rate;
173         int san_path_err_recovery_time;
174         int marginal_path_err_sample_time;
175         int marginal_path_err_rate_threshold;
176         int marginal_path_err_recheck_gap_time;
177         int marginal_path_double_failed_time;
178         int uxsock_timeout;
179         int strict_timing;
180         int retrigger_tries;
181         int retrigger_delay;
182         int delayed_reconfig;
183         int uev_wait_timeout;
184         int skip_kpartx;
185         int remove_retries;
186         int max_sectors_kb;
187         int ghost_delay;
188         int find_multipaths_timeout;
189         int marginal_pathgroups;
190         unsigned int version[3];
191
192         char * multipath_dir;
193         char * selector;
194         struct _vector uid_attrs;
195         char * uid_attribute;
196         char * getuid;
197         char * features;
198         char * hwhandler;
199         char * bindings_file;
200         char * wwids_file;
201         char * prkeys_file;
202         char * prio_name;
203         char * prio_args;
204         char * checker_name;
205         char * alias_prefix;
206         char * partition_delim;
207         char * config_dir;
208         int prkey_source;
209         int all_tg_pt;
210         struct be64 reservation_key;
211         uint8_t sa_flags;
212
213         vector keywords;
214         vector mptable;
215         vector hwtable;
216         struct hwentry *overrides;
217
218         vector blist_devnode;
219         vector blist_wwid;
220         vector blist_device;
221         vector blist_property;
222         vector blist_protocol;
223         vector elist_devnode;
224         vector elist_wwid;
225         vector elist_device;
226         vector elist_property;
227         vector elist_protocol;
228         char *enable_foreign;
229 };
230
231 extern struct udev * udev;
232
233 int find_hwe (const struct _vector *hwtable,
234               const char * vendor, const char * product, const char *revision,
235               vector result);
236 struct mpentry * find_mpe (vector mptable, char * wwid);
237 char * get_mpe_wwid (vector mptable, char * alias);
238
239 struct hwentry * alloc_hwe (void);
240 struct mpentry * alloc_mpe (void);
241
242 void free_hwe (struct hwentry * hwe);
243 void free_hwtable (vector hwtable);
244 void free_mpe (struct mpentry * mpe);
245 void free_mptable (vector mptable);
246
247 int store_hwe (vector hwtable, struct hwentry *);
248
249 struct config *load_config (char * file);
250 struct config * alloc_config (void);
251 void free_config (struct config * conf);
252 extern struct config *get_multipath_config(void);
253 extern void put_multipath_config(void *);
254
255 int parse_uid_attrs(char *uid_attrs, struct config *conf);
256 char *get_uid_attribute_by_attrs(struct config *conf,
257                                  const char *path_dev);
258
259 #endif