Use struct udev_device instead of sysdev
[platform/upstream/multipath-tools.git] / libmultipath / structs.h
1 #ifndef _STRUCTS_H
2 #define _STRUCTS_H
3
4 #include <sys/types.h>
5
6 #define WWID_SIZE               128
7 #define SERIAL_SIZE             65
8 #define NODE_NAME_SIZE          224
9 #define PATH_STR_SIZE           16
10 #define PARAMS_SIZE             1024
11 #define FILE_NAME_SIZE          256
12 #define CALLOUT_MAX_SIZE        256
13 #define BLK_DEV_SIZE            33
14 #define PATH_SIZE               512
15 #define NAME_SIZE               512
16
17
18 #define SCSI_VENDOR_SIZE        9
19 #define SCSI_PRODUCT_SIZE       17
20 #define SCSI_REV_SIZE           5
21 #define SCSI_STATE_SIZE         9
22
23 #define NO_PATH_RETRY_UNDEF     0
24 #define NO_PATH_RETRY_FAIL      -1
25 #define NO_PATH_RETRY_QUEUE     -2
26
27
28 enum free_path_mode {
29         KEEP_PATHS,
30         FREE_PATHS
31 };
32
33 enum rr_weight_mode {
34         RR_WEIGHT_UNDEF,
35         RR_WEIGHT_NONE,
36         RR_WEIGHT_PRIO
37 };
38
39 enum failback_mode {
40         FAILBACK_UNDEF,
41         FAILBACK_MANUAL,
42         FAILBACK_IMMEDIATE
43 };
44
45 enum sysfs_buses {
46         SYSFS_BUS_UNDEF,
47         SYSFS_BUS_SCSI,
48         SYSFS_BUS_IDE,
49         SYSFS_BUS_CCW,
50         SYSFS_BUS_CCISS,
51 };
52
53 enum pathstates {
54         PSTATE_UNDEF,
55         PSTATE_FAILED,
56         PSTATE_ACTIVE
57 };
58
59 enum pgstates {
60         PGSTATE_UNDEF,
61         PGSTATE_ENABLED,
62         PGSTATE_DISABLED,
63         PGSTATE_ACTIVE
64 };
65
66 enum queue_without_daemon_states {
67         QUE_NO_DAEMON_UNDEF,
68         QUE_NO_DAEMON_OFF,
69         QUE_NO_DAEMON_ON,
70 };
71
72 enum pgtimeouts {
73         PGTIMEOUT_UNDEF,
74         PGTIMEOUT_NONE
75 };
76
77 enum attribute_bits {
78         ATTR_UID,
79         ATTR_GID,
80         ATTR_MODE,
81 };
82
83 enum flush_states {
84         FLUSH_UNDEF,
85         FLUSH_DISABLED,
86         FLUSH_ENABLED,
87         FLUSH_IN_PROGRESS,
88 };
89
90 enum log_checker_err_states {
91         LOG_CHKR_ERR_ALWAYS,
92         LOG_CHKR_ERR_ONCE,
93 };
94
95 struct scsi_idlun {
96         int dev_id;
97         int host_unique_id;
98         int host_no;
99 };
100
101 struct sg_id {
102         int host_no;
103         int channel;
104         int scsi_id;
105         int lun;
106         short h_cmd_per_lun;
107         short d_queue_depth;
108         int unused1;
109         int unused2;
110 };
111
112 struct scsi_dev {
113         char dev[FILE_NAME_SIZE];
114         struct scsi_idlun scsi_id;
115         int host_no;
116 };
117
118 # ifndef HDIO_GETGEO
119 #  define HDIO_GETGEO   0x0301  /* get device geometry */
120
121 struct hd_geometry {
122       unsigned char heads;
123       unsigned char sectors;
124       unsigned short cylinders;
125       unsigned long start;
126 };
127 #endif
128 struct path {
129         char dev[FILE_NAME_SIZE];
130         char dev_t[BLK_DEV_SIZE];
131         struct udev_device *udev;
132         struct scsi_idlun scsi_id;
133         struct sg_id sg_id;
134         struct hd_geometry geom;
135         char wwid[WWID_SIZE];
136         char vendor_id[SCSI_VENDOR_SIZE];
137         char product_id[SCSI_PRODUCT_SIZE];
138         char rev[SCSI_REV_SIZE];
139         char serial[SERIAL_SIZE];
140         char tgt_node_name[NODE_NAME_SIZE];
141         unsigned long long size;
142         unsigned int checkint;
143         unsigned int tick;
144         int bus;
145         int offline;
146         int state;
147         int dmstate;
148         int failcount;
149         int priority;
150         int pgindex;
151         char * getuid;
152         struct prio * prio;
153         struct checker checker;
154         struct multipath * mpp;
155         int fd;
156
157         /* configlet pointers */
158         struct hwentry * hwe;
159 };
160
161 typedef int (pgpolicyfn) (struct multipath *);
162
163 struct multipath {
164         char wwid[WWID_SIZE];
165         char alias_old[WWID_SIZE];
166         int pgpolicy;
167         pgpolicyfn *pgpolicyfn;
168         int nextpg;
169         int bestpg;
170         int queuedio;
171         int action;
172         int pgfailback;
173         int failback_tick;
174         int rr_weight;
175         int nr_active;     /* current available(= not known as failed) paths */
176         int no_path_retry; /* number of retries after all paths are down */
177         int retry_tick;    /* remaining times for retries */
178         int minio;
179         int pg_timeout;
180         int flush_on_last_del;
181         int attribute_flags;
182         int fast_io_fail;
183         unsigned int dev_loss;
184         uid_t uid;
185         gid_t gid;
186         mode_t mode;
187         unsigned long long size;
188         vector paths;
189         vector pg;
190         struct dm_info * dmi;
191
192         /* configlet pointers */
193         char * alias;
194         char * alias_prefix;
195         char * selector;
196         char * features;
197         char * hwhandler;
198         struct mpentry * mpe;
199         struct hwentry * hwe;
200
201         /* threads */
202         pthread_t waiter;
203
204         /* stats */
205         unsigned int stat_switchgroup;
206         unsigned int stat_path_failures;
207         unsigned int stat_map_loads;
208         unsigned int stat_total_queueing_time;
209         unsigned int stat_queueing_timeouts;
210
211         /* checkers shared data */
212         void * mpcontext;
213         
214         /* persistent management data*/
215         unsigned char * reservation_key;
216         unsigned char prflag;
217 };
218
219 struct pathgroup {
220         long id;
221         int status;
222         int priority;
223         int enabled_paths;
224         vector paths;
225         char * selector;
226 };
227
228 struct path * alloc_path (void);
229 struct pathgroup * alloc_pathgroup (void);
230 struct multipath * alloc_multipath (void);
231 void free_path (struct path *);
232 void free_pathvec (vector vec, enum free_path_mode free_paths);
233 void free_pathgroup (struct pathgroup * pgp, enum free_path_mode free_paths);
234 void free_pgvec (vector pgvec, enum free_path_mode free_paths);
235 void free_multipath (struct multipath *, enum free_path_mode free_paths);
236 void free_multipath_attributes (struct multipath *);
237 void drop_multipath (vector mpvec, char * wwid, enum free_path_mode free_paths);
238 void free_multipathvec (vector mpvec, enum free_path_mode free_paths);
239
240 int store_path (vector pathvec, struct path * pp);
241 int store_pathgroup (vector pgvec, struct pathgroup * pgp);
242
243 struct multipath * find_mp_by_alias (vector mp, char * alias);
244 struct multipath * find_mp_by_wwid (vector mp, char * wwid);
245 struct multipath * find_mp_by_str (vector mp, char * wwid);
246 struct multipath * find_mp_by_minor (vector mp, int minor);
247         
248 struct path * find_path_by_devt (vector pathvec, char * devt);
249 struct path * find_path_by_dev (vector pathvec, char * dev);
250 struct path * first_path (struct multipath * mpp);
251
252 int pathcountgr (struct pathgroup *, int);
253 int pathcount (struct multipath *, int);
254 int pathcmp (struct pathgroup *, struct pathgroup *);
255 void setup_feature(struct multipath *, char *);
256 int add_feature (char **, char *);
257 int remove_feature (char **, char *);
258
259 extern char sysfs_path[PATH_SIZE];
260
261 #endif /* _STRUCTS_H */