3 Kernel module for 2.6.x Kernels
5 This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
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>.
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)
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.
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.
28 #include <linux/connector.h>
29 #include <asm/types.h>
32 #include <linux/types.h>
33 #include <asm/byteorder.h>
35 #include <sys/types.h>
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. */
44 #if __BYTE_ORDER == __LITTLE_ENDIAN
45 #define __LITTLE_ENDIAN_BITFIELD
46 #elif __BYTE_ORDER == __BIG_ENDIAN
47 #define __BIG_ENDIAN_BITFIELD
49 # error "sorry, weird endianness on this box"
55 extern const char *drbd_buildtag(void);
56 #define REL_VERSION "8.3.7"
57 #define API_VERSION 88
58 #define PRO_VERSION_MIN 86
59 #define PRO_VERSION_MAX 91
62 enum drbd_io_error_p {
63 EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
74 enum drbd_disconnect_p {
80 enum drbd_after_sb_p {
82 ASB_DISCARD_YOUNGER_PRI,
83 ASB_DISCARD_OLDER_PRI,
85 ASB_DISCARD_LEAST_CHG,
89 ASB_DISCARD_SECONDARY,
94 /* KEEP the order, do not delete or insert. Only append. */
101 ERR_OPEN_MD_DISK = 105,
102 ERR_DISK_NOT_BDEV = 107,
103 ERR_MD_NOT_BDEV = 108,
104 ERR_DISK_TO_SMALL = 111,
105 ERR_MD_DISK_TO_SMALL = 112,
106 ERR_BDCLAIM_DISK = 114,
107 ERR_BDCLAIM_MD_DISK = 115,
108 ERR_MD_IDX_INVALID = 116,
109 ERR_IO_MD_DISK = 118,
110 ERR_MD_INVALID = 119,
112 ERR_AUTH_ALG_ND = 121,
115 ERR_DISK_CONFIGURED = 124,
116 ERR_NET_CONFIGURED = 125,
117 ERR_MANDATORY_TAG = 126,
118 ERR_MINOR_INVALID = 127,
119 ERR_INTR = 129, /* EINTR */
120 ERR_RESIZE_RESYNC = 130,
121 ERR_NO_PRIMARY = 131,
122 ERR_SYNC_AFTER = 132,
123 ERR_SYNC_AFTER_CYCLE = 133,
124 ERR_PAUSE_IS_SET = 134,
125 ERR_PAUSE_IS_CLEAR = 135,
128 ERR_NOT_PROTO_C = 139,
129 ERR_NOMEM_BITMAP = 140,
130 ERR_INTEGRITY_ALG = 141, /* DRBD 8.2 only */
131 ERR_INTEGRITY_ALG_ND = 142, /* DRBD 8.2 only */
132 ERR_CPU_MASK_PARSE = 143, /* DRBD 8.2 only */
133 ERR_CSUMS_ALG = 144, /* DRBD 8.2 only */
134 ERR_CSUMS_ALG_ND = 145, /* DRBD 8.2 only */
135 ERR_VERIFY_ALG = 146, /* DRBD 8.2 only */
136 ERR_VERIFY_ALG_ND = 147, /* DRBD 8.2 only */
137 ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
138 ERR_VERIFY_RUNNING = 149, /* DRBD 8.2 only */
139 ERR_DATA_NOT_CURRENT = 150,
140 ERR_CONNECTED = 151, /* DRBD 8.3 only */
143 /* insert new ones above this line */
147 #define DRBD_PROT_A 1
148 #define DRBD_PROT_B 2
149 #define DRBD_PROT_C 3
153 R_PRIMARY = 1, /* role */
154 R_SECONDARY = 2, /* role */
158 /* The order of these constants is important.
159 * The lower ones (<C_WF_REPORT_PARAMS) indicate
160 * that there is no socket!
161 * >=C_WF_REPORT_PARAMS ==> There is a socket
165 C_DISCONNECTING, /* Temporal state on the way to StandAlone. */
166 C_UNCONNECTED, /* >= C_UNCONNECTED -> inc_net() succeeds */
168 /* These temporal states are all used on the way
169 * from >= C_CONNECTED to Unconnected.
170 * The 'disconnect reason' states
171 * I do not allow to change beween them. */
179 C_WF_REPORT_PARAMS, /* we have a socket */
180 C_CONNECTED, /* we have introduced each other */
181 C_STARTING_SYNC_S, /* starting full sync by admin request. */
182 C_STARTING_SYNC_T, /* stariing full sync by admin request. */
187 /* All SyncStates are tested with this comparison
188 * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
198 enum drbd_disk_state {
200 D_ATTACHING, /* In the process of reading the meta-data */
201 D_FAILED, /* Becomes D_DISKLESS as soon as we told it the peer */
202 /* when >= D_FAILED it is legal to access mdev->bc */
203 D_NEGOTIATING, /* Late attaching state, we need to talk to the peer */
206 D_UNKNOWN, /* Only used for the peer, never for myself */
207 D_CONSISTENT, /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
208 D_UP_TO_DATE, /* Only this disk state allows applications' IO ! */
213 /* According to gcc's docs is the ...
214 * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
216 * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
217 * even though we transmit as "cpu_to_be32(state)",
218 * the offsets of the bitfields still need to be swapped
219 * on different endianess.
222 #if defined(__LITTLE_ENDIAN_BITFIELD)
223 unsigned role:2 ; /* 3/4 primary/secondary/unknown */
224 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
225 unsigned conn:5 ; /* 17/32 cstates */
226 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
227 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
228 unsigned susp:1 ; /* 2/2 IO suspended no/yes */
229 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
230 unsigned peer_isp:1 ;
231 unsigned user_isp:1 ;
232 unsigned _pad:11; /* 0 unused */
233 #elif defined(__BIG_ENDIAN_BITFIELD)
234 unsigned _pad:11; /* 0 unused */
235 unsigned user_isp:1 ;
236 unsigned peer_isp:1 ;
237 unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
238 unsigned susp:1 ; /* 2/2 IO suspended no/yes */
239 unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
240 unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
241 unsigned conn:5 ; /* 17/32 cstates */
242 unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
243 unsigned role:2 ; /* 3/4 primary/secondary/unknown */
245 # error "this endianess is not supported"
251 enum drbd_state_ret_codes {
254 SS_NOTHING_TO_DO = 2,
256 SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
257 SS_TWO_PRIMARIES = -1,
258 SS_NO_UP_TO_DATE_DISK = -2,
259 SS_NO_LOCAL_DISK = -4,
260 SS_NO_REMOTE_DISK = -5,
261 SS_CONNECTED_OUTDATES = -6,
263 SS_RESYNC_RUNNING = -8,
264 SS_ALREADY_STANDALONE = -9,
265 SS_CW_FAILED_BY_PEER = -10,
266 SS_IS_DISKLESS = -11,
267 SS_DEVICE_IN_USE = -12,
268 SS_NO_NET_CONFIG = -13,
269 SS_NO_VERIFY_ALG = -14, /* drbd-8.2 only */
270 SS_NEED_CONNECTION = -15, /* drbd-8.2 only */
271 SS_LOWER_THAN_OUTDATED = -16,
272 SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */
273 SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */
274 SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */
275 SS_AFTER_LAST_ERROR = -20, /* Keep this at bottom */
278 /* from drbd_strings.c */
279 extern const char *drbd_conn_str(enum drbd_conns);
280 extern const char *drbd_role_str(enum drbd_role);
281 extern const char *drbd_disk_str(enum drbd_disk_state);
282 extern const char *drbd_set_st_err_str(enum drbd_state_ret_codes);
284 #define SHARED_SECRET_MAX 64
286 #define MDF_CONSISTENT (1 << 0)
287 #define MDF_PRIMARY_IND (1 << 1)
288 #define MDF_CONNECTED_IND (1 << 2)
289 #define MDF_FULL_SYNC (1 << 3)
290 #define MDF_WAS_UP_TO_DATE (1 << 4)
291 #define MDF_PEER_OUT_DATED (1 << 5)
292 #define MDF_CRASHED_PRIMARY (1 << 6)
294 enum drbd_uuid_index {
299 UI_SIZE, /* nl-packet: number of dirty bits */
300 UI_FLAGS, /* nl-packet: flags */
301 UI_EXTENDED_SIZE /* Everything. */
304 enum drbd_timeout_flag {
307 UT_PEER_OUTDATED = 2,
310 #define UUID_JUST_CREATED ((__u64)4)
312 #define DRBD_MAGIC 0x83740267
313 #define BE_DRBD_MAGIC __constant_cpu_to_be32(DRBD_MAGIC)
315 /* these are of type "int" */
316 #define DRBD_MD_INDEX_INTERNAL -1
317 #define DRBD_MD_INDEX_FLEX_EXT -2
318 #define DRBD_MD_INDEX_FLEX_INT -3
320 /* Start of the new netlink/connector stuff */
322 #define DRBD_NL_CREATE_DEVICE 0x01
323 #define DRBD_NL_SET_DEFAULTS 0x02
326 /* For searching a vacant cn_idx value */
327 #define CN_IDX_STEP 6977
329 struct drbd_nl_cfg_req {
331 unsigned int drbd_minor;
333 unsigned short tag_list[];
336 struct drbd_nl_cfg_reply {
339 int ret_code; /* enum ret_code or set_st_err_t */
340 unsigned short tag_list[]; /* only used with get_* calls */