1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef DRBD_H
27#define DRBD_H
28#include <linux/connector.h>
29#include <asm/types.h>
30
31#ifdef __KERNEL__
32#include <linux/types.h>
33#include <asm/byteorder.h>
34#else
35#include <sys/types.h>
36#include <sys/wait.h>
37#include <limits.h>
38
39
40
41
42
43
44#if __BYTE_ORDER == __LITTLE_ENDIAN
45#define __LITTLE_ENDIAN_BITFIELD
46#elif __BYTE_ORDER == __BIG_ENDIAN
47#define __BIG_ENDIAN_BITFIELD
48#else
49# error "sorry, weird endianness on this box"
50#endif
51
52#endif
53
54extern const char *drbd_buildtag(void);
55#define REL_VERSION "8.4.3"
56#define API_VERSION 1
57#define PRO_VERSION_MIN 86
58#define PRO_VERSION_MAX 101
59
60
61enum drbd_io_error_p {
62 EP_PASS_ON,
63 EP_CALL_HELPER,
64 EP_DETACH
65};
66
67enum drbd_fencing_p {
68 FP_NOT_AVAIL = -1,
69 FP_DONT_CARE = 0,
70 FP_RESOURCE,
71 FP_STONITH
72};
73
74enum drbd_disconnect_p {
75 DP_RECONNECT,
76 DP_DROP_NET_CONF,
77 DP_FREEZE_IO
78};
79
80enum drbd_after_sb_p {
81 ASB_DISCONNECT,
82 ASB_DISCARD_YOUNGER_PRI,
83 ASB_DISCARD_OLDER_PRI,
84 ASB_DISCARD_ZERO_CHG,
85 ASB_DISCARD_LEAST_CHG,
86 ASB_DISCARD_LOCAL,
87 ASB_DISCARD_REMOTE,
88 ASB_CONSENSUS,
89 ASB_DISCARD_SECONDARY,
90 ASB_CALL_HELPER,
91 ASB_VIOLENTLY
92};
93
94enum drbd_on_no_data {
95 OND_IO_ERROR,
96 OND_SUSPEND_IO
97};
98
99enum drbd_on_congestion {
100 OC_BLOCK,
101 OC_PULL_AHEAD,
102 OC_DISCONNECT,
103};
104
105enum drbd_read_balancing {
106 RB_PREFER_LOCAL,
107 RB_PREFER_REMOTE,
108 RB_ROUND_ROBIN,
109 RB_LEAST_PENDING,
110 RB_CONGESTED_REMOTE,
111 RB_32K_STRIPING,
112 RB_64K_STRIPING,
113 RB_128K_STRIPING,
114 RB_256K_STRIPING,
115 RB_512K_STRIPING,
116 RB_1M_STRIPING,
117};
118
119
120enum drbd_ret_code {
121 ERR_CODE_BASE = 100,
122 NO_ERROR = 101,
123 ERR_LOCAL_ADDR = 102,
124 ERR_PEER_ADDR = 103,
125 ERR_OPEN_DISK = 104,
126 ERR_OPEN_MD_DISK = 105,
127 ERR_DISK_NOT_BDEV = 107,
128 ERR_MD_NOT_BDEV = 108,
129 ERR_DISK_TOO_SMALL = 111,
130 ERR_MD_DISK_TOO_SMALL = 112,
131 ERR_BDCLAIM_DISK = 114,
132 ERR_BDCLAIM_MD_DISK = 115,
133 ERR_MD_IDX_INVALID = 116,
134 ERR_IO_MD_DISK = 118,
135 ERR_MD_INVALID = 119,
136 ERR_AUTH_ALG = 120,
137 ERR_AUTH_ALG_ND = 121,
138 ERR_NOMEM = 122,
139 ERR_DISCARD_IMPOSSIBLE = 123,
140 ERR_DISK_CONFIGURED = 124,
141 ERR_NET_CONFIGURED = 125,
142 ERR_MANDATORY_TAG = 126,
143 ERR_MINOR_INVALID = 127,
144 ERR_INTR = 129,
145 ERR_RESIZE_RESYNC = 130,
146 ERR_NO_PRIMARY = 131,
147 ERR_RESYNC_AFTER = 132,
148 ERR_RESYNC_AFTER_CYCLE = 133,
149 ERR_PAUSE_IS_SET = 134,
150 ERR_PAUSE_IS_CLEAR = 135,
151 ERR_PACKET_NR = 137,
152 ERR_NO_DISK = 138,
153 ERR_NOT_PROTO_C = 139,
154 ERR_NOMEM_BITMAP = 140,
155 ERR_INTEGRITY_ALG = 141,
156 ERR_INTEGRITY_ALG_ND = 142,
157 ERR_CPU_MASK_PARSE = 143,
158 ERR_CSUMS_ALG = 144,
159 ERR_CSUMS_ALG_ND = 145,
160 ERR_VERIFY_ALG = 146,
161 ERR_VERIFY_ALG_ND = 147,
162 ERR_CSUMS_RESYNC_RUNNING= 148,
163 ERR_VERIFY_RUNNING = 149,
164 ERR_DATA_NOT_CURRENT = 150,
165 ERR_CONNECTED = 151,
166 ERR_PERM = 152,
167 ERR_NEED_APV_93 = 153,
168 ERR_STONITH_AND_PROT_A = 154,
169 ERR_CONG_NOT_PROTO_A = 155,
170 ERR_PIC_AFTER_DEP = 156,
171 ERR_PIC_PEER_DEP = 157,
172 ERR_RES_NOT_KNOWN = 158,
173 ERR_RES_IN_USE = 159,
174 ERR_MINOR_CONFIGURED = 160,
175 ERR_MINOR_EXISTS = 161,
176 ERR_INVALID_REQUEST = 162,
177 ERR_NEED_APV_100 = 163,
178 ERR_NEED_ALLOW_TWO_PRI = 164,
179 ERR_MD_UNCLEAN = 165,
180
181
182 AFTER_LAST_ERR_CODE
183};
184
185#define DRBD_PROT_A 1
186#define DRBD_PROT_B 2
187#define DRBD_PROT_C 3
188
189enum drbd_role {
190 R_UNKNOWN = 0,
191 R_PRIMARY = 1,
192 R_SECONDARY = 2,
193 R_MASK = 3,
194};
195
196
197
198
199
200
201enum drbd_conns {
202 C_STANDALONE,
203 C_DISCONNECTING,
204 C_UNCONNECTED,
205
206
207
208
209
210 C_TIMEOUT,
211 C_BROKEN_PIPE,
212 C_NETWORK_FAILURE,
213 C_PROTOCOL_ERROR,
214 C_TEAR_DOWN,
215
216 C_WF_CONNECTION,
217 C_WF_REPORT_PARAMS,
218 C_CONNECTED,
219 C_STARTING_SYNC_S,
220 C_STARTING_SYNC_T,
221 C_WF_BITMAP_S,
222 C_WF_BITMAP_T,
223 C_WF_SYNC_UUID,
224
225
226
227 C_SYNC_SOURCE,
228 C_SYNC_TARGET,
229 C_VERIFY_S,
230 C_VERIFY_T,
231 C_PAUSED_SYNC_S,
232 C_PAUSED_SYNC_T,
233
234 C_AHEAD,
235 C_BEHIND,
236
237 C_MASK = 31
238};
239
240enum drbd_disk_state {
241 D_DISKLESS,
242 D_ATTACHING,
243 D_FAILED,
244
245 D_NEGOTIATING,
246 D_INCONSISTENT,
247 D_OUTDATED,
248 D_UNKNOWN,
249 D_CONSISTENT,
250 D_UP_TO_DATE,
251 D_MASK = 15
252};
253
254union drbd_state {
255
256
257
258
259
260
261
262
263 struct {
264#if defined(__LITTLE_ENDIAN_BITFIELD)
265 unsigned role:2 ;
266 unsigned peer:2 ;
267 unsigned conn:5 ;
268 unsigned disk:4 ;
269 unsigned pdsk:4 ;
270 unsigned susp:1 ;
271 unsigned aftr_isp:1 ;
272 unsigned peer_isp:1 ;
273 unsigned user_isp:1 ;
274 unsigned susp_nod:1 ;
275 unsigned susp_fen:1 ;
276 unsigned _pad:9;
277#elif defined(__BIG_ENDIAN_BITFIELD)
278 unsigned _pad:9;
279 unsigned susp_fen:1 ;
280 unsigned susp_nod:1 ;
281 unsigned user_isp:1 ;
282 unsigned peer_isp:1 ;
283 unsigned aftr_isp:1 ;
284 unsigned susp:1 ;
285 unsigned pdsk:4 ;
286 unsigned disk:4 ;
287 unsigned conn:5 ;
288 unsigned peer:2 ;
289 unsigned role:2 ;
290#else
291# error "this endianness is not supported"
292#endif
293 };
294 unsigned int i;
295};
296
297enum drbd_state_rv {
298 SS_CW_NO_NEED = 4,
299 SS_CW_SUCCESS = 3,
300 SS_NOTHING_TO_DO = 2,
301 SS_SUCCESS = 1,
302 SS_UNKNOWN_ERROR = 0,
303 SS_TWO_PRIMARIES = -1,
304 SS_NO_UP_TO_DATE_DISK = -2,
305 SS_NO_LOCAL_DISK = -4,
306 SS_NO_REMOTE_DISK = -5,
307 SS_CONNECTED_OUTDATES = -6,
308 SS_PRIMARY_NOP = -7,
309 SS_RESYNC_RUNNING = -8,
310 SS_ALREADY_STANDALONE = -9,
311 SS_CW_FAILED_BY_PEER = -10,
312 SS_IS_DISKLESS = -11,
313 SS_DEVICE_IN_USE = -12,
314 SS_NO_NET_CONFIG = -13,
315 SS_NO_VERIFY_ALG = -14,
316 SS_NEED_CONNECTION = -15,
317 SS_LOWER_THAN_OUTDATED = -16,
318 SS_NOT_SUPPORTED = -17,
319 SS_IN_TRANSIENT_STATE = -18,
320 SS_CONCURRENT_ST_CHG = -19,
321 SS_O_VOL_PEER_PRI = -20,
322 SS_OUTDATE_WO_CONN = -21,
323 SS_AFTER_LAST_ERROR = -22,
324};
325
326
327extern const char *drbd_conn_str(enum drbd_conns);
328extern const char *drbd_role_str(enum drbd_role);
329extern const char *drbd_disk_str(enum drbd_disk_state);
330extern const char *drbd_set_st_err_str(enum drbd_state_rv);
331
332#define SHARED_SECRET_MAX 64
333
334#define MDF_CONSISTENT (1 << 0)
335#define MDF_PRIMARY_IND (1 << 1)
336#define MDF_CONNECTED_IND (1 << 2)
337#define MDF_FULL_SYNC (1 << 3)
338#define MDF_WAS_UP_TO_DATE (1 << 4)
339#define MDF_PEER_OUT_DATED (1 << 5)
340#define MDF_CRASHED_PRIMARY (1 << 6)
341#define MDF_AL_CLEAN (1 << 7)
342#define MDF_AL_DISABLED (1 << 8)
343
344enum drbd_uuid_index {
345 UI_CURRENT,
346 UI_BITMAP,
347 UI_HISTORY_START,
348 UI_HISTORY_END,
349 UI_SIZE,
350 UI_FLAGS,
351 UI_EXTENDED_SIZE
352};
353
354enum drbd_timeout_flag {
355 UT_DEFAULT = 0,
356 UT_DEGRADED = 1,
357 UT_PEER_OUTDATED = 2,
358};
359
360#define UUID_JUST_CREATED ((__u64)4)
361
362
363#define DRBD_MAGIC 0x83740267
364#define DRBD_MAGIC_BIG 0x835a
365#define DRBD_MAGIC_100 0x8620ec20
366
367#define DRBD_MD_MAGIC_07 (DRBD_MAGIC+3)
368#define DRBD_MD_MAGIC_08 (DRBD_MAGIC+4)
369#define DRBD_MD_MAGIC_84_UNCLEAN (DRBD_MAGIC+5)
370
371
372
373
374#define DRBD_AL_MAGIC 0x69cb65a2
375
376
377#define DRBD_MD_INDEX_INTERNAL -1
378#define DRBD_MD_INDEX_FLEX_EXT -2
379#define DRBD_MD_INDEX_FLEX_INT -3
380
381#endif
382