1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <linux/drbd.h>
27#include "drbd_strings.h"
28
29static const char * const drbd_conn_s_names[] = {
30 [C_STANDALONE] = "StandAlone",
31 [C_DISCONNECTING] = "Disconnecting",
32 [C_UNCONNECTED] = "Unconnected",
33 [C_TIMEOUT] = "Timeout",
34 [C_BROKEN_PIPE] = "BrokenPipe",
35 [C_NETWORK_FAILURE] = "NetworkFailure",
36 [C_PROTOCOL_ERROR] = "ProtocolError",
37 [C_WF_CONNECTION] = "WFConnection",
38 [C_WF_REPORT_PARAMS] = "WFReportParams",
39 [C_TEAR_DOWN] = "TearDown",
40 [C_CONNECTED] = "Connected",
41 [C_STARTING_SYNC_S] = "StartingSyncS",
42 [C_STARTING_SYNC_T] = "StartingSyncT",
43 [C_WF_BITMAP_S] = "WFBitMapS",
44 [C_WF_BITMAP_T] = "WFBitMapT",
45 [C_WF_SYNC_UUID] = "WFSyncUUID",
46 [C_SYNC_SOURCE] = "SyncSource",
47 [C_SYNC_TARGET] = "SyncTarget",
48 [C_PAUSED_SYNC_S] = "PausedSyncS",
49 [C_PAUSED_SYNC_T] = "PausedSyncT",
50 [C_VERIFY_S] = "VerifyS",
51 [C_VERIFY_T] = "VerifyT",
52 [C_AHEAD] = "Ahead",
53 [C_BEHIND] = "Behind",
54};
55
56static const char * const drbd_role_s_names[] = {
57 [R_PRIMARY] = "Primary",
58 [R_SECONDARY] = "Secondary",
59 [R_UNKNOWN] = "Unknown"
60};
61
62static const char * const drbd_disk_s_names[] = {
63 [D_DISKLESS] = "Diskless",
64 [D_ATTACHING] = "Attaching",
65 [D_FAILED] = "Failed",
66 [D_NEGOTIATING] = "Negotiating",
67 [D_INCONSISTENT] = "Inconsistent",
68 [D_OUTDATED] = "Outdated",
69 [D_UNKNOWN] = "DUnknown",
70 [D_CONSISTENT] = "Consistent",
71 [D_UP_TO_DATE] = "UpToDate",
72};
73
74static const char * const drbd_state_sw_errors[] = {
75 [-SS_TWO_PRIMARIES] = "Multiple primaries not allowed by config",
76 [-SS_NO_UP_TO_DATE_DISK] = "Need access to UpToDate data",
77 [-SS_NO_LOCAL_DISK] = "Can not resync without local disk",
78 [-SS_NO_REMOTE_DISK] = "Can not resync without remote disk",
79 [-SS_CONNECTED_OUTDATES] = "Refusing to be Outdated while Connected",
80 [-SS_PRIMARY_NOP] = "Refusing to be Primary while peer is not outdated",
81 [-SS_RESYNC_RUNNING] = "Can not start OV/resync since it is already active",
82 [-SS_ALREADY_STANDALONE] = "Can not disconnect a StandAlone device",
83 [-SS_CW_FAILED_BY_PEER] = "State change was refused by peer node",
84 [-SS_IS_DISKLESS] = "Device is diskless, the requested operation requires a disk",
85 [-SS_DEVICE_IN_USE] = "Device is held open by someone",
86 [-SS_NO_NET_CONFIG] = "Have no net/connection configuration",
87 [-SS_NO_VERIFY_ALG] = "Need a verify algorithm to start online verify",
88 [-SS_NEED_CONNECTION] = "Need a connection to start verify or resync",
89 [-SS_NOT_SUPPORTED] = "Peer does not support protocol",
90 [-SS_LOWER_THAN_OUTDATED] = "Disk state is lower than outdated",
91 [-SS_IN_TRANSIENT_STATE] = "In transient state, retry after next state change",
92 [-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted",
93 [-SS_OUTDATE_WO_CONN] = "Need a connection for a graceful disconnect/outdate peer",
94 [-SS_O_VOL_PEER_PRI] = "Other vol primary on peer not allowed by config",
95};
96
97const char *drbd_conn_str(enum drbd_conns s)
98{
99
100 return s > C_BEHIND ? "TOO_LARGE" : drbd_conn_s_names[s];
101}
102
103const char *drbd_role_str(enum drbd_role s)
104{
105 return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s];
106}
107
108const char *drbd_disk_str(enum drbd_disk_state s)
109{
110 return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s];
111}
112
113const char *drbd_set_st_err_str(enum drbd_state_rv err)
114{
115 return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" :
116 err > SS_TWO_PRIMARIES ? "TOO_LARGE"
117 : drbd_state_sw_errors[-err];
118}
119