1b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner/*
2b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  drbd.h
3b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  Kernel module for 2.6.x Kernels
4b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
5b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
6b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
7b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
8b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
9b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
10b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
11b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  drbd is free software; you can redistribute it and/or modify
12b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  it under the terms of the GNU General Public License as published by
13b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  the Free Software Foundation; either version 2, or (at your option)
14b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  any later version.
15b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
16b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  drbd is distributed in the hope that it will be useful,
17b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  but WITHOUT ANY WARRANTY; without even the implied warranty of
18b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  GNU General Public License for more details.
20b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
21b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  You should have received a copy of the GNU General Public License
22b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  along with drbd; see the file COPYING.  If not, write to
23b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
25b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner*/
26b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#ifndef DRBD_H
27b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_H
28b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <linux/connector.h>
29b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <asm/types.h>
30b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
31b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#ifdef __KERNEL__
32b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <linux/types.h>
33b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <asm/byteorder.h>
34b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#else
35b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <sys/types.h>
36b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <sys/wait.h>
37b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#include <limits.h>
38b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
3925985edcedea6396277003854657b5f3cb31a628Lucas De Marchi/* Although the Linux source code makes a difference between
40b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner   generic endianness and the bitfields' endianness, there is no
4124c4830c8ec3cbc904d84c213126a35f41a4e455Bart Van Assche   architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
42b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner   does not match the generic endianness. */
43b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
44b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#if __BYTE_ORDER == __LITTLE_ENDIAN
45b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define __LITTLE_ENDIAN_BITFIELD
46b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#elif __BYTE_ORDER == __BIG_ENDIAN
47b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define __BIG_ENDIAN_BITFIELD
48b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#else
49b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner# error "sorry, weird endianness on this box"
50b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#endif
51b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
52b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#endif
53b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
54b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerextern const char *drbd_buildtag(void);
55bf0d6e4a1138e71cafdbbb99cde430eee50c4ff1Dan Carpenter#define REL_VERSION "8.4.5"
56328e0f125bf41f4f33f684db22015f92cb44fe56Philipp Reisner#define API_VERSION 1
57b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define PRO_VERSION_MIN 86
5858ffa580a748dd16b1e5ab260bea39cdbd1e94efLars Ellenberg#define PRO_VERSION_MAX 101
59b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
60b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
61b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_io_error_p {
62b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
63b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	EP_CALL_HELPER,
64b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	EP_DETACH
65b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
66b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
67b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_fencing_p {
68cb703454a283d8dd5599e928eeea30367ca18874Philipp Reisner	FP_NOT_AVAIL = -1, /* Not a policy */
69cb703454a283d8dd5599e928eeea30367ca18874Philipp Reisner	FP_DONT_CARE = 0,
70b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	FP_RESOURCE,
71b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	FP_STONITH
72b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
73b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
74b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_disconnect_p {
75b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	DP_RECONNECT,
76b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	DP_DROP_NET_CONF,
77b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	DP_FREEZE_IO
78b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
79b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
80b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_after_sb_p {
81b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCONNECT,
82b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_YOUNGER_PRI,
83b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_OLDER_PRI,
84b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_ZERO_CHG,
85b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_LEAST_CHG,
86b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_LOCAL,
87b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_REMOTE,
88b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_CONSENSUS,
89b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_DISCARD_SECONDARY,
90b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_CALL_HELPER,
91b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ASB_VIOLENTLY
92b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
93b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
94265be2d09853d425ad14a61cda0ca63345613d0cPhilipp Reisnerenum drbd_on_no_data {
95265be2d09853d425ad14a61cda0ca63345613d0cPhilipp Reisner	OND_IO_ERROR,
96265be2d09853d425ad14a61cda0ca63345613d0cPhilipp Reisner	OND_SUSPEND_IO
97265be2d09853d425ad14a61cda0ca63345613d0cPhilipp Reisner};
98265be2d09853d425ad14a61cda0ca63345613d0cPhilipp Reisner
99422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisnerenum drbd_on_congestion {
100422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner	OC_BLOCK,
101422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner	OC_PULL_AHEAD,
102422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner	OC_DISCONNECT,
103422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner};
104422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner
105380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisnerenum drbd_read_balancing {
106380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner	RB_PREFER_LOCAL,
107380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner	RB_PREFER_REMOTE,
108380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner	RB_ROUND_ROBIN,
109380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner	RB_LEAST_PENDING,
110380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner	RB_CONGESTED_REMOTE,
111d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_32K_STRIPING,
112d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_64K_STRIPING,
113d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_128K_STRIPING,
114d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_256K_STRIPING,
115d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_512K_STRIPING,
116d60de03a6694302b691bdf858ede9cbdfb7112d6Philipp Reisner	RB_1M_STRIPING,
117380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner};
118380207d08e7c4d1b19c0323777278992b4fbf9d6Philipp Reisner
119b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner/* KEEP the order, do not delete or insert. Only append. */
120116676ca621a862a8124969772f4dd61c8b40eeeAndreas Gruenbacherenum drbd_ret_code {
121b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CODE_BASE		= 100,
122b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	NO_ERROR		= 101,
123b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_LOCAL_ADDR		= 102,
124b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_PEER_ADDR		= 103,
125b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_OPEN_DISK		= 104,
126b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_OPEN_MD_DISK	= 105,
127b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_DISK_NOT_BDEV	= 107,
128b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_MD_NOT_BDEV		= 108,
12967b58bf723b083d4776cd7c9959246ef46c0d36fLars Ellenberg	ERR_DISK_TOO_SMALL	= 111,
13067b58bf723b083d4776cd7c9959246ef46c0d36fLars Ellenberg	ERR_MD_DISK_TOO_SMALL	= 112,
131b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_BDCLAIM_DISK	= 114,
132b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_BDCLAIM_MD_DISK	= 115,
133b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_MD_IDX_INVALID	= 116,
134b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_IO_MD_DISK		= 118,
135b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_MD_INVALID          = 119,
136b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_AUTH_ALG		= 120,
137b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_AUTH_ALG_ND		= 121,
138b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NOMEM		= 122,
139eb12010e9af119c84e6b2214064a98681027e0e3Lars Ellenberg	ERR_DISCARD_IMPOSSIBLE	= 123,
140b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_DISK_CONFIGURED	= 124,
141b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NET_CONFIGURED	= 125,
142b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_MANDATORY_TAG	= 126,
143b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_MINOR_INVALID	= 127,
144b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_INTR		= 129, /* EINTR */
145b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_RESIZE_RESYNC	= 130,
146b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NO_PRIMARY		= 131,
14795f8efd08bcce65df994049a292b94e56c7ada67Andreas Gruenbacher	ERR_RESYNC_AFTER	= 132,
14895f8efd08bcce65df994049a292b94e56c7ada67Andreas Gruenbacher	ERR_RESYNC_AFTER_CYCLE	= 133,
149b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_PAUSE_IS_SET	= 134,
150b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_PAUSE_IS_CLEAR	= 135,
151b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_PACKET_NR		= 137,
152b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NO_DISK		= 138,
153b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NOT_PROTO_C		= 139,
154b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_NOMEM_BITMAP	= 140,
155b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_INTEGRITY_ALG	= 141, /* DRBD 8.2 only */
156b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_INTEGRITY_ALG_ND	= 142, /* DRBD 8.2 only */
157b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CPU_MASK_PARSE	= 143, /* DRBD 8.2 only */
158b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CSUMS_ALG		= 144, /* DRBD 8.2 only */
159b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CSUMS_ALG_ND	= 145, /* DRBD 8.2 only */
160b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_VERIFY_ALG		= 146, /* DRBD 8.2 only */
161b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_VERIFY_ALG_ND	= 147, /* DRBD 8.2 only */
162b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
163b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_VERIFY_RUNNING	= 149, /* DRBD 8.2 only */
164b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_DATA_NOT_CURRENT	= 150,
165b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	ERR_CONNECTED		= 151, /* DRBD 8.3 only */
1669f5180e5c331d7b3ccc35e1a78072235d38f9f34Philipp Reisner	ERR_PERM		= 152,
1676495d2c6d04f4c45411fdb1b40527c24015f39d6Philipp Reisner	ERR_NEED_APV_93		= 153,
16847ff2d0a8e7ce87fed180729e8341f650bf585c8Philipp Reisner	ERR_STONITH_AND_PROT_A  = 154,
169422028b1ca4c07995af82a18abced022ff4c296cPhilipp Reisner	ERR_CONG_NOT_PROTO_A	= 155,
170cd88d030d41a9b0100fd5fee872024e6ebc8b276Philipp Reisner	ERR_PIC_AFTER_DEP	= 156,
171cd88d030d41a9b0100fd5fee872024e6ebc8b276Philipp Reisner	ERR_PIC_PEER_DEP	= 157,
172789c1b626cb490acb36cf481b45040b324f60fdeAndreas Gruenbacher	ERR_RES_NOT_KNOWN	= 158,
173789c1b626cb490acb36cf481b45040b324f60fdeAndreas Gruenbacher	ERR_RES_IN_USE		= 159,
174774b305518a68a50df4f479bcf79da2add724e6ePhilipp Reisner	ERR_MINOR_CONFIGURED    = 160,
175774b305518a68a50df4f479bcf79da2add724e6ePhilipp Reisner	ERR_MINOR_EXISTS	= 161,
1763b98c0c2093d1f92e5b7394ae0b13d142e7ef880Lars Ellenberg	ERR_INVALID_REQUEST	= 162,
177b032b6fa3528d6eed972db32257cb316a66e0dacPhilipp Reisner	ERR_NEED_APV_100	= 163,
178dcb20d1a8e7d9602e52a9b673ae4d7f746d2cbb2Philipp Reisner	ERR_NEED_ALLOW_TWO_PRI  = 164,
179d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg	ERR_MD_UNCLEAN          = 165,
180d752b2696072ed52fd5afab08b601e2220a3b87ePhilipp Reisner	ERR_MD_LAYOUT_CONNECTED = 166,
181d752b2696072ed52fd5afab08b601e2220a3b87ePhilipp Reisner	ERR_MD_LAYOUT_TOO_BIG   = 167,
182d752b2696072ed52fd5afab08b601e2220a3b87ePhilipp Reisner	ERR_MD_LAYOUT_TOO_SMALL = 168,
183d752b2696072ed52fd5afab08b601e2220a3b87ePhilipp Reisner	ERR_MD_LAYOUT_NO_FIT    = 169,
184d752b2696072ed52fd5afab08b601e2220a3b87ePhilipp Reisner	ERR_IMPLICIT_SHRINK     = 170,
185b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	/* insert new ones above this line */
186b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	AFTER_LAST_ERR_CODE
187b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
188b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
189b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_PROT_A   1
190b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_PROT_B   2
191b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_PROT_C   3
192b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
193b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_role {
194b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	R_UNKNOWN = 0,
195b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	R_PRIMARY = 1,     /* role */
196b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	R_SECONDARY = 2,   /* role */
197b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	R_MASK = 3,
198b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
199b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
200b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner/* The order of these constants is important.
201b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * The lower ones (<C_WF_REPORT_PARAMS) indicate
202b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * that there is no socket!
203b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * >=C_WF_REPORT_PARAMS ==> There is a socket
204b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner */
205b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_conns {
206b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_STANDALONE,
207b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_DISCONNECTING,  /* Temporal state on the way to StandAlone. */
208b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_UNCONNECTED,    /* >= C_UNCONNECTED -> inc_net() succeeds */
209b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
210b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	/* These temporal states are all used on the way
211b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	 * from >= C_CONNECTED to Unconnected.
212b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	 * The 'disconnect reason' states
21325985edcedea6396277003854657b5f3cb31a628Lucas De Marchi	 * I do not allow to change between them. */
214b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_TIMEOUT,
215b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_BROKEN_PIPE,
216b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_NETWORK_FAILURE,
217b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_PROTOCOL_ERROR,
218b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_TEAR_DOWN,
219b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
220b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_WF_CONNECTION,
221b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_WF_REPORT_PARAMS, /* we have a socket */
222b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_CONNECTED,      /* we have introduced each other */
223b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_STARTING_SYNC_S,  /* starting full sync by admin request. */
22424c4830c8ec3cbc904d84c213126a35f41a4e455Bart Van Assche	C_STARTING_SYNC_T,  /* starting full sync by admin request. */
225b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_WF_BITMAP_S,
226b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_WF_BITMAP_T,
227b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_WF_SYNC_UUID,
228b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
229b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	/* All SyncStates are tested with this comparison
230b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	 * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
231b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_SYNC_SOURCE,
232b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_SYNC_TARGET,
233b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_VERIFY_S,
234b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_VERIFY_T,
235b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_PAUSED_SYNC_S,
236b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_PAUSED_SYNC_T,
23767531718d8f1259f01ab84c2aa25f7b03c7afd46Philipp Reisner
23867531718d8f1259f01ab84c2aa25f7b03c7afd46Philipp Reisner	C_AHEAD,
23967531718d8f1259f01ab84c2aa25f7b03c7afd46Philipp Reisner	C_BEHIND,
24067531718d8f1259f01ab84c2aa25f7b03c7afd46Philipp Reisner
241b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	C_MASK = 31
242b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
243b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
244b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_disk_state {
245b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_DISKLESS,
246b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_ATTACHING,      /* In the process of reading the meta-data */
247b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_FAILED,         /* Becomes D_DISKLESS as soon as we told it the peer */
2488fe39aac0578cbb0abf27e1be70ff581e0c1d836Philipp Reisner			  /* when >= D_FAILED it is legal to access mdev->ldev */
249b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_NEGOTIATING,    /* Late attaching state, we need to talk to the peer */
250b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_INCONSISTENT,
251b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_OUTDATED,
252b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_UNKNOWN,       /* Only used for the peer, never for myself */
253b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_CONSISTENT,     /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
254b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_UP_TO_DATE,       /* Only this disk state allows applications' IO ! */
255b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	D_MASK = 15
256b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
257b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
258b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerunion drbd_state {
259b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner/* According to gcc's docs is the ...
260b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
261b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * Determined by ABI.
262b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
263b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * even though we transmit as "cpu_to_be32(state)",
264b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner * the offsets of the bitfields still need to be swapped
26524c4830c8ec3cbc904d84c213126a35f41a4e455Bart Van Assche * on different endianness.
266b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner */
267b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	struct {
268b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#if defined(__LITTLE_ENDIAN_BITFIELD)
269b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned role:2 ;   /* 3/4	 primary/secondary/unknown */
270b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned peer:2 ;   /* 3/4	 primary/secondary/unknown */
271b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned conn:5 ;   /* 17/32	 cstates */
272b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned disk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
273b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned pdsk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
274fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned susp:1 ;   /* 2/2	 IO suspended no/yes (by user) */
275b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
276b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned peer_isp:1 ;
277b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned user_isp:1 ;
278fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned susp_nod:1 ; /* IO suspended because no data */
279fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
280fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned _pad:9;   /* 0	 unused */
281b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#elif defined(__BIG_ENDIAN_BITFIELD)
282fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned _pad:9;
283fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned susp_fen:1 ;
284fb22c402ffdf61dd121795b5809de587185d5240Philipp Reisner		unsigned susp_nod:1 ;
285b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned user_isp:1 ;
286b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned peer_isp:1 ;
287b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
288b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned susp:1 ;   /* 2/2	 IO suspended  no/yes */
289b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned pdsk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
290b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned disk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
291b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned conn:5 ;   /* 17/32	 cstates */
292b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned peer:2 ;   /* 3/4	 primary/secondary/unknown */
293b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner		unsigned role:2 ;   /* 3/4	 primary/secondary/unknown */
294b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#else
29524c4830c8ec3cbc904d84c213126a35f41a4e455Bart Van Assche# error "this endianness is not supported"
296b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#endif
297b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	};
298b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	unsigned int i;
299b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
300b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
301c8b325632f0e5ffdaeca3d1f3be77c9399316a40Andreas Gruenbacherenum drbd_state_rv {
302b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_CW_NO_NEED = 4,
303b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_CW_SUCCESS = 3,
304b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NOTHING_TO_DO = 2,
305b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_SUCCESS = 1,
306b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
307b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_TWO_PRIMARIES = -1,
308b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NO_UP_TO_DATE_DISK = -2,
309b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NO_LOCAL_DISK = -4,
310b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NO_REMOTE_DISK = -5,
311b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_CONNECTED_OUTDATES = -6,
312b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_PRIMARY_NOP = -7,
313b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_RESYNC_RUNNING = -8,
314b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_ALREADY_STANDALONE = -9,
315b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_CW_FAILED_BY_PEER = -10,
316b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_IS_DISKLESS = -11,
317b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_DEVICE_IN_USE = -12,
318b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NO_NET_CONFIG = -13,
319b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NO_VERIFY_ALG = -14,       /* drbd-8.2 only */
320b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NEED_CONNECTION = -15,    /* drbd-8.2 only */
321b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_LOWER_THAN_OUTDATED = -16,
322b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_NOT_SUPPORTED = -17,      /* drbd-8.2 only */
323b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_IN_TRANSIENT_STATE = -18,  /* Retry after the next state change */
324b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	SS_CONCURRENT_ST_CHG = -19,   /* Concurrent cluster side state change! */
325047e95e259e81d7b97eca10cda0aa93082531ac1Philipp Reisner	SS_O_VOL_PEER_PRI = -20,
3262bd5ed5d6713594eb2b4d234d01217d506279c7dPhilipp Reisner	SS_OUTDATE_WO_CONN = -21,
3272bd5ed5d6713594eb2b4d234d01217d506279c7dPhilipp Reisner	SS_AFTER_LAST_ERROR = -22,    /* Keep this at bottom */
328b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
329b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
330b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define SHARED_SECRET_MAX 64
331b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
332b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_CONSISTENT		(1 << 0)
333b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_PRIMARY_IND		(1 << 1)
334b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_CONNECTED_IND	(1 << 2)
335b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_FULL_SYNC		(1 << 3)
336b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_WAS_UP_TO_DATE	(1 << 4)
337b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define MDF_PEER_OUT_DATED	(1 << 5)
338d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg#define MDF_CRASHED_PRIMARY	(1 << 6)
339d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg#define MDF_AL_CLEAN		(1 << 7)
3409a51ab1c1b3c1e21f076cdd571bbe6ca7d1b504cPhilipp Reisner#define MDF_AL_DISABLED		(1 << 8)
341b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
342b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_uuid_index {
343b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_CURRENT,
344b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_BITMAP,
345b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_HISTORY_START,
346b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_HISTORY_END,
347b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_SIZE,      /* nl-packet: number of dirty bits */
348b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_FLAGS,     /* nl-packet: flags */
349b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UI_EXTENDED_SIZE   /* Everything. */
350b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
351b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
352b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisnerenum drbd_timeout_flag {
353b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UT_DEFAULT      = 0,
354b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UT_DEGRADED     = 1,
355b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner	UT_PEER_OUTDATED = 2,
356b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner};
357b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
358b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define UUID_JUST_CREATED ((__u64)4)
359b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
360d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg/* magic numbers used in meta data and network packets */
361b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_MAGIC 0x83740267
3620b70a13dac014ec9274640b9e945bde493ba365ePhilipp Reisner#define DRBD_MAGIC_BIG 0x835a
3630c8e36d9b843be56e4e43d4ef3c3eb6a97205599Andreas Gruenbacher#define DRBD_MAGIC_100 0x8620ec20
364b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
365d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg#define DRBD_MD_MAGIC_07   (DRBD_MAGIC+3)
366d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg#define DRBD_MD_MAGIC_08   (DRBD_MAGIC+4)
367d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg#define DRBD_MD_MAGIC_84_UNCLEAN	(DRBD_MAGIC+5)
368d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg
369d5d7ebd42250620a6da2a8f6943c024391433488Lars Ellenberg
3707ad651b52218eea3f9280dbb353dfe0c42742d85Lars Ellenberg/* how I came up with this magic?
3717ad651b52218eea3f9280dbb353dfe0c42742d85Lars Ellenberg * base64 decode "actlog==" ;) */
3727ad651b52218eea3f9280dbb353dfe0c42742d85Lars Ellenberg#define DRBD_AL_MAGIC 0x69cb65a2
3737ad651b52218eea3f9280dbb353dfe0c42742d85Lars Ellenberg
374b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner/* these are of type "int" */
375b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_MD_INDEX_INTERNAL -1
376b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_MD_INDEX_FLEX_EXT -2
377b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#define DRBD_MD_INDEX_FLEX_INT -3
378b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner
379f44d0436db1ea02f2a08bec40a854550a93e90a8Andreas Gruenbacher#define DRBD_CPU_MASK_SIZE 32
380f44d0436db1ea02f2a08bec40a854550a93e90a8Andreas Gruenbacher
381b411b3637fa71fce9cf2acf0639009500f5892fePhilipp Reisner#endif
382