drbd: move UAPI headers to include/uapi/linux/
authorChristoph Böhmwalder <christoph.boehmwalder@linbit.com>
Wed, 6 May 2026 12:45:40 +0000 (14:45 +0200)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 May 2026 01:23:23 +0000 (19:23 -0600)
drbd.h and drbd_limits.h contain only type definitions, enums, and
constants shared between kernel and userspace. These should be part of
UAPI.

Split the genl_api header into two: the genlmsghdr and the enums are
UAPI, the rest stays there for now (it will be removed by one of the
next commits in this series).

drbd_config.h is clearly DRBD-internal, so move it there.

Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20260506124541.1951772-2-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_buildtag.c
drivers/block/drbd/drbd_config.h [new file with mode: 0644]
drivers/block/drbd/drbd_int.h
include/linux/drbd.h [deleted file]
include/linux/drbd_config.h [deleted file]
include/linux/drbd_genl_api.h
include/linux/drbd_limits.h [deleted file]
include/uapi/linux/drbd.h [new file with mode: 0644]
include/uapi/linux/drbd_limits.h [new file with mode: 0644]

index cb1aa66..cd03894 100644 (file)
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-only
-#include <linux/drbd_config.h>
+#include "drbd_config.h"
 #include <linux/module.h>
 
 const char *drbd_buildtag(void)
diff --git a/drivers/block/drbd/drbd_config.h b/drivers/block/drbd/drbd_config.h
new file mode 100644 (file)
index 0000000..d215365
--- /dev/null
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * drbd_config.h
+ * DRBD's compile time configuration.
+ */
+
+#ifndef DRBD_CONFIG_H
+#define DRBD_CONFIG_H
+
+extern const char *drbd_buildtag(void);
+
+#define REL_VERSION "8.4.11"
+#define PRO_VERSION_MIN 86
+#define PRO_VERSION_MAX 101
+
+#endif
index f6d6276..f3d746a 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/prefetch.h>
 #include <linux/drbd_genl_api.h>
 #include <linux/drbd.h>
-#include <linux/drbd_config.h>
+#include "drbd_config.h"
 #include "drbd_strings.h"
 #include "drbd_state.h"
 #include "drbd_protocol.h"
diff --git a/include/linux/drbd.h b/include/linux/drbd.h
deleted file mode 100644 (file)
index 5468a23..0000000
+++ /dev/null
@@ -1,392 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
-  drbd.h
-  Kernel module for 2.6.x Kernels
-
-  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
-
-  Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
-  Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
-  Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
-
-
-*/
-#ifndef DRBD_H
-#define DRBD_H
-#include <asm/types.h>
-
-#ifdef __KERNEL__
-#include <linux/types.h>
-#include <asm/byteorder.h>
-#else
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <limits.h>
-
-/* Although the Linux source code makes a difference between
-   generic endianness and the bitfields' endianness, there is no
-   architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
-   does not match the generic endianness. */
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN_BITFIELD
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#define __BIG_ENDIAN_BITFIELD
-#else
-# error "sorry, weird endianness on this box"
-#endif
-
-#endif
-
-enum drbd_io_error_p {
-       EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
-       EP_CALL_HELPER,
-       EP_DETACH
-};
-
-enum drbd_fencing_p {
-       FP_NOT_AVAIL = -1, /* Not a policy */
-       FP_DONT_CARE = 0,
-       FP_RESOURCE,
-       FP_STONITH
-};
-
-enum drbd_disconnect_p {
-       DP_RECONNECT,
-       DP_DROP_NET_CONF,
-       DP_FREEZE_IO
-};
-
-enum drbd_after_sb_p {
-       ASB_DISCONNECT,
-       ASB_DISCARD_YOUNGER_PRI,
-       ASB_DISCARD_OLDER_PRI,
-       ASB_DISCARD_ZERO_CHG,
-       ASB_DISCARD_LEAST_CHG,
-       ASB_DISCARD_LOCAL,
-       ASB_DISCARD_REMOTE,
-       ASB_CONSENSUS,
-       ASB_DISCARD_SECONDARY,
-       ASB_CALL_HELPER,
-       ASB_VIOLENTLY
-};
-
-enum drbd_on_no_data {
-       OND_IO_ERROR,
-       OND_SUSPEND_IO
-};
-
-enum drbd_on_congestion {
-       OC_BLOCK,
-       OC_PULL_AHEAD,
-       OC_DISCONNECT,
-};
-
-enum drbd_read_balancing {
-       RB_PREFER_LOCAL,
-       RB_PREFER_REMOTE,
-       RB_ROUND_ROBIN,
-       RB_LEAST_PENDING,
-       RB_CONGESTED_REMOTE,
-       RB_32K_STRIPING,
-       RB_64K_STRIPING,
-       RB_128K_STRIPING,
-       RB_256K_STRIPING,
-       RB_512K_STRIPING,
-       RB_1M_STRIPING,
-};
-
-/* KEEP the order, do not delete or insert. Only append. */
-enum drbd_ret_code {
-       ERR_CODE_BASE           = 100,
-       NO_ERROR                = 101,
-       ERR_LOCAL_ADDR          = 102,
-       ERR_PEER_ADDR           = 103,
-       ERR_OPEN_DISK           = 104,
-       ERR_OPEN_MD_DISK        = 105,
-       ERR_DISK_NOT_BDEV       = 107,
-       ERR_MD_NOT_BDEV         = 108,
-       ERR_DISK_TOO_SMALL      = 111,
-       ERR_MD_DISK_TOO_SMALL   = 112,
-       ERR_BDCLAIM_DISK        = 114,
-       ERR_BDCLAIM_MD_DISK     = 115,
-       ERR_MD_IDX_INVALID      = 116,
-       ERR_IO_MD_DISK          = 118,
-       ERR_MD_INVALID          = 119,
-       ERR_AUTH_ALG            = 120,
-       ERR_AUTH_ALG_ND         = 121,
-       ERR_NOMEM               = 122,
-       ERR_DISCARD_IMPOSSIBLE  = 123,
-       ERR_DISK_CONFIGURED     = 124,
-       ERR_NET_CONFIGURED      = 125,
-       ERR_MANDATORY_TAG       = 126,
-       ERR_MINOR_INVALID       = 127,
-       ERR_INTR                = 129, /* EINTR */
-       ERR_RESIZE_RESYNC       = 130,
-       ERR_NO_PRIMARY          = 131,
-       ERR_RESYNC_AFTER        = 132,
-       ERR_RESYNC_AFTER_CYCLE  = 133,
-       ERR_PAUSE_IS_SET        = 134,
-       ERR_PAUSE_IS_CLEAR      = 135,
-       ERR_PACKET_NR           = 137,
-       ERR_NO_DISK             = 138,
-       ERR_NOT_PROTO_C         = 139,
-       ERR_NOMEM_BITMAP        = 140,
-       ERR_INTEGRITY_ALG       = 141, /* DRBD 8.2 only */
-       ERR_INTEGRITY_ALG_ND    = 142, /* DRBD 8.2 only */
-       ERR_CPU_MASK_PARSE      = 143, /* DRBD 8.2 only */
-       ERR_CSUMS_ALG           = 144, /* DRBD 8.2 only */
-       ERR_CSUMS_ALG_ND        = 145, /* DRBD 8.2 only */
-       ERR_VERIFY_ALG          = 146, /* DRBD 8.2 only */
-       ERR_VERIFY_ALG_ND       = 147, /* DRBD 8.2 only */
-       ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
-       ERR_VERIFY_RUNNING      = 149, /* DRBD 8.2 only */
-       ERR_DATA_NOT_CURRENT    = 150,
-       ERR_CONNECTED           = 151, /* DRBD 8.3 only */
-       ERR_PERM                = 152,
-       ERR_NEED_APV_93         = 153,
-       ERR_STONITH_AND_PROT_A  = 154,
-       ERR_CONG_NOT_PROTO_A    = 155,
-       ERR_PIC_AFTER_DEP       = 156,
-       ERR_PIC_PEER_DEP        = 157,
-       ERR_RES_NOT_KNOWN       = 158,
-       ERR_RES_IN_USE          = 159,
-       ERR_MINOR_CONFIGURED    = 160,
-       ERR_MINOR_OR_VOLUME_EXISTS = 161,
-       ERR_INVALID_REQUEST     = 162,
-       ERR_NEED_APV_100        = 163,
-       ERR_NEED_ALLOW_TWO_PRI  = 164,
-       ERR_MD_UNCLEAN          = 165,
-       ERR_MD_LAYOUT_CONNECTED = 166,
-       ERR_MD_LAYOUT_TOO_BIG   = 167,
-       ERR_MD_LAYOUT_TOO_SMALL = 168,
-       ERR_MD_LAYOUT_NO_FIT    = 169,
-       ERR_IMPLICIT_SHRINK     = 170,
-       /* insert new ones above this line */
-       AFTER_LAST_ERR_CODE
-};
-
-#define DRBD_PROT_A   1
-#define DRBD_PROT_B   2
-#define DRBD_PROT_C   3
-
-enum drbd_role {
-       R_UNKNOWN = 0,
-       R_PRIMARY = 1,     /* role */
-       R_SECONDARY = 2,   /* role */
-       R_MASK = 3,
-};
-
-/* The order of these constants is important.
- * The lower ones (<C_WF_REPORT_PARAMS) indicate
- * that there is no socket!
- * >=C_WF_REPORT_PARAMS ==> There is a socket
- */
-enum drbd_conns {
-       C_STANDALONE,
-       C_DISCONNECTING,  /* Temporal state on the way to StandAlone. */
-       C_UNCONNECTED,    /* >= C_UNCONNECTED -> inc_net() succeeds */
-
-       /* These temporal states are all used on the way
-        * from >= C_CONNECTED to Unconnected.
-        * The 'disconnect reason' states
-        * I do not allow to change between them. */
-       C_TIMEOUT,
-       C_BROKEN_PIPE,
-       C_NETWORK_FAILURE,
-       C_PROTOCOL_ERROR,
-       C_TEAR_DOWN,
-
-       C_WF_CONNECTION,
-       C_WF_REPORT_PARAMS, /* we have a socket */
-       C_CONNECTED,      /* we have introduced each other */
-       C_STARTING_SYNC_S,  /* starting full sync by admin request. */
-       C_STARTING_SYNC_T,  /* starting full sync by admin request. */
-       C_WF_BITMAP_S,
-       C_WF_BITMAP_T,
-       C_WF_SYNC_UUID,
-
-       /* All SyncStates are tested with this comparison
-        * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
-       C_SYNC_SOURCE,
-       C_SYNC_TARGET,
-       C_VERIFY_S,
-       C_VERIFY_T,
-       C_PAUSED_SYNC_S,
-       C_PAUSED_SYNC_T,
-
-       C_AHEAD,
-       C_BEHIND,
-
-       C_MASK = 31
-};
-
-enum drbd_disk_state {
-       D_DISKLESS,
-       D_ATTACHING,      /* In the process of reading the meta-data */
-       D_FAILED,         /* Becomes D_DISKLESS as soon as we told it the peer */
-                         /* when >= D_FAILED it is legal to access mdev->ldev */
-       D_NEGOTIATING,    /* Late attaching state, we need to talk to the peer */
-       D_INCONSISTENT,
-       D_OUTDATED,
-       D_UNKNOWN,       /* Only used for the peer, never for myself */
-       D_CONSISTENT,     /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
-       D_UP_TO_DATE,       /* Only this disk state allows applications' IO ! */
-       D_MASK = 15
-};
-
-union drbd_state {
-/* According to gcc's docs is the ...
- * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
- * Determined by ABI.
- * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
- * even though we transmit as "cpu_to_be32(state)",
- * the offsets of the bitfields still need to be swapped
- * on different endianness.
- */
-       struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-               unsigned role:2 ;   /* 3/4       primary/secondary/unknown */
-               unsigned peer:2 ;   /* 3/4       primary/secondary/unknown */
-               unsigned conn:5 ;   /* 17/32     cstates */
-               unsigned disk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
-               unsigned pdsk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
-               unsigned susp:1 ;   /* 2/2       IO suspended no/yes (by user) */
-               unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
-               unsigned peer_isp:1 ;
-               unsigned user_isp:1 ;
-               unsigned susp_nod:1 ; /* IO suspended because no data */
-               unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
-               unsigned _pad:9;   /* 0  unused */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-               unsigned _pad:9;
-               unsigned susp_fen:1 ;
-               unsigned susp_nod:1 ;
-               unsigned user_isp:1 ;
-               unsigned peer_isp:1 ;
-               unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
-               unsigned susp:1 ;   /* 2/2       IO suspended  no/yes */
-               unsigned pdsk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
-               unsigned disk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
-               unsigned conn:5 ;   /* 17/32     cstates */
-               unsigned peer:2 ;   /* 3/4       primary/secondary/unknown */
-               unsigned role:2 ;   /* 3/4       primary/secondary/unknown */
-#else
-# error "this endianness is not supported"
-#endif
-       };
-       unsigned int i;
-};
-
-enum drbd_state_rv {
-       SS_CW_NO_NEED = 4,
-       SS_CW_SUCCESS = 3,
-       SS_NOTHING_TO_DO = 2,
-       SS_SUCCESS = 1,
-       SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
-       SS_TWO_PRIMARIES = -1,
-       SS_NO_UP_TO_DATE_DISK = -2,
-       SS_NO_LOCAL_DISK = -4,
-       SS_NO_REMOTE_DISK = -5,
-       SS_CONNECTED_OUTDATES = -6,
-       SS_PRIMARY_NOP = -7,
-       SS_RESYNC_RUNNING = -8,
-       SS_ALREADY_STANDALONE = -9,
-       SS_CW_FAILED_BY_PEER = -10,
-       SS_IS_DISKLESS = -11,
-       SS_DEVICE_IN_USE = -12,
-       SS_NO_NET_CONFIG = -13,
-       SS_NO_VERIFY_ALG = -14,       /* drbd-8.2 only */
-       SS_NEED_CONNECTION = -15,    /* drbd-8.2 only */
-       SS_LOWER_THAN_OUTDATED = -16,
-       SS_NOT_SUPPORTED = -17,      /* drbd-8.2 only */
-       SS_IN_TRANSIENT_STATE = -18,  /* Retry after the next state change */
-       SS_CONCURRENT_ST_CHG = -19,   /* Concurrent cluster side state change! */
-       SS_O_VOL_PEER_PRI = -20,
-       SS_OUTDATE_WO_CONN = -21,
-       SS_AFTER_LAST_ERROR = -22,    /* Keep this at bottom */
-};
-
-#define SHARED_SECRET_MAX 64
-
-#define MDF_CONSISTENT         (1 << 0)
-#define MDF_PRIMARY_IND                (1 << 1)
-#define MDF_CONNECTED_IND      (1 << 2)
-#define MDF_FULL_SYNC          (1 << 3)
-#define MDF_WAS_UP_TO_DATE     (1 << 4)
-#define MDF_PEER_OUT_DATED     (1 << 5)
-#define MDF_CRASHED_PRIMARY    (1 << 6)
-#define MDF_AL_CLEAN           (1 << 7)
-#define MDF_AL_DISABLED                (1 << 8)
-
-#define MAX_PEERS 32
-
-enum drbd_uuid_index {
-       UI_CURRENT,
-       UI_BITMAP,
-       UI_HISTORY_START,
-       UI_HISTORY_END,
-       UI_SIZE,      /* nl-packet: number of dirty bits */
-       UI_FLAGS,     /* nl-packet: flags */
-       UI_EXTENDED_SIZE   /* Everything. */
-};
-
-#define HISTORY_UUIDS MAX_PEERS
-
-enum drbd_timeout_flag {
-       UT_DEFAULT      = 0,
-       UT_DEGRADED     = 1,
-       UT_PEER_OUTDATED = 2,
-};
-
-enum drbd_notification_type {
-       NOTIFY_EXISTS,
-       NOTIFY_CREATE,
-       NOTIFY_CHANGE,
-       NOTIFY_DESTROY,
-       NOTIFY_CALL,
-       NOTIFY_RESPONSE,
-
-       NOTIFY_CONTINUES = 0x8000,
-       NOTIFY_FLAGS = NOTIFY_CONTINUES,
-};
-
-enum drbd_peer_state {
-       P_INCONSISTENT = 3,
-       P_OUTDATED = 4,
-       P_DOWN = 5,
-       P_PRIMARY = 6,
-       P_FENCING = 7,
-};
-
-#define UUID_JUST_CREATED ((__u64)4)
-
-enum write_ordering_e {
-       WO_NONE,
-       WO_DRAIN_IO,
-       WO_BDEV_FLUSH,
-       WO_BIO_BARRIER
-};
-
-/* magic numbers used in meta data and network packets */
-#define DRBD_MAGIC 0x83740267
-#define DRBD_MAGIC_BIG 0x835a
-#define DRBD_MAGIC_100 0x8620ec20
-
-#define DRBD_MD_MAGIC_07   (DRBD_MAGIC+3)
-#define DRBD_MD_MAGIC_08   (DRBD_MAGIC+4)
-#define DRBD_MD_MAGIC_84_UNCLEAN       (DRBD_MAGIC+5)
-
-
-/* how I came up with this magic?
- * base64 decode "actlog==" ;) */
-#define DRBD_AL_MAGIC 0x69cb65a2
-
-/* these are of type "int" */
-#define DRBD_MD_INDEX_INTERNAL -1
-#define DRBD_MD_INDEX_FLEX_EXT -2
-#define DRBD_MD_INDEX_FLEX_INT -3
-
-#define DRBD_CPU_MASK_SIZE 32
-
-#endif
diff --git a/include/linux/drbd_config.h b/include/linux/drbd_config.h
deleted file mode 100644 (file)
index d215365..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * drbd_config.h
- * DRBD's compile time configuration.
- */
-
-#ifndef DRBD_CONFIG_H
-#define DRBD_CONFIG_H
-
-extern const char *drbd_buildtag(void);
-
-#define REL_VERSION "8.4.11"
-#define PRO_VERSION_MIN 86
-#define PRO_VERSION_MAX 101
-
-#endif
index 70682c0..19d2639 100644 (file)
@@ -2,46 +2,6 @@
 #ifndef DRBD_GENL_STRUCT_H
 #define DRBD_GENL_STRUCT_H
 
-/**
- * struct drbd_genlmsghdr - DRBD specific header used in NETLINK_GENERIC requests
- * @minor:
- *     For admin requests (user -> kernel): which minor device to operate on.
- *     For (unicast) replies or informational (broadcast) messages
- *     (kernel -> user): which minor device the information is about.
- *     If we do not operate on minors, but on connections or resources,
- *     the minor value shall be (~0), and the attribute DRBD_NLA_CFG_CONTEXT
- *     is used instead.
- * @flags: possible operation modifiers (relevant only for user->kernel):
- *     DRBD_GENL_F_SET_DEFAULTS
- * @volume:
- *     When creating a new minor (adding it to a resource), the resource needs
- *     to know which volume number within the resource this is supposed to be.
- *     The volume number corresponds to the same volume number on the remote side,
- *     whereas the minor number on the remote side may be different
- *     (union with flags).
- * @ret_code: kernel->userland unicast cfg reply return code (union with flags);
- */
-struct drbd_genlmsghdr {
-       __u32 minor;
-       union {
-       __u32 flags;
-       __s32 ret_code;
-       };
-};
-
-/* To be used in drbd_genlmsghdr.flags */
-enum {
-       DRBD_GENL_F_SET_DEFAULTS = 1,
-};
-
-enum drbd_state_info_bcast_reason {
-       SIB_GET_STATUS_REPLY = 1,
-       SIB_STATE_CHANGE = 2,
-       SIB_HELPER_PRE = 3,
-       SIB_HELPER_POST = 4,
-       SIB_SYNC_PROGRESS = 5,
-};
-
 /* hack around predefined gcc/cpp "linux=1",
  * we cannot possibly include <1/drbd_genl.h> */
 #undef linux
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h
deleted file mode 100644 (file)
index 5b042fb..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
-  drbd_limits.h
-  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
-*/
-
-/*
- * Our current limitations.
- * Some of them are hard limits,
- * some of them are arbitrary range limits, that make it easier to provide
- * feedback about nonsense settings for certain configurable values.
- */
-
-#ifndef DRBD_LIMITS_H
-#define DRBD_LIMITS_H 1
-
-#define DEBUG_RANGE_CHECK 0
-
-#define DRBD_MINOR_COUNT_MIN 1U
-#define DRBD_MINOR_COUNT_MAX 255U
-#define DRBD_MINOR_COUNT_DEF 32U
-#define DRBD_MINOR_COUNT_SCALE '1'
-
-#define DRBD_VOLUME_MAX 65534U
-
-#define DRBD_DIALOG_REFRESH_MIN 0U
-#define DRBD_DIALOG_REFRESH_MAX 600U
-#define DRBD_DIALOG_REFRESH_SCALE '1'
-
-/* valid port number */
-#define DRBD_PORT_MIN 1U
-#define DRBD_PORT_MAX 0xffffU
-#define DRBD_PORT_SCALE '1'
-
-/* startup { */
-  /* if you want more than 3.4 days, disable */
-#define DRBD_WFC_TIMEOUT_MIN 0U
-#define DRBD_WFC_TIMEOUT_MAX 300000U
-#define DRBD_WFC_TIMEOUT_DEF 0U
-#define DRBD_WFC_TIMEOUT_SCALE '1'
-
-#define DRBD_DEGR_WFC_TIMEOUT_MIN 0U
-#define DRBD_DEGR_WFC_TIMEOUT_MAX 300000U
-#define DRBD_DEGR_WFC_TIMEOUT_DEF 0U
-#define DRBD_DEGR_WFC_TIMEOUT_SCALE '1'
-
-#define DRBD_OUTDATED_WFC_TIMEOUT_MIN 0U
-#define DRBD_OUTDATED_WFC_TIMEOUT_MAX 300000U
-#define DRBD_OUTDATED_WFC_TIMEOUT_DEF 0U
-#define DRBD_OUTDATED_WFC_TIMEOUT_SCALE '1'
-/* }*/
-
-/* net { */
-  /* timeout, unit centi seconds
-   * more than one minute timeout is not useful */
-#define DRBD_TIMEOUT_MIN 1U
-#define DRBD_TIMEOUT_MAX 600U
-#define DRBD_TIMEOUT_DEF 60U       /* 6 seconds */
-#define DRBD_TIMEOUT_SCALE '1'
-
- /* If backing disk takes longer than disk_timeout, mark the disk as failed */
-#define DRBD_DISK_TIMEOUT_MIN 0U    /* 0 = disabled */
-#define DRBD_DISK_TIMEOUT_MAX 6000U /* 10 Minutes */
-#define DRBD_DISK_TIMEOUT_DEF 0U    /* disabled */
-#define DRBD_DISK_TIMEOUT_SCALE '1'
-
-  /* active connection retries when C_WF_CONNECTION */
-#define DRBD_CONNECT_INT_MIN 1U
-#define DRBD_CONNECT_INT_MAX 120U
-#define DRBD_CONNECT_INT_DEF 10U   /* seconds */
-#define DRBD_CONNECT_INT_SCALE '1'
-
-  /* keep-alive probes when idle */
-#define DRBD_PING_INT_MIN 1U
-#define DRBD_PING_INT_MAX 120U
-#define DRBD_PING_INT_DEF 10U
-#define DRBD_PING_INT_SCALE '1'
-
- /* timeout for the ping packets.*/
-#define DRBD_PING_TIMEO_MIN  1U
-#define DRBD_PING_TIMEO_MAX  300U
-#define DRBD_PING_TIMEO_DEF  5U
-#define DRBD_PING_TIMEO_SCALE '1'
-
-  /* max number of write requests between write barriers */
-#define DRBD_MAX_EPOCH_SIZE_MIN 1U
-#define DRBD_MAX_EPOCH_SIZE_MAX 20000U
-#define DRBD_MAX_EPOCH_SIZE_DEF 2048U
-#define DRBD_MAX_EPOCH_SIZE_SCALE '1'
-
-  /* I don't think that a tcp send buffer of more than 10M is useful */
-#define DRBD_SNDBUF_SIZE_MIN  0U
-#define DRBD_SNDBUF_SIZE_MAX  (10U<<20)
-#define DRBD_SNDBUF_SIZE_DEF  0U
-#define DRBD_SNDBUF_SIZE_SCALE '1'
-
-#define DRBD_RCVBUF_SIZE_MIN  0U
-#define DRBD_RCVBUF_SIZE_MAX  (10U<<20)
-#define DRBD_RCVBUF_SIZE_DEF  0U
-#define DRBD_RCVBUF_SIZE_SCALE '1'
-
-  /* @4k PageSize -> 128kB - 512MB */
-#define DRBD_MAX_BUFFERS_MIN  32U
-#define DRBD_MAX_BUFFERS_MAX  131072U
-#define DRBD_MAX_BUFFERS_DEF  2048U
-#define DRBD_MAX_BUFFERS_SCALE '1'
-
-  /* @4k PageSize -> 4kB - 512MB */
-#define DRBD_UNPLUG_WATERMARK_MIN  1U
-#define DRBD_UNPLUG_WATERMARK_MAX  131072U
-#define DRBD_UNPLUG_WATERMARK_DEF (DRBD_MAX_BUFFERS_DEF/16)
-#define DRBD_UNPLUG_WATERMARK_SCALE '1'
-
-  /* 0 is disabled.
-   * 200 should be more than enough even for very short timeouts */
-#define DRBD_KO_COUNT_MIN  0U
-#define DRBD_KO_COUNT_MAX  200U
-#define DRBD_KO_COUNT_DEF  7U
-#define DRBD_KO_COUNT_SCALE '1'
-/* } */
-
-/* syncer { */
-  /* FIXME allow rate to be zero? */
-#define DRBD_RESYNC_RATE_MIN 1U
-/* channel bonding 10 GbE, or other hardware */
-#define DRBD_RESYNC_RATE_MAX (4 << 20)
-#define DRBD_RESYNC_RATE_DEF 250U
-#define DRBD_RESYNC_RATE_SCALE 'k'  /* kilobytes */
-
-#define DRBD_AL_EXTENTS_MIN  67U
-  /* we use u16 as "slot number", (u16)~0 is "FREE".
-   * If you use >= 292 kB on-disk ring buffer,
-   * this is the maximum you can use: */
-#define DRBD_AL_EXTENTS_MAX  0xfffeU
-#define DRBD_AL_EXTENTS_DEF  1237U
-#define DRBD_AL_EXTENTS_SCALE '1'
-
-#define DRBD_MINOR_NUMBER_MIN  -1
-#define DRBD_MINOR_NUMBER_MAX  ((1 << 20) - 1)
-#define DRBD_MINOR_NUMBER_DEF  -1
-#define DRBD_MINOR_NUMBER_SCALE '1'
-
-/* } */
-
-/* drbdsetup XY resize -d Z
- * you are free to reduce the device size to nothing, if you want to.
- * the upper limit with 64bit kernel, enough ram and flexible meta data
- * is 1 PiB, currently. */
-/* DRBD_MAX_SECTORS */
-#define DRBD_DISK_SIZE_MIN  0LLU
-#define DRBD_DISK_SIZE_MAX  (1LLU * (2LLU << 40))
-#define DRBD_DISK_SIZE_DEF  0LLU /* = disabled = no user size... */
-#define DRBD_DISK_SIZE_SCALE 's'  /* sectors */
-
-#define DRBD_ON_IO_ERROR_DEF EP_DETACH
-#define DRBD_FENCING_DEF FP_DONT_CARE
-#define DRBD_AFTER_SB_0P_DEF ASB_DISCONNECT
-#define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT
-#define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT
-#define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT
-#define DRBD_ON_NO_DATA_DEF OND_IO_ERROR
-#define DRBD_ON_CONGESTION_DEF OC_BLOCK
-#define DRBD_READ_BALANCING_DEF RB_PREFER_LOCAL
-
-#define DRBD_MAX_BIO_BVECS_MIN 0U
-#define DRBD_MAX_BIO_BVECS_MAX 128U
-#define DRBD_MAX_BIO_BVECS_DEF 0U
-#define DRBD_MAX_BIO_BVECS_SCALE '1'
-
-#define DRBD_C_PLAN_AHEAD_MIN  0U
-#define DRBD_C_PLAN_AHEAD_MAX  300U
-#define DRBD_C_PLAN_AHEAD_DEF  20U
-#define DRBD_C_PLAN_AHEAD_SCALE '1'
-
-#define DRBD_C_DELAY_TARGET_MIN 1U
-#define DRBD_C_DELAY_TARGET_MAX 100U
-#define DRBD_C_DELAY_TARGET_DEF 10U
-#define DRBD_C_DELAY_TARGET_SCALE '1'
-
-#define DRBD_C_FILL_TARGET_MIN 0U
-#define DRBD_C_FILL_TARGET_MAX (1U<<20) /* 500MByte in sec */
-#define DRBD_C_FILL_TARGET_DEF 100U /* Try to place 50KiB in socket send buffer during resync */
-#define DRBD_C_FILL_TARGET_SCALE 's'  /* sectors */
-
-#define DRBD_C_MAX_RATE_MIN     250U
-#define DRBD_C_MAX_RATE_MAX     (4U << 20)
-#define DRBD_C_MAX_RATE_DEF     102400U
-#define DRBD_C_MAX_RATE_SCALE  'k'  /* kilobytes */
-
-#define DRBD_C_MIN_RATE_MIN     0U
-#define DRBD_C_MIN_RATE_MAX     (4U << 20)
-#define DRBD_C_MIN_RATE_DEF     250U
-#define DRBD_C_MIN_RATE_SCALE  'k'  /* kilobytes */
-
-#define DRBD_CONG_FILL_MIN     0U
-#define DRBD_CONG_FILL_MAX     (10U<<21) /* 10GByte in sectors */
-#define DRBD_CONG_FILL_DEF     0U
-#define DRBD_CONG_FILL_SCALE   's'  /* sectors */
-
-#define DRBD_CONG_EXTENTS_MIN  DRBD_AL_EXTENTS_MIN
-#define DRBD_CONG_EXTENTS_MAX  DRBD_AL_EXTENTS_MAX
-#define DRBD_CONG_EXTENTS_DEF  DRBD_AL_EXTENTS_DEF
-#define DRBD_CONG_EXTENTS_SCALE DRBD_AL_EXTENTS_SCALE
-
-#define DRBD_PROTOCOL_DEF DRBD_PROT_C
-
-#define DRBD_DISK_BARRIER_DEF  0U
-#define DRBD_DISK_FLUSHES_DEF  1U
-#define DRBD_DISK_DRAIN_DEF    1U
-#define DRBD_MD_FLUSHES_DEF    1U
-#define DRBD_TCP_CORK_DEF      1U
-#define DRBD_AL_UPDATES_DEF     1U
-
-/* We used to ignore the discard_zeroes_data setting.
- * To not change established (and expected) behaviour,
- * by default assume that, for discard_zeroes_data=0,
- * we can make that an effective discard_zeroes_data=1,
- * if we only explicitly zero-out unaligned partial chunks. */
-#define DRBD_DISCARD_ZEROES_IF_ALIGNED_DEF 1U
-
-/* Some backends pretend to support WRITE SAME,
- * but fail such requests when they are actually submitted.
- * This is to tell DRBD to not even try. */
-#define DRBD_DISABLE_WRITE_SAME_DEF 0U
-
-#define DRBD_ALLOW_TWO_PRIMARIES_DEF   0U
-#define DRBD_ALWAYS_ASBP_DEF   0U
-#define DRBD_USE_RLE_DEF       1U
-#define DRBD_CSUMS_AFTER_CRASH_ONLY_DEF 0U
-
-#define DRBD_AL_STRIPES_MIN     1U
-#define DRBD_AL_STRIPES_MAX     1024U
-#define DRBD_AL_STRIPES_DEF     1U
-#define DRBD_AL_STRIPES_SCALE   '1'
-
-#define DRBD_AL_STRIPE_SIZE_MIN   4U
-#define DRBD_AL_STRIPE_SIZE_MAX   16777216U
-#define DRBD_AL_STRIPE_SIZE_DEF   32U
-#define DRBD_AL_STRIPE_SIZE_SCALE 'k' /* kilobytes */
-
-#define DRBD_SOCKET_CHECK_TIMEO_MIN 0U
-#define DRBD_SOCKET_CHECK_TIMEO_MAX DRBD_PING_TIMEO_MAX
-#define DRBD_SOCKET_CHECK_TIMEO_DEF 0U
-#define DRBD_SOCKET_CHECK_TIMEO_SCALE '1'
-
-#define DRBD_RS_DISCARD_GRANULARITY_MIN 0U
-#define DRBD_RS_DISCARD_GRANULARITY_MAX (1U<<20)  /* 1MiByte */
-#define DRBD_RS_DISCARD_GRANULARITY_DEF 0U     /* disabled by default */
-#define DRBD_RS_DISCARD_GRANULARITY_SCALE '1' /* bytes */
-
-#endif
diff --git a/include/uapi/linux/drbd.h b/include/uapi/linux/drbd.h
new file mode 100644 (file)
index 0000000..7930a97
--- /dev/null
@@ -0,0 +1,432 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
+/*
+  drbd.h
+  Kernel module for 2.6.x Kernels
+
+  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
+
+  Copyright (C) 2001-2008, LINBIT Information Technologies GmbH.
+  Copyright (C) 2001-2008, Philipp Reisner <philipp.reisner@linbit.com>.
+  Copyright (C) 2001-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
+
+
+*/
+#ifndef DRBD_H
+#define DRBD_H
+#include <asm/types.h>
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#include <asm/byteorder.h>
+#else
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <limits.h>
+
+/* Although the Linux source code makes a difference between
+   generic endianness and the bitfields' endianness, there is no
+   architecture as of Linux-2.6.24-rc4 where the bitfields' endianness
+   does not match the generic endianness. */
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN_BITFIELD
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define __BIG_ENDIAN_BITFIELD
+#else
+# error "sorry, weird endianness on this box"
+#endif
+
+#endif
+
+enum drbd_io_error_p {
+       EP_PASS_ON, /* FIXME should the better be named "Ignore"? */
+       EP_CALL_HELPER,
+       EP_DETACH
+};
+
+enum drbd_fencing_p {
+       FP_NOT_AVAIL = -1, /* Not a policy */
+       FP_DONT_CARE = 0,
+       FP_RESOURCE,
+       FP_STONITH
+};
+
+enum drbd_disconnect_p {
+       DP_RECONNECT,
+       DP_DROP_NET_CONF,
+       DP_FREEZE_IO
+};
+
+enum drbd_after_sb_p {
+       ASB_DISCONNECT,
+       ASB_DISCARD_YOUNGER_PRI,
+       ASB_DISCARD_OLDER_PRI,
+       ASB_DISCARD_ZERO_CHG,
+       ASB_DISCARD_LEAST_CHG,
+       ASB_DISCARD_LOCAL,
+       ASB_DISCARD_REMOTE,
+       ASB_CONSENSUS,
+       ASB_DISCARD_SECONDARY,
+       ASB_CALL_HELPER,
+       ASB_VIOLENTLY
+};
+
+enum drbd_on_no_data {
+       OND_IO_ERROR,
+       OND_SUSPEND_IO
+};
+
+enum drbd_on_congestion {
+       OC_BLOCK,
+       OC_PULL_AHEAD,
+       OC_DISCONNECT,
+};
+
+enum drbd_read_balancing {
+       RB_PREFER_LOCAL,
+       RB_PREFER_REMOTE,
+       RB_ROUND_ROBIN,
+       RB_LEAST_PENDING,
+       RB_CONGESTED_REMOTE,
+       RB_32K_STRIPING,
+       RB_64K_STRIPING,
+       RB_128K_STRIPING,
+       RB_256K_STRIPING,
+       RB_512K_STRIPING,
+       RB_1M_STRIPING,
+};
+
+/* KEEP the order, do not delete or insert. Only append. */
+enum drbd_ret_code {
+       ERR_CODE_BASE           = 100,
+       NO_ERROR                = 101,
+       ERR_LOCAL_ADDR          = 102,
+       ERR_PEER_ADDR           = 103,
+       ERR_OPEN_DISK           = 104,
+       ERR_OPEN_MD_DISK        = 105,
+       ERR_DISK_NOT_BDEV       = 107,
+       ERR_MD_NOT_BDEV         = 108,
+       ERR_DISK_TOO_SMALL      = 111,
+       ERR_MD_DISK_TOO_SMALL   = 112,
+       ERR_BDCLAIM_DISK        = 114,
+       ERR_BDCLAIM_MD_DISK     = 115,
+       ERR_MD_IDX_INVALID      = 116,
+       ERR_IO_MD_DISK          = 118,
+       ERR_MD_INVALID          = 119,
+       ERR_AUTH_ALG            = 120,
+       ERR_AUTH_ALG_ND         = 121,
+       ERR_NOMEM               = 122,
+       ERR_DISCARD_IMPOSSIBLE  = 123,
+       ERR_DISK_CONFIGURED     = 124,
+       ERR_NET_CONFIGURED      = 125,
+       ERR_MANDATORY_TAG       = 126,
+       ERR_MINOR_INVALID       = 127,
+       ERR_INTR                = 129, /* EINTR */
+       ERR_RESIZE_RESYNC       = 130,
+       ERR_NO_PRIMARY          = 131,
+       ERR_RESYNC_AFTER        = 132,
+       ERR_RESYNC_AFTER_CYCLE  = 133,
+       ERR_PAUSE_IS_SET        = 134,
+       ERR_PAUSE_IS_CLEAR      = 135,
+       ERR_PACKET_NR           = 137,
+       ERR_NO_DISK             = 138,
+       ERR_NOT_PROTO_C         = 139,
+       ERR_NOMEM_BITMAP        = 140,
+       ERR_INTEGRITY_ALG       = 141, /* DRBD 8.2 only */
+       ERR_INTEGRITY_ALG_ND    = 142, /* DRBD 8.2 only */
+       ERR_CPU_MASK_PARSE      = 143, /* DRBD 8.2 only */
+       ERR_CSUMS_ALG           = 144, /* DRBD 8.2 only */
+       ERR_CSUMS_ALG_ND        = 145, /* DRBD 8.2 only */
+       ERR_VERIFY_ALG          = 146, /* DRBD 8.2 only */
+       ERR_VERIFY_ALG_ND       = 147, /* DRBD 8.2 only */
+       ERR_CSUMS_RESYNC_RUNNING= 148, /* DRBD 8.2 only */
+       ERR_VERIFY_RUNNING      = 149, /* DRBD 8.2 only */
+       ERR_DATA_NOT_CURRENT    = 150,
+       ERR_CONNECTED           = 151, /* DRBD 8.3 only */
+       ERR_PERM                = 152,
+       ERR_NEED_APV_93         = 153,
+       ERR_STONITH_AND_PROT_A  = 154,
+       ERR_CONG_NOT_PROTO_A    = 155,
+       ERR_PIC_AFTER_DEP       = 156,
+       ERR_PIC_PEER_DEP        = 157,
+       ERR_RES_NOT_KNOWN       = 158,
+       ERR_RES_IN_USE          = 159,
+       ERR_MINOR_CONFIGURED    = 160,
+       ERR_MINOR_OR_VOLUME_EXISTS = 161,
+       ERR_INVALID_REQUEST     = 162,
+       ERR_NEED_APV_100        = 163,
+       ERR_NEED_ALLOW_TWO_PRI  = 164,
+       ERR_MD_UNCLEAN          = 165,
+       ERR_MD_LAYOUT_CONNECTED = 166,
+       ERR_MD_LAYOUT_TOO_BIG   = 167,
+       ERR_MD_LAYOUT_TOO_SMALL = 168,
+       ERR_MD_LAYOUT_NO_FIT    = 169,
+       ERR_IMPLICIT_SHRINK     = 170,
+       /* insert new ones above this line */
+       AFTER_LAST_ERR_CODE
+};
+
+#define DRBD_PROT_A   1
+#define DRBD_PROT_B   2
+#define DRBD_PROT_C   3
+
+enum drbd_role {
+       R_UNKNOWN = 0,
+       R_PRIMARY = 1,     /* role */
+       R_SECONDARY = 2,   /* role */
+       R_MASK = 3,
+};
+
+/* The order of these constants is important.
+ * The lower ones (<C_WF_REPORT_PARAMS) indicate
+ * that there is no socket!
+ * >=C_WF_REPORT_PARAMS ==> There is a socket
+ */
+enum drbd_conns {
+       C_STANDALONE,
+       C_DISCONNECTING,  /* Temporal state on the way to StandAlone. */
+       C_UNCONNECTED,    /* >= C_UNCONNECTED -> inc_net() succeeds */
+
+       /* These temporal states are all used on the way
+        * from >= C_CONNECTED to Unconnected.
+        * The 'disconnect reason' states
+        * I do not allow to change between them. */
+       C_TIMEOUT,
+       C_BROKEN_PIPE,
+       C_NETWORK_FAILURE,
+       C_PROTOCOL_ERROR,
+       C_TEAR_DOWN,
+
+       C_WF_CONNECTION,
+       C_WF_REPORT_PARAMS, /* we have a socket */
+       C_CONNECTED,      /* we have introduced each other */
+       C_STARTING_SYNC_S,  /* starting full sync by admin request. */
+       C_STARTING_SYNC_T,  /* starting full sync by admin request. */
+       C_WF_BITMAP_S,
+       C_WF_BITMAP_T,
+       C_WF_SYNC_UUID,
+
+       /* All SyncStates are tested with this comparison
+        * xx >= C_SYNC_SOURCE && xx <= C_PAUSED_SYNC_T */
+       C_SYNC_SOURCE,
+       C_SYNC_TARGET,
+       C_VERIFY_S,
+       C_VERIFY_T,
+       C_PAUSED_SYNC_S,
+       C_PAUSED_SYNC_T,
+
+       C_AHEAD,
+       C_BEHIND,
+
+       C_MASK = 31
+};
+
+enum drbd_disk_state {
+       D_DISKLESS,
+       D_ATTACHING,      /* In the process of reading the meta-data */
+       D_FAILED,         /* Becomes D_DISKLESS as soon as we told it the peer */
+                         /* when >= D_FAILED it is legal to access mdev->ldev */
+       D_NEGOTIATING,    /* Late attaching state, we need to talk to the peer */
+       D_INCONSISTENT,
+       D_OUTDATED,
+       D_UNKNOWN,       /* Only used for the peer, never for myself */
+       D_CONSISTENT,     /* Might be D_OUTDATED, might be D_UP_TO_DATE ... */
+       D_UP_TO_DATE,       /* Only this disk state allows applications' IO ! */
+       D_MASK = 15
+};
+
+union drbd_state {
+/* According to gcc's docs is the ...
+ * The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 6.7.2.1).
+ * Determined by ABI.
+ * pointed out by Maxim Uvarov q<muvarov@ru.mvista.com>
+ * even though we transmit as "cpu_to_be32(state)",
+ * the offsets of the bitfields still need to be swapped
+ * on different endianness.
+ */
+       struct {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+               unsigned role:2 ;   /* 3/4       primary/secondary/unknown */
+               unsigned peer:2 ;   /* 3/4       primary/secondary/unknown */
+               unsigned conn:5 ;   /* 17/32     cstates */
+               unsigned disk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
+               unsigned pdsk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
+               unsigned susp:1 ;   /* 2/2       IO suspended no/yes (by user) */
+               unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
+               unsigned peer_isp:1 ;
+               unsigned user_isp:1 ;
+               unsigned susp_nod:1 ; /* IO suspended because no data */
+               unsigned susp_fen:1 ; /* IO suspended because fence peer handler runs*/
+               unsigned _pad:9;   /* 0  unused */
+#elif defined(__BIG_ENDIAN_BITFIELD)
+               unsigned _pad:9;
+               unsigned susp_fen:1 ;
+               unsigned susp_nod:1 ;
+               unsigned user_isp:1 ;
+               unsigned peer_isp:1 ;
+               unsigned aftr_isp:1 ; /* isp .. imposed sync pause */
+               unsigned susp:1 ;   /* 2/2       IO suspended  no/yes */
+               unsigned pdsk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
+               unsigned disk:4 ;   /* 8/16      from D_DISKLESS to D_UP_TO_DATE */
+               unsigned conn:5 ;   /* 17/32     cstates */
+               unsigned peer:2 ;   /* 3/4       primary/secondary/unknown */
+               unsigned role:2 ;   /* 3/4       primary/secondary/unknown */
+#else
+# error "this endianness is not supported"
+#endif
+       };
+       unsigned int i;
+};
+
+enum drbd_state_rv {
+       SS_CW_NO_NEED = 4,
+       SS_CW_SUCCESS = 3,
+       SS_NOTHING_TO_DO = 2,
+       SS_SUCCESS = 1,
+       SS_UNKNOWN_ERROR = 0, /* Used to sleep longer in _drbd_request_state */
+       SS_TWO_PRIMARIES = -1,
+       SS_NO_UP_TO_DATE_DISK = -2,
+       SS_NO_LOCAL_DISK = -4,
+       SS_NO_REMOTE_DISK = -5,
+       SS_CONNECTED_OUTDATES = -6,
+       SS_PRIMARY_NOP = -7,
+       SS_RESYNC_RUNNING = -8,
+       SS_ALREADY_STANDALONE = -9,
+       SS_CW_FAILED_BY_PEER = -10,
+       SS_IS_DISKLESS = -11,
+       SS_DEVICE_IN_USE = -12,
+       SS_NO_NET_CONFIG = -13,
+       SS_NO_VERIFY_ALG = -14,       /* drbd-8.2 only */
+       SS_NEED_CONNECTION = -15,    /* drbd-8.2 only */
+       SS_LOWER_THAN_OUTDATED = -16,
+       SS_NOT_SUPPORTED = -17,      /* drbd-8.2 only */
+       SS_IN_TRANSIENT_STATE = -18,  /* Retry after the next state change */
+       SS_CONCURRENT_ST_CHG = -19,   /* Concurrent cluster side state change! */
+       SS_O_VOL_PEER_PRI = -20,
+       SS_OUTDATE_WO_CONN = -21,
+       SS_AFTER_LAST_ERROR = -22,    /* Keep this at bottom */
+};
+
+#define SHARED_SECRET_MAX 64
+
+#define MDF_CONSISTENT         (1 << 0)
+#define MDF_PRIMARY_IND                (1 << 1)
+#define MDF_CONNECTED_IND      (1 << 2)
+#define MDF_FULL_SYNC          (1 << 3)
+#define MDF_WAS_UP_TO_DATE     (1 << 4)
+#define MDF_PEER_OUT_DATED     (1 << 5)
+#define MDF_CRASHED_PRIMARY    (1 << 6)
+#define MDF_AL_CLEAN           (1 << 7)
+#define MDF_AL_DISABLED                (1 << 8)
+
+#define MAX_PEERS 32
+
+enum drbd_uuid_index {
+       UI_CURRENT,
+       UI_BITMAP,
+       UI_HISTORY_START,
+       UI_HISTORY_END,
+       UI_SIZE,      /* nl-packet: number of dirty bits */
+       UI_FLAGS,     /* nl-packet: flags */
+       UI_EXTENDED_SIZE   /* Everything. */
+};
+
+#define HISTORY_UUIDS MAX_PEERS
+
+enum drbd_timeout_flag {
+       UT_DEFAULT      = 0,
+       UT_DEGRADED     = 1,
+       UT_PEER_OUTDATED = 2,
+};
+
+enum drbd_notification_type {
+       NOTIFY_EXISTS,
+       NOTIFY_CREATE,
+       NOTIFY_CHANGE,
+       NOTIFY_DESTROY,
+       NOTIFY_CALL,
+       NOTIFY_RESPONSE,
+
+       NOTIFY_CONTINUES = 0x8000,
+       NOTIFY_FLAGS = NOTIFY_CONTINUES,
+};
+
+enum drbd_peer_state {
+       P_INCONSISTENT = 3,
+       P_OUTDATED = 4,
+       P_DOWN = 5,
+       P_PRIMARY = 6,
+       P_FENCING = 7,
+};
+
+#define UUID_JUST_CREATED ((__u64)4)
+
+enum write_ordering_e {
+       WO_NONE,
+       WO_DRAIN_IO,
+       WO_BDEV_FLUSH,
+       WO_BIO_BARRIER
+};
+
+/* magic numbers used in meta data and network packets */
+#define DRBD_MAGIC 0x83740267
+#define DRBD_MAGIC_BIG 0x835a
+#define DRBD_MAGIC_100 0x8620ec20
+
+#define DRBD_MD_MAGIC_07   (DRBD_MAGIC+3)
+#define DRBD_MD_MAGIC_08   (DRBD_MAGIC+4)
+#define DRBD_MD_MAGIC_84_UNCLEAN       (DRBD_MAGIC+5)
+
+
+/* how I came up with this magic?
+ * base64 decode "actlog==" ;) */
+#define DRBD_AL_MAGIC 0x69cb65a2
+
+/* these are of type "int" */
+#define DRBD_MD_INDEX_INTERNAL -1
+#define DRBD_MD_INDEX_FLEX_EXT -2
+#define DRBD_MD_INDEX_FLEX_INT -3
+
+#define DRBD_CPU_MASK_SIZE 32
+
+/**
+ * struct drbd_genlmsghdr - DRBD specific header used in NETLINK_GENERIC requests
+ * @minor:
+ *     For admin requests (user -> kernel): which minor device to operate on.
+ *     For (unicast) replies or informational (broadcast) messages
+ *     (kernel -> user): which minor device the information is about.
+ *     If we do not operate on minors, but on connections or resources,
+ *     the minor value shall be (~0), and the attribute DRBD_NLA_CFG_CONTEXT
+ *     is used instead.
+ * @flags: possible operation modifiers (relevant only for user->kernel):
+ *     DRBD_GENL_F_SET_DEFAULTS
+ * @volume:
+ *     When creating a new minor (adding it to a resource), the resource needs
+ *     to know which volume number within the resource this is supposed to be.
+ *     The volume number corresponds to the same volume number on the remote side,
+ *     whereas the minor number on the remote side may be different
+ *     (union with flags).
+ * @ret_code: kernel->userland unicast cfg reply return code (union with flags);
+ */
+struct drbd_genlmsghdr {
+       __u32 minor;
+       union {
+               __u32 flags;
+               __s32 ret_code;
+       };
+};
+
+/* To be used in drbd_genlmsghdr.flags */
+enum {
+       DRBD_GENL_F_SET_DEFAULTS = 1,
+};
+
+enum drbd_state_info_bcast_reason {
+       SIB_GET_STATUS_REPLY = 1,
+       SIB_STATE_CHANGE = 2,
+       SIB_HELPER_PRE = 3,
+       SIB_HELPER_POST = 4,
+       SIB_SYNC_PROGRESS = 5,
+};
+
+#endif
diff --git a/include/uapi/linux/drbd_limits.h b/include/uapi/linux/drbd_limits.h
new file mode 100644 (file)
index 0000000..a72a102
--- /dev/null
@@ -0,0 +1,251 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/*
+  drbd_limits.h
+  This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
+*/
+
+/*
+ * Our current limitations.
+ * Some of them are hard limits,
+ * some of them are arbitrary range limits, that make it easier to provide
+ * feedback about nonsense settings for certain configurable values.
+ */
+
+#ifndef DRBD_LIMITS_H
+#define DRBD_LIMITS_H 1
+
+#define DEBUG_RANGE_CHECK 0
+
+#define DRBD_MINOR_COUNT_MIN 1U
+#define DRBD_MINOR_COUNT_MAX 255U
+#define DRBD_MINOR_COUNT_DEF 32U
+#define DRBD_MINOR_COUNT_SCALE '1'
+
+#define DRBD_VOLUME_MAX 65534U
+
+#define DRBD_DIALOG_REFRESH_MIN 0U
+#define DRBD_DIALOG_REFRESH_MAX 600U
+#define DRBD_DIALOG_REFRESH_SCALE '1'
+
+/* valid port number */
+#define DRBD_PORT_MIN 1U
+#define DRBD_PORT_MAX 0xffffU
+#define DRBD_PORT_SCALE '1'
+
+/* startup { */
+  /* if you want more than 3.4 days, disable */
+#define DRBD_WFC_TIMEOUT_MIN 0U
+#define DRBD_WFC_TIMEOUT_MAX 300000U
+#define DRBD_WFC_TIMEOUT_DEF 0U
+#define DRBD_WFC_TIMEOUT_SCALE '1'
+
+#define DRBD_DEGR_WFC_TIMEOUT_MIN 0U
+#define DRBD_DEGR_WFC_TIMEOUT_MAX 300000U
+#define DRBD_DEGR_WFC_TIMEOUT_DEF 0U
+#define DRBD_DEGR_WFC_TIMEOUT_SCALE '1'
+
+#define DRBD_OUTDATED_WFC_TIMEOUT_MIN 0U
+#define DRBD_OUTDATED_WFC_TIMEOUT_MAX 300000U
+#define DRBD_OUTDATED_WFC_TIMEOUT_DEF 0U
+#define DRBD_OUTDATED_WFC_TIMEOUT_SCALE '1'
+/* }*/
+
+/* net { */
+  /* timeout, unit centi seconds
+   * more than one minute timeout is not useful */
+#define DRBD_TIMEOUT_MIN 1U
+#define DRBD_TIMEOUT_MAX 600U
+#define DRBD_TIMEOUT_DEF 60U       /* 6 seconds */
+#define DRBD_TIMEOUT_SCALE '1'
+
+ /* If backing disk takes longer than disk_timeout, mark the disk as failed */
+#define DRBD_DISK_TIMEOUT_MIN 0U    /* 0 = disabled */
+#define DRBD_DISK_TIMEOUT_MAX 6000U /* 10 Minutes */
+#define DRBD_DISK_TIMEOUT_DEF 0U    /* disabled */
+#define DRBD_DISK_TIMEOUT_SCALE '1'
+
+  /* active connection retries when C_WF_CONNECTION */
+#define DRBD_CONNECT_INT_MIN 1U
+#define DRBD_CONNECT_INT_MAX 120U
+#define DRBD_CONNECT_INT_DEF 10U   /* seconds */
+#define DRBD_CONNECT_INT_SCALE '1'
+
+  /* keep-alive probes when idle */
+#define DRBD_PING_INT_MIN 1U
+#define DRBD_PING_INT_MAX 120U
+#define DRBD_PING_INT_DEF 10U
+#define DRBD_PING_INT_SCALE '1'
+
+ /* timeout for the ping packets.*/
+#define DRBD_PING_TIMEO_MIN  1U
+#define DRBD_PING_TIMEO_MAX  300U
+#define DRBD_PING_TIMEO_DEF  5U
+#define DRBD_PING_TIMEO_SCALE '1'
+
+  /* max number of write requests between write barriers */
+#define DRBD_MAX_EPOCH_SIZE_MIN 1U
+#define DRBD_MAX_EPOCH_SIZE_MAX 20000U
+#define DRBD_MAX_EPOCH_SIZE_DEF 2048U
+#define DRBD_MAX_EPOCH_SIZE_SCALE '1'
+
+  /* I don't think that a tcp send buffer of more than 10M is useful */
+#define DRBD_SNDBUF_SIZE_MIN  0U
+#define DRBD_SNDBUF_SIZE_MAX  (10U<<20)
+#define DRBD_SNDBUF_SIZE_DEF  0U
+#define DRBD_SNDBUF_SIZE_SCALE '1'
+
+#define DRBD_RCVBUF_SIZE_MIN  0U
+#define DRBD_RCVBUF_SIZE_MAX  (10U<<20)
+#define DRBD_RCVBUF_SIZE_DEF  0U
+#define DRBD_RCVBUF_SIZE_SCALE '1'
+
+  /* @4k PageSize -> 128kB - 512MB */
+#define DRBD_MAX_BUFFERS_MIN  32U
+#define DRBD_MAX_BUFFERS_MAX  131072U
+#define DRBD_MAX_BUFFERS_DEF  2048U
+#define DRBD_MAX_BUFFERS_SCALE '1'
+
+  /* @4k PageSize -> 4kB - 512MB */
+#define DRBD_UNPLUG_WATERMARK_MIN  1U
+#define DRBD_UNPLUG_WATERMARK_MAX  131072U
+#define DRBD_UNPLUG_WATERMARK_DEF (DRBD_MAX_BUFFERS_DEF/16)
+#define DRBD_UNPLUG_WATERMARK_SCALE '1'
+
+  /* 0 is disabled.
+   * 200 should be more than enough even for very short timeouts */
+#define DRBD_KO_COUNT_MIN  0U
+#define DRBD_KO_COUNT_MAX  200U
+#define DRBD_KO_COUNT_DEF  7U
+#define DRBD_KO_COUNT_SCALE '1'
+/* } */
+
+/* syncer { */
+  /* FIXME allow rate to be zero? */
+#define DRBD_RESYNC_RATE_MIN 1U
+/* channel bonding 10 GbE, or other hardware */
+#define DRBD_RESYNC_RATE_MAX (4 << 20)
+#define DRBD_RESYNC_RATE_DEF 250U
+#define DRBD_RESYNC_RATE_SCALE 'k'  /* kilobytes */
+
+#define DRBD_AL_EXTENTS_MIN  67U
+  /* we use u16 as "slot number", (u16)~0 is "FREE".
+   * If you use >= 292 kB on-disk ring buffer,
+   * this is the maximum you can use: */
+#define DRBD_AL_EXTENTS_MAX  0xfffeU
+#define DRBD_AL_EXTENTS_DEF  1237U
+#define DRBD_AL_EXTENTS_SCALE '1'
+
+#define DRBD_MINOR_NUMBER_MIN  -1
+#define DRBD_MINOR_NUMBER_MAX  ((1 << 20) - 1)
+#define DRBD_MINOR_NUMBER_DEF  -1
+#define DRBD_MINOR_NUMBER_SCALE '1'
+
+/* } */
+
+/* drbdsetup XY resize -d Z
+ * you are free to reduce the device size to nothing, if you want to.
+ * the upper limit with 64bit kernel, enough ram and flexible meta data
+ * is 1 PiB, currently. */
+/* DRBD_MAX_SECTORS */
+#define DRBD_DISK_SIZE_MIN  0LLU
+#define DRBD_DISK_SIZE_MAX  (1LLU * (2LLU << 40))
+#define DRBD_DISK_SIZE_DEF  0LLU /* = disabled = no user size... */
+#define DRBD_DISK_SIZE_SCALE 's'  /* sectors */
+
+#define DRBD_ON_IO_ERROR_DEF EP_DETACH
+#define DRBD_FENCING_DEF FP_DONT_CARE
+#define DRBD_AFTER_SB_0P_DEF ASB_DISCONNECT
+#define DRBD_AFTER_SB_1P_DEF ASB_DISCONNECT
+#define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT
+#define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT
+#define DRBD_ON_NO_DATA_DEF OND_IO_ERROR
+#define DRBD_ON_CONGESTION_DEF OC_BLOCK
+#define DRBD_READ_BALANCING_DEF RB_PREFER_LOCAL
+
+#define DRBD_MAX_BIO_BVECS_MIN 0U
+#define DRBD_MAX_BIO_BVECS_MAX 128U
+#define DRBD_MAX_BIO_BVECS_DEF 0U
+#define DRBD_MAX_BIO_BVECS_SCALE '1'
+
+#define DRBD_C_PLAN_AHEAD_MIN  0U
+#define DRBD_C_PLAN_AHEAD_MAX  300U
+#define DRBD_C_PLAN_AHEAD_DEF  20U
+#define DRBD_C_PLAN_AHEAD_SCALE '1'
+
+#define DRBD_C_DELAY_TARGET_MIN 1U
+#define DRBD_C_DELAY_TARGET_MAX 100U
+#define DRBD_C_DELAY_TARGET_DEF 10U
+#define DRBD_C_DELAY_TARGET_SCALE '1'
+
+#define DRBD_C_FILL_TARGET_MIN 0U
+#define DRBD_C_FILL_TARGET_MAX (1U<<20) /* 500MByte in sec */
+#define DRBD_C_FILL_TARGET_DEF 100U /* Try to place 50KiB in socket send buffer during resync */
+#define DRBD_C_FILL_TARGET_SCALE 's'  /* sectors */
+
+#define DRBD_C_MAX_RATE_MIN     250U
+#define DRBD_C_MAX_RATE_MAX     (4U << 20)
+#define DRBD_C_MAX_RATE_DEF     102400U
+#define DRBD_C_MAX_RATE_SCALE  'k'  /* kilobytes */
+
+#define DRBD_C_MIN_RATE_MIN     0U
+#define DRBD_C_MIN_RATE_MAX     (4U << 20)
+#define DRBD_C_MIN_RATE_DEF     250U
+#define DRBD_C_MIN_RATE_SCALE  'k'  /* kilobytes */
+
+#define DRBD_CONG_FILL_MIN     0U
+#define DRBD_CONG_FILL_MAX     (10U<<21) /* 10GByte in sectors */
+#define DRBD_CONG_FILL_DEF     0U
+#define DRBD_CONG_FILL_SCALE   's'  /* sectors */
+
+#define DRBD_CONG_EXTENTS_MIN  DRBD_AL_EXTENTS_MIN
+#define DRBD_CONG_EXTENTS_MAX  DRBD_AL_EXTENTS_MAX
+#define DRBD_CONG_EXTENTS_DEF  DRBD_AL_EXTENTS_DEF
+#define DRBD_CONG_EXTENTS_SCALE DRBD_AL_EXTENTS_SCALE
+
+#define DRBD_PROTOCOL_DEF DRBD_PROT_C
+
+#define DRBD_DISK_BARRIER_DEF  0U
+#define DRBD_DISK_FLUSHES_DEF  1U
+#define DRBD_DISK_DRAIN_DEF    1U
+#define DRBD_MD_FLUSHES_DEF    1U
+#define DRBD_TCP_CORK_DEF      1U
+#define DRBD_AL_UPDATES_DEF     1U
+
+/* We used to ignore the discard_zeroes_data setting.
+ * To not change established (and expected) behaviour,
+ * by default assume that, for discard_zeroes_data=0,
+ * we can make that an effective discard_zeroes_data=1,
+ * if we only explicitly zero-out unaligned partial chunks. */
+#define DRBD_DISCARD_ZEROES_IF_ALIGNED_DEF 1U
+
+/* Some backends pretend to support WRITE SAME,
+ * but fail such requests when they are actually submitted.
+ * This is to tell DRBD to not even try. */
+#define DRBD_DISABLE_WRITE_SAME_DEF 0U
+
+#define DRBD_ALLOW_TWO_PRIMARIES_DEF   0U
+#define DRBD_ALWAYS_ASBP_DEF   0U
+#define DRBD_USE_RLE_DEF       1U
+#define DRBD_CSUMS_AFTER_CRASH_ONLY_DEF 0U
+
+#define DRBD_AL_STRIPES_MIN     1U
+#define DRBD_AL_STRIPES_MAX     1024U
+#define DRBD_AL_STRIPES_DEF     1U
+#define DRBD_AL_STRIPES_SCALE   '1'
+
+#define DRBD_AL_STRIPE_SIZE_MIN   4U
+#define DRBD_AL_STRIPE_SIZE_MAX   16777216U
+#define DRBD_AL_STRIPE_SIZE_DEF   32U
+#define DRBD_AL_STRIPE_SIZE_SCALE 'k' /* kilobytes */
+
+#define DRBD_SOCKET_CHECK_TIMEO_MIN 0U
+#define DRBD_SOCKET_CHECK_TIMEO_MAX DRBD_PING_TIMEO_MAX
+#define DRBD_SOCKET_CHECK_TIMEO_DEF 0U
+#define DRBD_SOCKET_CHECK_TIMEO_SCALE '1'
+
+#define DRBD_RS_DISCARD_GRANULARITY_MIN 0U
+#define DRBD_RS_DISCARD_GRANULARITY_MAX (1U<<20)  /* 1MiByte */
+#define DRBD_RS_DISCARD_GRANULARITY_DEF 0U     /* disabled by default */
+#define DRBD_RS_DISCARD_GRANULARITY_SCALE '1' /* bytes */
+
+#endif