drbd.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. /*
  2. drbd.h
  3. Kernel module for 2.6.x Kernels
  4. This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
  5. Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
  6. Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
  7. Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
  8. drbd is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2, or (at your option)
  11. any later version.
  12. drbd is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with drbd; see the file COPYING. If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #ifndef DRBD_H
  21. #define DRBD_H
  22. #include <linux/connector.h>
  23. #include <asm/types.h>
  24. #ifdef __KERNEL__
  25. #include <linux/types.h>
  26. #include <asm/byteorder.h>
  27. #else
  28. #include <sys/types.h>
  29. #include <sys/wait.h>
  30. #include <limits.h>
  31. /* Although the Linux source code makes a difference between
  32. generic endianness and the bitfields' endianness, there is no
  33. architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
  34. does not match the generic endianness. */
  35. #if __BYTE_ORDER == __LITTLE_ENDIAN
  36. #define __LITTLE_ENDIAN_BITFIELD
  37. #elif __BYTE_ORDER == __BIG_ENDIAN
  38. #define __BIG_ENDIAN_BITFIELD
  39. #else
  40. # error "sorry, weird endianness on this box"
  41. #endif
  42. #endif
  43. extern const char *drbd_buildtag(void);
  44. #define REL_VERSION "8.4.5"
  45. #define API_VERSION 1
  46. #define PRO_VERSION_MIN 86
  47. #define PRO_VERSION_MAX 101
  48. enum drbd_io_error_p {
  49. EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
  50. EP_CALL_HELPER,
  51. EP_DETACH
  52. };
  53. enum drbd_fencing_p {
  54. FP_NOT_AVAIL = -1, /* Not a policy */
  55. FP_DONT_CARE = 0,
  56. FP_RESOURCE,
  57. FP_STONITH
  58. };
  59. enum drbd_disconnect_p {
  60. DP_RECONNECT,
  61. DP_DROP_NET_CONF,
  62. DP_FREEZE_IO
  63. };
  64. enum drbd_after_sb_p {
  65. ASB_DISCONNECT,
  66. ASB_DISCARD_YOUNGER_PRI,
  67. ASB_DISCARD_OLDER_PRI,
  68. ASB_DISCARD_ZERO_CHG,
  69. ASB_DISCARD_LEAST_CHG,
  70. ASB_DISCARD_LOCAL,
  71. ASB_DISCARD_REMOTE,
  72. ASB_CONSENSUS,
  73. ASB_DISCARD_SECONDARY,
  74. ASB_CALL_HELPER,
  75. ASB_VIOLENTLY
  76. };
  77. enum drbd_on_no_data {
  78. OND_IO_ERROR,
  79. OND_SUSPEND_IO
  80. };
  81. enum drbd_on_congestion {
  82. OC_BLOCK,
  83. OC_PULL_AHEAD,
  84. OC_DISCONNECT,
  85. };
  86. enum drbd_read_balancing {
  87. RB_PREFER_LOCAL,
  88. RB_PREFER_REMOTE,
  89. RB_ROUND_ROBIN,
  90. RB_LEAST_PENDING,
  91. RB_CONGESTED_REMOTE,
  92. RB_32K_STRIPING,
  93. RB_64K_STRIPING,
  94. RB_128K_STRIPING,
  95. RB_256K_STRIPING,
  96. RB_512K_STRIPING,
  97. RB_1M_STRIPING,
  98. };
  99. /* KEEP the order, do not delete or insert. Only append. */
  100. enum drbd_ret_code {
  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_TOO_SMALL = 111,
  110. ERR_MD_DISK_TOO_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_IMPOSSIBLE = 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_RESYNC_AFTER = 132,
  128. ERR_RESYNC_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 */
  146. ERR_PERM = 152,
  147. ERR_NEED_APV_93 = 153,
  148. ERR_STONITH_AND_PROT_A = 154,
  149. ERR_CONG_NOT_PROTO_A = 155,
  150. ERR_PIC_AFTER_DEP = 156,
  151. ERR_PIC_PEER_DEP = 157,
  152. ERR_RES_NOT_KNOWN = 158,
  153. ERR_RES_IN_USE = 159,
  154. ERR_MINOR_CONFIGURED = 160,
  155. ERR_MINOR_OR_VOLUME_EXISTS = 161,
  156. ERR_INVALID_REQUEST = 162,
  157. ERR_NEED_APV_100 = 163,
  158. ERR_NEED_ALLOW_TWO_PRI = 164,
  159. ERR_MD_UNCLEAN = 165,
  160. ERR_MD_LAYOUT_CONNECTED = 166,
  161. ERR_MD_LAYOUT_TOO_BIG = 167,
  162. ERR_MD_LAYOUT_TOO_SMALL = 168,
  163. ERR_MD_LAYOUT_NO_FIT = 169,
  164. ERR_IMPLICIT_SHRINK = 170,
  165. /* insert new ones above this line */
  166. AFTER_LAST_ERR_CODE
  167. };
  168. #define DRBD_PROT_A 1
  169. #define DRBD_PROT_B 2
  170. #define DRBD_PROT_C 3
  171. enum drbd_role {
  172. R_UNKNOWN = 0,
  173. R_PRIMARY = 1, /* role */
  174. R_SECONDARY = 2, /* role */
  175. R_MASK = 3,
  176. };
  177. /* The order of these constants is important.
  178. * The lower ones (<C_WF_REPORT_PARAMS) indicate
  179. * that there is no socket!
  180. * >=C_WF_REPORT_PARAMS ==> There is a socket
  181. */
  182. enum drbd_conns {
  183. C_STANDALONE,
  184. C_DISCONNECTING, /* Temporal state on the way to StandAlone. */
  185. C_UNCONNECTED, /* >= C_UNCONNECTED -> inc_net() succeeds */
  186. /* These temporal states are all used on the way
  187. * from >= C_CONNECTED to Unconnected.
  188. * The 'disconnect reason' states
  189. * I do not allow to change between them. */
  190. C_TIMEOUT,
  191. C_BROKEN_PIPE,
  192. C_NETWORK_FAILURE,
  193. C_PROTOCOL_ERROR,
  194. C_TEAR_DOWN,
  195. C_WF_CONNECTION,
  196. C_WF_REPORT_PARAMS, /* we have a socket */
  197. C_CONNECTED, /* we have introduced each other */
  198. C_STARTING_SYNC_S, /* starting full sync by admin request. */
  199. C_STARTING_SYNC_T, /* starting full sync by admin request. */
  200. C_WF_BITMAP_S,
  201. C_WF_BITMAP_T,
  202. C_WF_SYNC_UUID,
  203. /* All SyncStates are tested with this comparison
  204. * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
  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. C_AHEAD,
  212. C_BEHIND,
  213. C_MASK = 31
  214. };
  215. enum drbd_disk_state {
  216. D_DISKLESS,
  217. D_ATTACHING, /* In the process of reading the meta-data */
  218. D_FAILED, /* Becomes D_DISKLESS as soon as we told it the peer */
  219. /* when >= D_FAILED it is legal to access mdev->ldev */
  220. D_NEGOTIATING, /* Late attaching state, we need to talk to the peer */
  221. D_INCONSISTENT,
  222. D_OUTDATED,
  223. D_UNKNOWN, /* Only used for the peer, never for myself */
  224. D_CONSISTENT, /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
  225. D_UP_TO_DATE, /* Only this disk state allows applications' IO ! */
  226. D_MASK = 15
  227. };
  228. union drbd_state {
  229. /* According to gcc's docs is the ...
  230. * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
  231. * Determined by ABI.
  232. * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
  233. * even though we transmit as "cpu_to_be32(state)",
  234. * the offsets of the bitfields still need to be swapped
  235. * on different endianness.
  236. */
  237. struct {
  238. #if defined(__LITTLE_ENDIAN_BITFIELD)
  239. unsigned role:2 ; /* 3/4 primary/secondary/unknown */
  240. unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
  241. unsigned conn:5 ; /* 17/32 cstates */
  242. unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
  243. unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
  244. unsigned susp:1 ; /* 2/2 IO suspended no/yes (by user) */
  245. unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
  246. unsigned peer_isp:1 ;
  247. unsigned user_isp:1 ;
  248. unsigned susp_nod:1 ; /* IO suspended because no data */
  249. unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
  250. unsigned _pad:9; /* 0 unused */
  251. #elif defined(__BIG_ENDIAN_BITFIELD)
  252. unsigned _pad:9;
  253. unsigned susp_fen:1 ;
  254. unsigned susp_nod:1 ;
  255. unsigned user_isp:1 ;
  256. unsigned peer_isp:1 ;
  257. unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
  258. unsigned susp:1 ; /* 2/2 IO suspended no/yes */
  259. unsigned pdsk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
  260. unsigned disk:4 ; /* 8/16 from D_DISKLESS to D_UP_TO_DATE */
  261. unsigned conn:5 ; /* 17/32 cstates */
  262. unsigned peer:2 ; /* 3/4 primary/secondary/unknown */
  263. unsigned role:2 ; /* 3/4 primary/secondary/unknown */
  264. #else
  265. # error "this endianness is not supported"
  266. #endif
  267. };
  268. unsigned int i;
  269. };
  270. enum drbd_state_rv {
  271. SS_CW_NO_NEED = 4,
  272. SS_CW_SUCCESS = 3,
  273. SS_NOTHING_TO_DO = 2,
  274. SS_SUCCESS = 1,
  275. SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
  276. SS_TWO_PRIMARIES = -1,
  277. SS_NO_UP_TO_DATE_DISK = -2,
  278. SS_NO_LOCAL_DISK = -4,
  279. SS_NO_REMOTE_DISK = -5,
  280. SS_CONNECTED_OUTDATES = -6,
  281. SS_PRIMARY_NOP = -7,
  282. SS_RESYNC_RUNNING = -8,
  283. SS_ALREADY_STANDALONE = -9,
  284. SS_CW_FAILED_BY_PEER = -10,
  285. SS_IS_DISKLESS = -11,
  286. SS_DEVICE_IN_USE = -12,
  287. SS_NO_NET_CONFIG = -13,
  288. SS_NO_VERIFY_ALG = -14, /* drbd-8.2 only */
  289. SS_NEED_CONNECTION = -15, /* drbd-8.2 only */
  290. SS_LOWER_THAN_OUTDATED = -16,
  291. SS_NOT_SUPPORTED = -17, /* drbd-8.2 only */
  292. SS_IN_TRANSIENT_STATE = -18, /* Retry after the next state change */
  293. SS_CONCURRENT_ST_CHG = -19, /* Concurrent cluster side state change! */
  294. SS_O_VOL_PEER_PRI = -20,
  295. SS_OUTDATE_WO_CONN = -21,
  296. SS_AFTER_LAST_ERROR = -22, /* Keep this at bottom */
  297. };
  298. #define SHARED_SECRET_MAX 64
  299. #define MDF_CONSISTENT (1 << 0)
  300. #define MDF_PRIMARY_IND (1 << 1)
  301. #define MDF_CONNECTED_IND (1 << 2)
  302. #define MDF_FULL_SYNC (1 << 3)
  303. #define MDF_WAS_UP_TO_DATE (1 << 4)
  304. #define MDF_PEER_OUT_DATED (1 << 5)
  305. #define MDF_CRASHED_PRIMARY (1 << 6)
  306. #define MDF_AL_CLEAN (1 << 7)
  307. #define MDF_AL_DISABLED (1 << 8)
  308. enum drbd_uuid_index {
  309. UI_CURRENT,
  310. UI_BITMAP,
  311. UI_HISTORY_START,
  312. UI_HISTORY_END,
  313. UI_SIZE, /* nl-packet: number of dirty bits */
  314. UI_FLAGS, /* nl-packet: flags */
  315. UI_EXTENDED_SIZE /* Everything. */
  316. };
  317. enum drbd_timeout_flag {
  318. UT_DEFAULT = 0,
  319. UT_DEGRADED = 1,
  320. UT_PEER_OUTDATED = 2,
  321. };
  322. #define UUID_JUST_CREATED ((__u64)4)
  323. /* magic numbers used in meta data and network packets */
  324. #define DRBD_MAGIC 0x83740267
  325. #define DRBD_MAGIC_BIG 0x835a
  326. #define DRBD_MAGIC_100 0x8620ec20
  327. #define DRBD_MD_MAGIC_07 (DRBD_MAGIC+3)
  328. #define DRBD_MD_MAGIC_08 (DRBD_MAGIC+4)
  329. #define DRBD_MD_MAGIC_84_UNCLEAN (DRBD_MAGIC+5)
  330. /* how I came up with this magic?
  331. * base64 decode "actlog==" ;) */
  332. #define DRBD_AL_MAGIC 0x69cb65a2
  333. /* these are of type "int" */
  334. #define DRBD_MD_INDEX_INTERNAL -1
  335. #define DRBD_MD_INDEX_FLEX_EXT -2
  336. #define DRBD_MD_INDEX_FLEX_INT -3
  337. #define DRBD_CPU_MASK_SIZE 32
  338. #endif