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
54
55extern const char *drbd_buildtag(void);
56#define REL_VERSION "8.3.11"
57#define API_VERSION 88
58#define PRO_VERSION_MIN 86
59#define PRO_VERSION_MAX 96
60
61
62enum drbd_io_error_p {
63 EP_PASS_ON,
64 EP_CALL_HELPER,
65 EP_DETACH
66};
67
68enum drbd_fencing_p {
69 FP_DONT_CARE,
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
105
106enum drbd_ret_code {
107 ERR_CODE_BASE = 100,
108 NO_ERROR = 101,
109 ERR_LOCAL_ADDR = 102,
110 ERR_PEER_ADDR = 103,
111 ERR_OPEN_DISK = 104,
112 ERR_OPEN_MD_DISK = 105,
113 ERR_DISK_NOT_BDEV = 107,
114 ERR_MD_NOT_BDEV = 108,
115 ERR_DISK_TO_SMALL = 111,
116 ERR_MD_DISK_TO_SMALL = 112,
117 ERR_BDCLAIM_DISK = 114,
118 ERR_BDCLAIM_MD_DISK = 115,
119 ERR_MD_IDX_INVALID = 116,
120 ERR_IO_MD_DISK = 118,
121 ERR_MD_INVALID = 119,
122 ERR_AUTH_ALG = 120,
123 ERR_AUTH_ALG_ND = 121,
124 ERR_NOMEM = 122,
125 ERR_DISCARD = 123,
126 ERR_DISK_CONFIGURED = 124,
127 ERR_NET_CONFIGURED = 125,
128 ERR_MANDATORY_TAG = 126,
129 ERR_MINOR_INVALID = 127,
130 ERR_INTR = 129,
131 ERR_RESIZE_RESYNC = 130,
132 ERR_NO_PRIMARY = 131,
133 ERR_SYNC_AFTER = 132,
134 ERR_SYNC_AFTER_CYCLE = 133,
135 ERR_PAUSE_IS_SET = 134,
136 ERR_PAUSE_IS_CLEAR = 135,
137 ERR_PACKET_NR = 137,
138 ERR_NO_DISK = 138,
139 ERR_NOT_PROTO_C = 139,
140 ERR_NOMEM_BITMAP = 140,
141 ERR_INTEGRITY_ALG = 141,
142 ERR_INTEGRITY_ALG_ND = 142,
143 ERR_CPU_MASK_PARSE = 143,
144 ERR_CSUMS_ALG = 144,
145 ERR_CSUMS_ALG_ND = 145,
146 ERR_VERIFY_ALG = 146,
147 ERR_VERIFY_ALG_ND = 147,
148 ERR_CSUMS_RESYNC_RUNNING= 148,
149 ERR_VERIFY_RUNNING = 149,
150 ERR_DATA_NOT_CURRENT = 150,
151 ERR_CONNECTED = 151,
152 ERR_PERM = 152,
153 ERR_NEED_APV_93 = 153,
154 ERR_STONITH_AND_PROT_A = 154,
155 ERR_CONG_NOT_PROTO_A = 155,
156 ERR_PIC_AFTER_DEP = 156,
157 ERR_PIC_PEER_DEP = 157,
158
159
160 AFTER_LAST_ERR_CODE
161};
162
163#define DRBD_PROT_A 1
164#define DRBD_PROT_B 2
165#define DRBD_PROT_C 3
166
167enum drbd_role {
168 R_UNKNOWN = 0,
169 R_PRIMARY = 1,
170 R_SECONDARY = 2,
171 R_MASK = 3,
172};
173
174
175
176
177
178
179enum drbd_conns {
180 C_STANDALONE,
181 C_DISCONNECTING,
182 C_UNCONNECTED,
183
184
185
186
187
188 C_TIMEOUT,
189 C_BROKEN_PIPE,
190 C_NETWORK_FAILURE,
191 C_PROTOCOL_ERROR,
192 C_TEAR_DOWN,
193
194 C_WF_CONNECTION,
195 C_WF_REPORT_PARAMS,
196 C_CONNECTED,
197 C_STARTING_SYNC_S,
198 C_STARTING_SYNC_T,
199 C_WF_BITMAP_S,
200 C_WF_BITMAP_T,
201 C_WF_SYNC_UUID,
202
203
204
205 C_SYNC_SOURCE,
206 C_SYNC_TARGET,
207 C_VERIFY_S,
208 C_VERIFY_T,
209 C_PAUSED_SYNC_S,
210 C_PAUSED_SYNC_T,
211
212 C_AHEAD,
213 C_BEHIND,
214
215 C_MASK = 31
216};
217
218enum drbd_disk_state {
219 D_DISKLESS,
220 D_ATTACHING,
221 D_FAILED,
222
223 D_NEGOTIATING,
224 D_INCONSISTENT,
225 D_OUTDATED,
226 D_UNKNOWN,
227 D_CONSISTENT,
228 D_UP_TO_DATE,
229 D_MASK = 15
230};
231
232union drbd_state {
233
234
235
236
237
238
239
240
241 struct {
242#if defined(__LITTLE_ENDIAN_BITFIELD)
243 unsigned role:2 ;
244 unsigned peer:2 ;
245 unsigned conn:5 ;
246 unsigned disk:4 ;
247 unsigned pdsk:4 ;
248 unsigned susp:1 ;
249 unsigned aftr_isp:1 ;
250 unsigned peer_isp:1 ;
251 unsigned user_isp:1 ;
252 unsigned susp_nod:1 ;
253 unsigned susp_fen:1 ;
254 unsigned _pad:9;
255#elif defined(__BIG_ENDIAN_BITFIELD)
256 unsigned _pad:9;
257 unsigned susp_fen:1 ;
258 unsigned susp_nod:1 ;
259 unsigned user_isp:1 ;
260 unsigned peer_isp:1 ;
261 unsigned aftr_isp:1 ;
262 unsigned susp:1 ;
263 unsigned pdsk:4 ;
264 unsigned disk:4 ;
265 unsigned conn:5 ;
266 unsigned peer:2 ;
267 unsigned role:2 ;
268#else
269# error "this endianness is not supported"
270#endif
271 };
272 unsigned int i;
273};
274
275enum drbd_state_rv {
276 SS_CW_NO_NEED = 4,
277 SS_CW_SUCCESS = 3,
278 SS_NOTHING_TO_DO = 2,
279 SS_SUCCESS = 1,
280 SS_UNKNOWN_ERROR = 0,
281 SS_TWO_PRIMARIES = -1,
282 SS_NO_UP_TO_DATE_DISK = -2,
283 SS_NO_LOCAL_DISK = -4,
284 SS_NO_REMOTE_DISK = -5,
285 SS_CONNECTED_OUTDATES = -6,
286 SS_PRIMARY_NOP = -7,
287 SS_RESYNC_RUNNING = -8,
288 SS_ALREADY_STANDALONE = -9,
289 SS_CW_FAILED_BY_PEER = -10,
290 SS_IS_DISKLESS = -11,
291 SS_DEVICE_IN_USE = -12,
292 SS_NO_NET_CONFIG = -13,
293 SS_NO_VERIFY_ALG = -14,
294 SS_NEED_CONNECTION = -15,
295 SS_LOWER_THAN_OUTDATED = -16,
296 SS_NOT_SUPPORTED = -17,
297 SS_IN_TRANSIENT_STATE = -18,
298 SS_CONCURRENT_ST_CHG = -19,
299 SS_AFTER_LAST_ERROR = -20,
300};
301
302
303extern const char *drbd_conn_str(enum drbd_conns);
304extern const char *drbd_role_str(enum drbd_role);
305extern const char *drbd_disk_str(enum drbd_disk_state);
306extern const char *drbd_set_st_err_str(enum drbd_state_rv);
307
308#define SHARED_SECRET_MAX 64
309
310#define MDF_CONSISTENT (1 << 0)
311#define MDF_PRIMARY_IND (1 << 1)
312#define MDF_CONNECTED_IND (1 << 2)
313#define MDF_FULL_SYNC (1 << 3)
314#define MDF_WAS_UP_TO_DATE (1 << 4)
315#define MDF_PEER_OUT_DATED (1 << 5)
316#define MDF_CRASHED_PRIMARY (1 << 6)
317
318enum drbd_uuid_index {
319 UI_CURRENT,
320 UI_BITMAP,
321 UI_HISTORY_START,
322 UI_HISTORY_END,
323 UI_SIZE,
324 UI_FLAGS,
325 UI_EXTENDED_SIZE
326};
327
328enum drbd_timeout_flag {
329 UT_DEFAULT = 0,
330 UT_DEGRADED = 1,
331 UT_PEER_OUTDATED = 2,
332};
333
334#define UUID_JUST_CREATED ((__u64)4)
335
336#define DRBD_MAGIC 0x83740267
337#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
338#define DRBD_MAGIC_BIG 0x835a
339#define BE_DRBD_MAGIC_BIG __constant_cpu_to_be16(DRBD_MAGIC_BIG)
340
341
342#define DRBD_MD_INDEX_INTERNAL -1
343#define DRBD_MD_INDEX_FLEX_EXT -2
344#define DRBD_MD_INDEX_FLEX_INT -3
345
346
347
348#define DRBD_NL_CREATE_DEVICE 0x01
349#define DRBD_NL_SET_DEFAULTS 0x02
350
351
352
353#define CN_IDX_STEP 6977
354
355struct drbd_nl_cfg_req {
356 int packet_type;
357 unsigned int drbd_minor;
358 int flags;
359 unsigned short tag_list[];
360};
361
362struct drbd_nl_cfg_reply {
363 int packet_type;
364 unsigned int minor;
365 int ret_code;
366 unsigned short tag_list[];
367};
368
369#endif
370