cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

drbd.h (10311B)


      1/* SPDX-License-Identifier: GPL-2.0-or-later */
      2/*
      3  drbd.h
      4  Kernel module for 2.6.x Kernels
      5
      6  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
      7
      8  Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
      9  Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
     10  Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
     11
     12
     13*/
     14#ifndef DRBD_H
     15#define DRBD_H
     16#include <asm/types.h>
     17
     18#ifdef __KERNEL__
     19#include <linux/types.h>
     20#include <asm/byteorder.h>
     21#else
     22#include <sys/types.h>
     23#include <sys/wait.h>
     24#include <limits.h>
     25
     26/* Although the Linux source code makes a difference between
     27   generic endianness and the bitfields' endianness, there is no
     28   architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
     29   does not match the generic endianness. */
     30
     31#if __BYTE_ORDER == __LITTLE_ENDIAN
     32#define __LITTLE_ENDIAN_BITFIELD
     33#elif __BYTE_ORDER == __BIG_ENDIAN
     34#define __BIG_ENDIAN_BITFIELD
     35#else
     36# error "sorry, weird endianness on this box"
     37#endif
     38
     39#endif
     40
     41extern const char *drbd_buildtag(void);
     42#define REL_VERSION "8.4.11"
     43#define API_VERSION 1
     44#define PRO_VERSION_MIN 86
     45#define PRO_VERSION_MAX 101
     46
     47
     48enum drbd_io_error_p {
     49	EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
     50	EP_CALL_HELPER,
     51	EP_DETACH
     52};
     53
     54enum drbd_fencing_p {
     55	FP_NOT_AVAIL = -1, /* Not a policy */
     56	FP_DONT_CARE = 0,
     57	FP_RESOURCE,
     58	FP_STONITH
     59};
     60
     61enum drbd_disconnect_p {
     62	DP_RECONNECT,
     63	DP_DROP_NET_CONF,
     64	DP_FREEZE_IO
     65};
     66
     67enum drbd_after_sb_p {
     68	ASB_DISCONNECT,
     69	ASB_DISCARD_YOUNGER_PRI,
     70	ASB_DISCARD_OLDER_PRI,
     71	ASB_DISCARD_ZERO_CHG,
     72	ASB_DISCARD_LEAST_CHG,
     73	ASB_DISCARD_LOCAL,
     74	ASB_DISCARD_REMOTE,
     75	ASB_CONSENSUS,
     76	ASB_DISCARD_SECONDARY,
     77	ASB_CALL_HELPER,
     78	ASB_VIOLENTLY
     79};
     80
     81enum drbd_on_no_data {
     82	OND_IO_ERROR,
     83	OND_SUSPEND_IO
     84};
     85
     86enum drbd_on_congestion {
     87	OC_BLOCK,
     88	OC_PULL_AHEAD,
     89	OC_DISCONNECT,
     90};
     91
     92enum drbd_read_balancing {
     93	RB_PREFER_LOCAL,
     94	RB_PREFER_REMOTE,
     95	RB_ROUND_ROBIN,
     96	RB_LEAST_PENDING,
     97	RB_CONGESTED_REMOTE,
     98	RB_32K_STRIPING,
     99	RB_64K_STRIPING,
    100	RB_128K_STRIPING,
    101	RB_256K_STRIPING,
    102	RB_512K_STRIPING,
    103	RB_1M_STRIPING,
    104};
    105
    106/* KEEP the order, do not delete or insert. Only append. */
    107enum drbd_ret_code {
    108	ERR_CODE_BASE		= 100,
    109	NO_ERROR		= 101,
    110	ERR_LOCAL_ADDR		= 102,
    111	ERR_PEER_ADDR		= 103,
    112	ERR_OPEN_DISK		= 104,
    113	ERR_OPEN_MD_DISK	= 105,
    114	ERR_DISK_NOT_BDEV	= 107,
    115	ERR_MD_NOT_BDEV		= 108,
    116	ERR_DISK_TOO_SMALL	= 111,
    117	ERR_MD_DISK_TOO_SMALL	= 112,
    118	ERR_BDCLAIM_DISK	= 114,
    119	ERR_BDCLAIM_MD_DISK	= 115,
    120	ERR_MD_IDX_INVALID	= 116,
    121	ERR_IO_MD_DISK		= 118,
    122	ERR_MD_INVALID          = 119,
    123	ERR_AUTH_ALG		= 120,
    124	ERR_AUTH_ALG_ND		= 121,
    125	ERR_NOMEM		= 122,
    126	ERR_DISCARD_IMPOSSIBLE	= 123,
    127	ERR_DISK_CONFIGURED	= 124,
    128	ERR_NET_CONFIGURED	= 125,
    129	ERR_MANDATORY_TAG	= 126,
    130	ERR_MINOR_INVALID	= 127,
    131	ERR_INTR		= 129, /* EINTR */
    132	ERR_RESIZE_RESYNC	= 130,
    133	ERR_NO_PRIMARY		= 131,
    134	ERR_RESYNC_AFTER	= 132,
    135	ERR_RESYNC_AFTER_CYCLE	= 133,
    136	ERR_PAUSE_IS_SET	= 134,
    137	ERR_PAUSE_IS_CLEAR	= 135,
    138	ERR_PACKET_NR		= 137,
    139	ERR_NO_DISK		= 138,
    140	ERR_NOT_PROTO_C		= 139,
    141	ERR_NOMEM_BITMAP	= 140,
    142	ERR_INTEGRITY_ALG	= 141, /* DRBD 8.2 only */
    143	ERR_INTEGRITY_ALG_ND	= 142, /* DRBD 8.2 only */
    144	ERR_CPU_MASK_PARSE	= 143, /* DRBD 8.2 only */
    145	ERR_CSUMS_ALG		= 144, /* DRBD 8.2 only */
    146	ERR_CSUMS_ALG_ND	= 145, /* DRBD 8.2 only */
    147	ERR_VERIFY_ALG		= 146, /* DRBD 8.2 only */
    148	ERR_VERIFY_ALG_ND	= 147, /* DRBD 8.2 only */
    149	ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
    150	ERR_VERIFY_RUNNING	= 149, /* DRBD 8.2 only */
    151	ERR_DATA_NOT_CURRENT	= 150,
    152	ERR_CONNECTED		= 151, /* DRBD 8.3 only */
    153	ERR_PERM		= 152,
    154	ERR_NEED_APV_93		= 153,
    155	ERR_STONITH_AND_PROT_A  = 154,
    156	ERR_CONG_NOT_PROTO_A	= 155,
    157	ERR_PIC_AFTER_DEP	= 156,
    158	ERR_PIC_PEER_DEP	= 157,
    159	ERR_RES_NOT_KNOWN	= 158,
    160	ERR_RES_IN_USE		= 159,
    161	ERR_MINOR_CONFIGURED    = 160,
    162	ERR_MINOR_OR_VOLUME_EXISTS = 161,
    163	ERR_INVALID_REQUEST	= 162,
    164	ERR_NEED_APV_100	= 163,
    165	ERR_NEED_ALLOW_TWO_PRI  = 164,
    166	ERR_MD_UNCLEAN          = 165,
    167	ERR_MD_LAYOUT_CONNECTED = 166,
    168	ERR_MD_LAYOUT_TOO_BIG   = 167,
    169	ERR_MD_LAYOUT_TOO_SMALL = 168,
    170	ERR_MD_LAYOUT_NO_FIT    = 169,
    171	ERR_IMPLICIT_SHRINK     = 170,
    172	/* insert new ones above this line */
    173	AFTER_LAST_ERR_CODE
    174};
    175
    176#define DRBD_PROT_A   1
    177#define DRBD_PROT_B   2
    178#define DRBD_PROT_C   3
    179
    180enum drbd_role {
    181	R_UNKNOWN = 0,
    182	R_PRIMARY = 1,     /* role */
    183	R_SECONDARY = 2,   /* role */
    184	R_MASK = 3,
    185};
    186
    187/* The order of these constants is important.
    188 * The lower ones (<C_WF_REPORT_PARAMS) indicate
    189 * that there is no socket!
    190 * >=C_WF_REPORT_PARAMS ==> There is a socket
    191 */
    192enum drbd_conns {
    193	C_STANDALONE,
    194	C_DISCONNECTING,  /* Temporal state on the way to StandAlone. */
    195	C_UNCONNECTED,    /* >= C_UNCONNECTED -> inc_net() succeeds */
    196
    197	/* These temporal states are all used on the way
    198	 * from >= C_CONNECTED to Unconnected.
    199	 * The 'disconnect reason' states
    200	 * I do not allow to change between them. */
    201	C_TIMEOUT,
    202	C_BROKEN_PIPE,
    203	C_NETWORK_FAILURE,
    204	C_PROTOCOL_ERROR,
    205	C_TEAR_DOWN,
    206
    207	C_WF_CONNECTION,
    208	C_WF_REPORT_PARAMS, /* we have a socket */
    209	C_CONNECTED,      /* we have introduced each other */
    210	C_STARTING_SYNC_S,  /* starting full sync by admin request. */
    211	C_STARTING_SYNC_T,  /* starting full sync by admin request. */
    212	C_WF_BITMAP_S,
    213	C_WF_BITMAP_T,
    214	C_WF_SYNC_UUID,
    215
    216	/* All SyncStates are tested with this comparison
    217	 * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
    218	C_SYNC_SOURCE,
    219	C_SYNC_TARGET,
    220	C_VERIFY_S,
    221	C_VERIFY_T,
    222	C_PAUSED_SYNC_S,
    223	C_PAUSED_SYNC_T,
    224
    225	C_AHEAD,
    226	C_BEHIND,
    227
    228	C_MASK = 31
    229};
    230
    231enum drbd_disk_state {
    232	D_DISKLESS,
    233	D_ATTACHING,      /* In the process of reading the meta-data */
    234	D_FAILED,         /* Becomes D_DISKLESS as soon as we told it the peer */
    235			  /* when >= D_FAILED it is legal to access mdev->ldev */
    236	D_NEGOTIATING,    /* Late attaching state, we need to talk to the peer */
    237	D_INCONSISTENT,
    238	D_OUTDATED,
    239	D_UNKNOWN,       /* Only used for the peer, never for myself */
    240	D_CONSISTENT,     /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
    241	D_UP_TO_DATE,       /* Only this disk state allows applications' IO ! */
    242	D_MASK = 15
    243};
    244
    245union drbd_state {
    246/* According to gcc's docs is the ...
    247 * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
    248 * Determined by ABI.
    249 * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
    250 * even though we transmit as "cpu_to_be32(state)",
    251 * the offsets of the bitfields still need to be swapped
    252 * on different endianness.
    253 */
    254	struct {
    255#if defined(__LITTLE_ENDIAN_BITFIELD)
    256		unsigned role:2 ;   /* 3/4	 primary/secondary/unknown */
    257		unsigned peer:2 ;   /* 3/4	 primary/secondary/unknown */
    258		unsigned conn:5 ;   /* 17/32	 cstates */
    259		unsigned disk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
    260		unsigned pdsk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
    261		unsigned susp:1 ;   /* 2/2	 IO suspended no/yes (by user) */
    262		unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
    263		unsigned peer_isp:1 ;
    264		unsigned user_isp:1 ;
    265		unsigned susp_nod:1 ; /* IO suspended because no data */
    266		unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
    267		unsigned _pad:9;   /* 0	 unused */
    268#elif defined(__BIG_ENDIAN_BITFIELD)
    269		unsigned _pad:9;
    270		unsigned susp_fen:1 ;
    271		unsigned susp_nod:1 ;
    272		unsigned user_isp:1 ;
    273		unsigned peer_isp:1 ;
    274		unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
    275		unsigned susp:1 ;   /* 2/2	 IO suspended  no/yes */
    276		unsigned pdsk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
    277		unsigned disk:4 ;   /* 8/16	 from D_DISKLESS to D_UP_TO_DATE */
    278		unsigned conn:5 ;   /* 17/32	 cstates */
    279		unsigned peer:2 ;   /* 3/4	 primary/secondary/unknown */
    280		unsigned role:2 ;   /* 3/4	 primary/secondary/unknown */
    281#else
    282# error "this endianness is not supported"
    283#endif
    284	};
    285	unsigned int i;
    286};
    287
    288enum drbd_state_rv {
    289	SS_CW_NO_NEED = 4,
    290	SS_CW_SUCCESS = 3,
    291	SS_NOTHING_TO_DO = 2,
    292	SS_SUCCESS = 1,
    293	SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
    294	SS_TWO_PRIMARIES = -1,
    295	SS_NO_UP_TO_DATE_DISK = -2,
    296	SS_NO_LOCAL_DISK = -4,
    297	SS_NO_REMOTE_DISK = -5,
    298	SS_CONNECTED_OUTDATES = -6,
    299	SS_PRIMARY_NOP = -7,
    300	SS_RESYNC_RUNNING = -8,
    301	SS_ALREADY_STANDALONE = -9,
    302	SS_CW_FAILED_BY_PEER = -10,
    303	SS_IS_DISKLESS = -11,
    304	SS_DEVICE_IN_USE = -12,
    305	SS_NO_NET_CONFIG = -13,
    306	SS_NO_VERIFY_ALG = -14,       /* drbd-8.2 only */
    307	SS_NEED_CONNECTION = -15,    /* drbd-8.2 only */
    308	SS_LOWER_THAN_OUTDATED = -16,
    309	SS_NOT_SUPPORTED = -17,      /* drbd-8.2 only */
    310	SS_IN_TRANSIENT_STATE = -18,  /* Retry after the next state change */
    311	SS_CONCURRENT_ST_CHG = -19,   /* Concurrent cluster side state change! */
    312	SS_O_VOL_PEER_PRI = -20,
    313	SS_OUTDATE_WO_CONN = -21,
    314	SS_AFTER_LAST_ERROR = -22,    /* Keep this at bottom */
    315};
    316
    317#define SHARED_SECRET_MAX 64
    318
    319#define MDF_CONSISTENT		(1 << 0)
    320#define MDF_PRIMARY_IND		(1 << 1)
    321#define MDF_CONNECTED_IND	(1 << 2)
    322#define MDF_FULL_SYNC		(1 << 3)
    323#define MDF_WAS_UP_TO_DATE	(1 << 4)
    324#define MDF_PEER_OUT_DATED	(1 << 5)
    325#define MDF_CRASHED_PRIMARY	(1 << 6)
    326#define MDF_AL_CLEAN		(1 << 7)
    327#define MDF_AL_DISABLED		(1 << 8)
    328
    329#define MAX_PEERS 32
    330
    331enum drbd_uuid_index {
    332	UI_CURRENT,
    333	UI_BITMAP,
    334	UI_HISTORY_START,
    335	UI_HISTORY_END,
    336	UI_SIZE,      /* nl-packet: number of dirty bits */
    337	UI_FLAGS,     /* nl-packet: flags */
    338	UI_EXTENDED_SIZE   /* Everything. */
    339};
    340
    341#define HISTORY_UUIDS MAX_PEERS
    342
    343enum drbd_timeout_flag {
    344	UT_DEFAULT      = 0,
    345	UT_DEGRADED     = 1,
    346	UT_PEER_OUTDATED = 2,
    347};
    348
    349enum drbd_notification_type {
    350	NOTIFY_EXISTS,
    351	NOTIFY_CREATE,
    352	NOTIFY_CHANGE,
    353	NOTIFY_DESTROY,
    354	NOTIFY_CALL,
    355	NOTIFY_RESPONSE,
    356
    357	NOTIFY_CONTINUES = 0x8000,
    358	NOTIFY_FLAGS = NOTIFY_CONTINUES,
    359};
    360
    361enum drbd_peer_state {
    362	P_INCONSISTENT = 3,
    363	P_OUTDATED = 4,
    364	P_DOWN = 5,
    365	P_PRIMARY = 6,
    366	P_FENCING = 7,
    367};
    368
    369#define UUID_JUST_CREATED ((__u64)4)
    370
    371enum write_ordering_e {
    372	WO_NONE,
    373	WO_DRAIN_IO,
    374	WO_BDEV_FLUSH,
    375	WO_BIO_BARRIER
    376};
    377
    378/* magic numbers used in meta data and network packets */
    379#define DRBD_MAGIC 0x83740267
    380#define DRBD_MAGIC_BIG 0x835a
    381#define DRBD_MAGIC_100 0x8620ec20
    382
    383#define DRBD_MD_MAGIC_07   (DRBD_MAGIC+3)
    384#define DRBD_MD_MAGIC_08   (DRBD_MAGIC+4)
    385#define DRBD_MD_MAGIC_84_UNCLEAN	(DRBD_MAGIC+5)
    386
    387
    388/* how I came up with this magic?
    389 * base64 decode "actlog==" ;) */
    390#define DRBD_AL_MAGIC 0x69cb65a2
    391
    392/* these are of type "int" */
    393#define DRBD_MD_INDEX_INTERNAL -1
    394#define DRBD_MD_INDEX_FLEX_EXT -2
    395#define DRBD_MD_INDEX_FLEX_INT -3
    396
    397#define DRBD_CPU_MASK_SIZE 32
    398
    399#endif