1*93c68cc4SChristoph Böhmwalder // SPDX-License-Identifier: GPL-2.0-only
2b411b363SPhilipp Reisner /*
3b411b363SPhilipp Reisner drbd.h
4b411b363SPhilipp Reisner
5b411b363SPhilipp Reisner This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
6b411b363SPhilipp Reisner
7b411b363SPhilipp Reisner Copyright (C) 2003-2008, LINBIT Information Technologies GmbH.
8b411b363SPhilipp Reisner Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>.
9b411b363SPhilipp Reisner Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
10b411b363SPhilipp Reisner
11b411b363SPhilipp Reisner
12b411b363SPhilipp Reisner */
13b411b363SPhilipp Reisner
14b411b363SPhilipp Reisner #include <linux/drbd.h>
15d9f65229SAndreas Gruenbacher #include "drbd_strings.h"
16b411b363SPhilipp Reisner
177e5fec31SFabian Frederick static const char * const drbd_conn_s_names[] = {
18b411b363SPhilipp Reisner [C_STANDALONE] = "StandAlone",
19b411b363SPhilipp Reisner [C_DISCONNECTING] = "Disconnecting",
20b411b363SPhilipp Reisner [C_UNCONNECTED] = "Unconnected",
21b411b363SPhilipp Reisner [C_TIMEOUT] = "Timeout",
22b411b363SPhilipp Reisner [C_BROKEN_PIPE] = "BrokenPipe",
23b411b363SPhilipp Reisner [C_NETWORK_FAILURE] = "NetworkFailure",
24b411b363SPhilipp Reisner [C_PROTOCOL_ERROR] = "ProtocolError",
25b411b363SPhilipp Reisner [C_WF_CONNECTION] = "WFConnection",
26b411b363SPhilipp Reisner [C_WF_REPORT_PARAMS] = "WFReportParams",
27b411b363SPhilipp Reisner [C_TEAR_DOWN] = "TearDown",
28b411b363SPhilipp Reisner [C_CONNECTED] = "Connected",
29b411b363SPhilipp Reisner [C_STARTING_SYNC_S] = "StartingSyncS",
30b411b363SPhilipp Reisner [C_STARTING_SYNC_T] = "StartingSyncT",
31b411b363SPhilipp Reisner [C_WF_BITMAP_S] = "WFBitMapS",
32b411b363SPhilipp Reisner [C_WF_BITMAP_T] = "WFBitMapT",
33b411b363SPhilipp Reisner [C_WF_SYNC_UUID] = "WFSyncUUID",
34b411b363SPhilipp Reisner [C_SYNC_SOURCE] = "SyncSource",
35b411b363SPhilipp Reisner [C_SYNC_TARGET] = "SyncTarget",
36b411b363SPhilipp Reisner [C_PAUSED_SYNC_S] = "PausedSyncS",
37b411b363SPhilipp Reisner [C_PAUSED_SYNC_T] = "PausedSyncT",
38b411b363SPhilipp Reisner [C_VERIFY_S] = "VerifyS",
39b411b363SPhilipp Reisner [C_VERIFY_T] = "VerifyT",
4067531718SPhilipp Reisner [C_AHEAD] = "Ahead",
4167531718SPhilipp Reisner [C_BEHIND] = "Behind",
42b411b363SPhilipp Reisner };
43b411b363SPhilipp Reisner
447e5fec31SFabian Frederick static const char * const drbd_role_s_names[] = {
45b411b363SPhilipp Reisner [R_PRIMARY] = "Primary",
46b411b363SPhilipp Reisner [R_SECONDARY] = "Secondary",
47b411b363SPhilipp Reisner [R_UNKNOWN] = "Unknown"
48b411b363SPhilipp Reisner };
49b411b363SPhilipp Reisner
507e5fec31SFabian Frederick static const char * const drbd_disk_s_names[] = {
51b411b363SPhilipp Reisner [D_DISKLESS] = "Diskless",
52b411b363SPhilipp Reisner [D_ATTACHING] = "Attaching",
53b411b363SPhilipp Reisner [D_FAILED] = "Failed",
54b411b363SPhilipp Reisner [D_NEGOTIATING] = "Negotiating",
55b411b363SPhilipp Reisner [D_INCONSISTENT] = "Inconsistent",
56b411b363SPhilipp Reisner [D_OUTDATED] = "Outdated",
57b411b363SPhilipp Reisner [D_UNKNOWN] = "DUnknown",
58b411b363SPhilipp Reisner [D_CONSISTENT] = "Consistent",
59b411b363SPhilipp Reisner [D_UP_TO_DATE] = "UpToDate",
60b411b363SPhilipp Reisner };
61b411b363SPhilipp Reisner
627e5fec31SFabian Frederick static const char * const drbd_state_sw_errors[] = {
63b411b363SPhilipp Reisner [-SS_TWO_PRIMARIES] = "Multiple primaries not allowed by config",
648d4ce82bSLars Ellenberg [-SS_NO_UP_TO_DATE_DISK] = "Need access to UpToDate data",
65b411b363SPhilipp Reisner [-SS_NO_LOCAL_DISK] = "Can not resync without local disk",
66b411b363SPhilipp Reisner [-SS_NO_REMOTE_DISK] = "Can not resync without remote disk",
67b411b363SPhilipp Reisner [-SS_CONNECTED_OUTDATES] = "Refusing to be Outdated while Connected",
68b411b363SPhilipp Reisner [-SS_PRIMARY_NOP] = "Refusing to be Primary while peer is not outdated",
69b411b363SPhilipp Reisner [-SS_RESYNC_RUNNING] = "Can not start OV/resync since it is already active",
70b411b363SPhilipp Reisner [-SS_ALREADY_STANDALONE] = "Can not disconnect a StandAlone device",
71b411b363SPhilipp Reisner [-SS_CW_FAILED_BY_PEER] = "State change was refused by peer node",
72b411b363SPhilipp Reisner [-SS_IS_DISKLESS] = "Device is diskless, the requested operation requires a disk",
73b411b363SPhilipp Reisner [-SS_DEVICE_IN_USE] = "Device is held open by someone",
74b411b363SPhilipp Reisner [-SS_NO_NET_CONFIG] = "Have no net/connection configuration",
75b411b363SPhilipp Reisner [-SS_NO_VERIFY_ALG] = "Need a verify algorithm to start online verify",
76b411b363SPhilipp Reisner [-SS_NEED_CONNECTION] = "Need a connection to start verify or resync",
77b411b363SPhilipp Reisner [-SS_NOT_SUPPORTED] = "Peer does not support protocol",
78b411b363SPhilipp Reisner [-SS_LOWER_THAN_OUTDATED] = "Disk state is lower than outdated",
79b411b363SPhilipp Reisner [-SS_IN_TRANSIENT_STATE] = "In transient state, retry after next state change",
80b411b363SPhilipp Reisner [-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted",
812bd5ed5dSPhilipp Reisner [-SS_OUTDATE_WO_CONN] = "Need a connection for a graceful disconnect/outdate peer",
82047e95e2SPhilipp Reisner [-SS_O_VOL_PEER_PRI] = "Other vol primary on peer not allowed by config",
83b411b363SPhilipp Reisner };
84b411b363SPhilipp Reisner
drbd_conn_str(enum drbd_conns s)85b411b363SPhilipp Reisner const char *drbd_conn_str(enum drbd_conns s)
86b411b363SPhilipp Reisner {
87b411b363SPhilipp Reisner /* enums are unsigned... */
8867531718SPhilipp Reisner return s > C_BEHIND ? "TOO_LARGE" : drbd_conn_s_names[s];
89b411b363SPhilipp Reisner }
90b411b363SPhilipp Reisner
drbd_role_str(enum drbd_role s)91b411b363SPhilipp Reisner const char *drbd_role_str(enum drbd_role s)
92b411b363SPhilipp Reisner {
93b411b363SPhilipp Reisner return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s];
94b411b363SPhilipp Reisner }
95b411b363SPhilipp Reisner
drbd_disk_str(enum drbd_disk_state s)96b411b363SPhilipp Reisner const char *drbd_disk_str(enum drbd_disk_state s)
97b411b363SPhilipp Reisner {
98b411b363SPhilipp Reisner return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s];
99b411b363SPhilipp Reisner }
100b411b363SPhilipp Reisner
drbd_set_st_err_str(enum drbd_state_rv err)101c8b32563SAndreas Gruenbacher const char *drbd_set_st_err_str(enum drbd_state_rv err)
102b411b363SPhilipp Reisner {
103b411b363SPhilipp Reisner return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" :
104b411b363SPhilipp Reisner err > SS_TWO_PRIMARIES ? "TOO_LARGE"
105b411b363SPhilipp Reisner : drbd_state_sw_errors[-err];
106b411b363SPhilipp Reisner }
107