Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
drbd.h
Go to the documentation of this file.
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 <[email protected]>.
9  Copyright (C) 2001-2008, Lars Ellenberg <[email protected]>.
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 /* Although 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 bitfields' 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 
55 extern const char *drbd_buildtag(void);
56 #define REL_VERSION "8.3.13"
57 #define API_VERSION 88
58 #define PRO_VERSION_MIN 86
59 #define PRO_VERSION_MAX 96
60 
61 
63  EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
66 };
67 
72 };
73 
78 };
79 
92 };
93 
97 };
98 
103 };
104 
105 /* KEEP the order, do not delete or insert. Only append. */
108  NO_ERROR = 101,
124  ERR_NOMEM = 122,
125  ERR_DISCARD = 123,
130  ERR_INTR = 129, /* EINTR */
138  ERR_NO_DISK = 138,
141  ERR_INTEGRITY_ALG = 141, /* DRBD 8.2 only */
142  ERR_INTEGRITY_ALG_ND = 142, /* DRBD 8.2 only */
143  ERR_CPU_MASK_PARSE = 143, /* DRBD 8.2 only */
144  ERR_CSUMS_ALG = 144, /* DRBD 8.2 only */
145  ERR_CSUMS_ALG_ND = 145, /* DRBD 8.2 only */
146  ERR_VERIFY_ALG = 146, /* DRBD 8.2 only */
147  ERR_VERIFY_ALG_ND = 147, /* DRBD 8.2 only */
148  ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
149  ERR_VERIFY_RUNNING = 149, /* DRBD 8.2 only */
151  ERR_CONNECTED = 151, /* DRBD 8.3 only */
152  ERR_PERM = 152,
158 
159  /* insert new ones above this line */
161 };
162 
163 #define DRBD_PROT_A 1
164 #define DRBD_PROT_B 2
165 #define DRBD_PROT_C 3
166 
167 enum drbd_role {
169  R_PRIMARY = 1, /* role */
170  R_SECONDARY = 2, /* role */
171  R_MASK = 3,
172 };
173 
174 /* The order of these constants is important.
175  * The lower ones (<C_WF_REPORT_PARAMS) indicate
176  * that there is no socket!
177  * >=C_WF_REPORT_PARAMS ==> There is a socket
178  */
181  C_DISCONNECTING, /* Temporal state on the way to StandAlone. */
182  C_UNCONNECTED, /* >= C_UNCONNECTED -> inc_net() succeeds */
183 
184  /* These temporal states are all used on the way
185  * from >= C_CONNECTED to Unconnected.
186  * The 'disconnect reason' states
187  * I do not allow to change between them. */
193 
195  C_WF_REPORT_PARAMS, /* we have a socket */
196  C_CONNECTED, /* we have introduced each other */
197  C_STARTING_SYNC_S, /* starting full sync by admin request. */
198  C_STARTING_SYNC_T, /* starting full sync by admin request. */
202 
203  /* All SyncStates are tested with this comparison
204  * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
211 
214 
215  C_MASK = 31
216 };
217 
220  D_ATTACHING, /* In the process of reading the meta-data */
221  D_FAILED, /* Becomes D_DISKLESS as soon as we told it the peer */
222  /* when >= D_FAILED it is legal to access mdev->bc */
223  D_NEGOTIATING, /* Late attaching state, we need to talk to the peer */
226  D_UNKNOWN, /* Only used for the peer, never for myself */
227  D_CONSISTENT, /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
228  D_UP_TO_DATE, /* Only this disk state allows applications' IO ! */
229  D_MASK = 15
230 };
231 
232 union drbd_state {
233 /* According to gcc's docs is the ...
234  * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
235  * Determined by ABI.
236  * pointed out by Maxim Uvarov q<[email protected]>
237  * even though we transmit as "cpu_to_be32(state)",
238  * the offsets of the bitfields still need to be swapped
239  * on different endianness.
240  */
241  struct {
242 #if defined(__LITTLE_ENDIAN_BITFIELD)
243  unsigned role:2 ; /* 3/4 primary/secondary/unknown */
244  unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
245  unsigned conn:5 ; /* 17/32 cstates */
246  unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
247  unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
248  unsigned susp:1 ; /* 2/2 IO suspended no/yes (by user) */
249  unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
250  unsigned peer_isp:1 ;
251  unsigned user_isp:1 ;
252  unsigned susp_nod:1 ; /* IO suspended because no data */
253  unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
254  unsigned _pad:9; /* 0 unused */
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 ; /* isp .. imposed sync pause */
262  unsigned susp:1 ; /* 2/2 IO suspended no/yes */
263  unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
264  unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
265  unsigned conn:5 ; /* 17/32 cstates */
266  unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
267  unsigned role:2 ; /* 3/4 primary/secondary/unknown */
268 #else
269 # error "this endianness is not supported"
270 #endif
271  };
272  unsigned int i;
273 };
274 
280  SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
293  SS_NO_VERIFY_ALG = -14, /* drbd-8.2 only */
294  SS_NEED_CONNECTION = -15, /* drbd-8.2 only */
296  SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */
297  SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */
298  SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */
299  SS_AFTER_LAST_ERROR = -20, /* Keep this at bottom */
300 };
301 
302 /* from drbd_strings.c */
303 extern const char *drbd_conn_str(enum drbd_conns);
304 extern const char *drbd_role_str(enum drbd_role);
305 extern const char *drbd_disk_str(enum drbd_disk_state);
306 extern 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 
323  UI_SIZE, /* nl-packet: number of dirty bits */
324  UI_FLAGS, /* nl-packet: flags */
325  UI_EXTENDED_SIZE /* Everything. */
326 };
327 
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 /* these are of type "int" */
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 /* Start of the new netlink/connector stuff */
347 
348 #define DRBD_NL_CREATE_DEVICE 0x01
349 #define DRBD_NL_SET_DEFAULTS 0x02
350 
351 
352 /* For searching a vacant cn_idx value */
353 #define CN_IDX_STEP 6977
354 
357  unsigned int drbd_minor;
358  int flags;
359  unsigned short tag_list[];
360 };
361 
364  unsigned int minor;
365  int ret_code; /* enum ret_code or set_st_err_t */
366  unsigned short tag_list[]; /* only used with get_* calls */
367 };
368 
369 #endif