drbd: Finished the "on-no-data-accessible suspend-io;" functionality
[deliverable/linux.git] / include / linux / drbd.h
CommitLineData
b411b363
PR
1/*
2 drbd.h
3 Kernel module for 2.6.x Kernels
4
5 This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
6
7 Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
8 Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
9 Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
10
11 drbd is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
14 any later version.
15
16 drbd is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with drbd; see the file COPYING. If not, write to
23 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
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/* Altough the Linux source code makes a difference between
40 generic endianness and the bitfields' endianness, there is no
41 architecture as of Linux-2.6.24-rc4 where the bitfileds' endianness
42 does not match the generic endianness. */
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);
e7f52dfb 56#define REL_VERSION "8.3.8.1"
b411b363
PR
57#define API_VERSION 88
58#define PRO_VERSION_MIN 86
3d42b361 59#define PRO_VERSION_MAX 94
b411b363
PR
60
61
62enum drbd_io_error_p {
63 EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
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
265be2d0
PR
94enum drbd_on_no_data {
95 OND_IO_ERROR,
96 OND_SUSPEND_IO
97};
98
b411b363
PR
99/* KEEP the order, do not delete or insert. Only append. */
100enum drbd_ret_codes {
101 ERR_CODE_BASE = 100,
102 NO_ERROR = 101,
103 ERR_LOCAL_ADDR = 102,
104 ERR_PEER_ADDR = 103,
105 ERR_OPEN_DISK = 104,
106 ERR_OPEN_MD_DISK = 105,
107 ERR_DISK_NOT_BDEV = 107,
108 ERR_MD_NOT_BDEV = 108,
109 ERR_DISK_TO_SMALL = 111,
110 ERR_MD_DISK_TO_SMALL = 112,
111 ERR_BDCLAIM_DISK = 114,
112 ERR_BDCLAIM_MD_DISK = 115,
113 ERR_MD_IDX_INVALID = 116,
114 ERR_IO_MD_DISK = 118,
115 ERR_MD_INVALID = 119,
116 ERR_AUTH_ALG = 120,
117 ERR_AUTH_ALG_ND = 121,
118 ERR_NOMEM = 122,
119 ERR_DISCARD = 123,
120 ERR_DISK_CONFIGURED = 124,
121 ERR_NET_CONFIGURED = 125,
122 ERR_MANDATORY_TAG = 126,
123 ERR_MINOR_INVALID = 127,
124 ERR_INTR = 129, /* EINTR */
125 ERR_RESIZE_RESYNC = 130,
126 ERR_NO_PRIMARY = 131,
127 ERR_SYNC_AFTER = 132,
128 ERR_SYNC_AFTER_CYCLE = 133,
129 ERR_PAUSE_IS_SET = 134,
130 ERR_PAUSE_IS_CLEAR = 135,
131 ERR_PACKET_NR = 137,
132 ERR_NO_DISK = 138,
133 ERR_NOT_PROTO_C = 139,
134 ERR_NOMEM_BITMAP = 140,
135 ERR_INTEGRITY_ALG = 141, /* DRBD 8.2 only */
136 ERR_INTEGRITY_ALG_ND = 142, /* DRBD 8.2 only */
137 ERR_CPU_MASK_PARSE = 143, /* DRBD 8.2 only */
138 ERR_CSUMS_ALG = 144, /* DRBD 8.2 only */
139 ERR_CSUMS_ALG_ND = 145, /* DRBD 8.2 only */
140 ERR_VERIFY_ALG = 146, /* DRBD 8.2 only */
141 ERR_VERIFY_ALG_ND = 147, /* DRBD 8.2 only */
142 ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
143 ERR_VERIFY_RUNNING = 149, /* DRBD 8.2 only */
144 ERR_DATA_NOT_CURRENT = 150,
145 ERR_CONNECTED = 151, /* DRBD 8.3 only */
9f5180e5 146 ERR_PERM = 152,
6495d2c6 147 ERR_NEED_APV_93 = 153,
b411b363
PR
148
149 /* insert new ones above this line */
150 AFTER_LAST_ERR_CODE
151};
152
153#define DRBD_PROT_A 1
154#define DRBD_PROT_B 2
155#define DRBD_PROT_C 3
156
157enum drbd_role {
158 R_UNKNOWN = 0,
159 R_PRIMARY = 1, /* role */
160 R_SECONDARY = 2, /* role */
161 R_MASK = 3,
162};
163
164/* The order of these constants is important.
165 * The lower ones (<C_WF_REPORT_PARAMS) indicate
166 * that there is no socket!
167 * >=C_WF_REPORT_PARAMS ==> There is a socket
168 */
169enum drbd_conns {
170 C_STANDALONE,
171 C_DISCONNECTING, /* Temporal state on the way to StandAlone. */
172 C_UNCONNECTED, /* >= C_UNCONNECTED -> inc_net() succeeds */
173
174 /* These temporal states are all used on the way
175 * from >= C_CONNECTED to Unconnected.
176 * The 'disconnect reason' states
177 * I do not allow to change beween them. */
178 C_TIMEOUT,
179 C_BROKEN_PIPE,
180 C_NETWORK_FAILURE,
181 C_PROTOCOL_ERROR,
182 C_TEAR_DOWN,
183
184 C_WF_CONNECTION,
185 C_WF_REPORT_PARAMS, /* we have a socket */
186 C_CONNECTED, /* we have introduced each other */
187 C_STARTING_SYNC_S, /* starting full sync by admin request. */
188 C_STARTING_SYNC_T, /* stariing full sync by admin request. */
189 C_WF_BITMAP_S,
190 C_WF_BITMAP_T,
191 C_WF_SYNC_UUID,
192
193 /* All SyncStates are tested with this comparison
194 * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
195 C_SYNC_SOURCE,
196 C_SYNC_TARGET,
197 C_VERIFY_S,
198 C_VERIFY_T,
199 C_PAUSED_SYNC_S,
200 C_PAUSED_SYNC_T,
201 C_MASK = 31
202};
203
204enum drbd_disk_state {
205 D_DISKLESS,
206 D_ATTACHING, /* In the process of reading the meta-data */
207 D_FAILED, /* Becomes D_DISKLESS as soon as we told it the peer */
208 /* when >= D_FAILED it is legal to access mdev->bc */
209 D_NEGOTIATING, /* Late attaching state, we need to talk to the peer */
210 D_INCONSISTENT,
211 D_OUTDATED,
212 D_UNKNOWN, /* Only used for the peer, never for myself */
213 D_CONSISTENT, /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
214 D_UP_TO_DATE, /* Only this disk state allows applications' IO ! */
215 D_MASK = 15
216};
217
218union drbd_state {
219/* According to gcc's docs is the ...
220 * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
221 * Determined by ABI.
222 * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
223 * even though we transmit as "cpu_to_be32(state)",
224 * the offsets of the bitfields still need to be swapped
225 * on different endianess.
226 */
227 struct {
228#if defined(__LITTLE_ENDIAN_BITFIELD)
229 unsigned role:2 ; /* 3/4 primary/secondary/unknown */
230 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
231 unsigned conn:5 ; /* 17/32 cstates */
232 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
233 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
234 unsigned susp:1 ; /* 2/2 IO suspended no/yes */
235 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
236 unsigned peer_isp:1 ;
237 unsigned user_isp:1 ;
238 unsigned _pad:11; /* 0 unused */
239#elif defined(__BIG_ENDIAN_BITFIELD)
240 unsigned _pad:11; /* 0 unused */
241 unsigned user_isp:1 ;
242 unsigned peer_isp:1 ;
243 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
244 unsigned susp:1 ; /* 2/2 IO suspended no/yes */
245 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
246 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
247 unsigned conn:5 ; /* 17/32 cstates */
248 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
249 unsigned role:2 ; /* 3/4 primary/secondary/unknown */
250#else
251# error "this endianess is not supported"
252#endif
253 };
254 unsigned int i;
255};
256
257enum drbd_state_ret_codes {
258 SS_CW_NO_NEED = 4,
259 SS_CW_SUCCESS = 3,
260 SS_NOTHING_TO_DO = 2,
261 SS_SUCCESS = 1,
262 SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
263 SS_TWO_PRIMARIES = -1,
264 SS_NO_UP_TO_DATE_DISK = -2,
265 SS_NO_LOCAL_DISK = -4,
266 SS_NO_REMOTE_DISK = -5,
267 SS_CONNECTED_OUTDATES = -6,
268 SS_PRIMARY_NOP = -7,
269 SS_RESYNC_RUNNING = -8,
270 SS_ALREADY_STANDALONE = -9,
271 SS_CW_FAILED_BY_PEER = -10,
272 SS_IS_DISKLESS = -11,
273 SS_DEVICE_IN_USE = -12,
274 SS_NO_NET_CONFIG = -13,
275 SS_NO_VERIFY_ALG = -14, /* drbd-8.2 only */
276 SS_NEED_CONNECTION = -15, /* drbd-8.2 only */
277 SS_LOWER_THAN_OUTDATED = -16,
278 SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */
279 SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */
280 SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */
281 SS_AFTER_LAST_ERROR = -20, /* Keep this at bottom */
282};
283
284/* from drbd_strings.c */
285extern const char *drbd_conn_str(enum drbd_conns);
286extern const char *drbd_role_str(enum drbd_role);
287extern const char *drbd_disk_str(enum drbd_disk_state);
288extern const char *drbd_set_st_err_str(enum drbd_state_ret_codes);
289
290#define SHARED_SECRET_MAX 64
291
292#define MDF_CONSISTENT (1 << 0)
293#define MDF_PRIMARY_IND (1 << 1)
294#define MDF_CONNECTED_IND (1 << 2)
295#define MDF_FULL_SYNC (1 << 3)
296#define MDF_WAS_UP_TO_DATE (1 << 4)
297#define MDF_PEER_OUT_DATED (1 << 5)
298#define MDF_CRASHED_PRIMARY (1 << 6)
299
300enum drbd_uuid_index {
301 UI_CURRENT,
302 UI_BITMAP,
303 UI_HISTORY_START,
304 UI_HISTORY_END,
305 UI_SIZE, /* nl-packet: number of dirty bits */
306 UI_FLAGS, /* nl-packet: flags */
307 UI_EXTENDED_SIZE /* Everything. */
308};
309
310enum drbd_timeout_flag {
311 UT_DEFAULT = 0,
312 UT_DEGRADED = 1,
313 UT_PEER_OUTDATED = 2,
314};
315
316#define UUID_JUST_CREATED ((__u64)4)
317
318#define DRBD_MAGIC 0x83740267
319#define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
320
321/* these are of type "int" */
322#define DRBD_MD_INDEX_INTERNAL -1
323#define DRBD_MD_INDEX_FLEX_EXT -2
324#define DRBD_MD_INDEX_FLEX_INT -3
325
326/* Start of the new netlink/connector stuff */
327
328#define DRBD_NL_CREATE_DEVICE 0x01
329#define DRBD_NL_SET_DEFAULTS 0x02
330
b411b363
PR
331
332/* For searching a vacant cn_idx value */
333#define CN_IDX_STEP 6977
334
335struct drbd_nl_cfg_req {
336 int packet_type;
337 unsigned int drbd_minor;
338 int flags;
339 unsigned short tag_list[];
340};
341
342struct drbd_nl_cfg_reply {
343 int packet_type;
344 unsigned int minor;
345 int ret_code; /* enum ret_code or set_st_err_t */
346 unsigned short tag_list[]; /* only used with get_* calls */
347};
348
349#endif
This page took 0.083005 seconds and 5 git commands to generate.