Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / block / drbd / drbd_strings.c
1 /*
2 drbd.h
3
4 This file is part of DRBD by Philipp Reisner and Lars Ellenberg.
5
6 Copyright (C) 2003-2008, LINBIT Information Technologies GmbH.
7 Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>.
8 Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
9
10 drbd is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 drbd is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with drbd; see the file COPYING. If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 */
25
26 #include <linux/drbd.h>
27
28 static const char *drbd_conn_s_names[] = {
29 [C_STANDALONE] = "StandAlone",
30 [C_DISCONNECTING] = "Disconnecting",
31 [C_UNCONNECTED] = "Unconnected",
32 [C_TIMEOUT] = "Timeout",
33 [C_BROKEN_PIPE] = "BrokenPipe",
34 [C_NETWORK_FAILURE] = "NetworkFailure",
35 [C_PROTOCOL_ERROR] = "ProtocolError",
36 [C_WF_CONNECTION] = "WFConnection",
37 [C_WF_REPORT_PARAMS] = "WFReportParams",
38 [C_TEAR_DOWN] = "TearDown",
39 [C_CONNECTED] = "Connected",
40 [C_STARTING_SYNC_S] = "StartingSyncS",
41 [C_STARTING_SYNC_T] = "StartingSyncT",
42 [C_WF_BITMAP_S] = "WFBitMapS",
43 [C_WF_BITMAP_T] = "WFBitMapT",
44 [C_WF_SYNC_UUID] = "WFSyncUUID",
45 [C_SYNC_SOURCE] = "SyncSource",
46 [C_SYNC_TARGET] = "SyncTarget",
47 [C_PAUSED_SYNC_S] = "PausedSyncS",
48 [C_PAUSED_SYNC_T] = "PausedSyncT",
49 [C_VERIFY_S] = "VerifyS",
50 [C_VERIFY_T] = "VerifyT",
51 [C_AHEAD] = "Ahead",
52 [C_BEHIND] = "Behind",
53 };
54
55 static const char *drbd_role_s_names[] = {
56 [R_PRIMARY] = "Primary",
57 [R_SECONDARY] = "Secondary",
58 [R_UNKNOWN] = "Unknown"
59 };
60
61 static const char *drbd_disk_s_names[] = {
62 [D_DISKLESS] = "Diskless",
63 [D_ATTACHING] = "Attaching",
64 [D_FAILED] = "Failed",
65 [D_NEGOTIATING] = "Negotiating",
66 [D_INCONSISTENT] = "Inconsistent",
67 [D_OUTDATED] = "Outdated",
68 [D_UNKNOWN] = "DUnknown",
69 [D_CONSISTENT] = "Consistent",
70 [D_UP_TO_DATE] = "UpToDate",
71 };
72
73 static const char *drbd_state_sw_errors[] = {
74 [-SS_TWO_PRIMARIES] = "Multiple primaries not allowed by config",
75 [-SS_NO_UP_TO_DATE_DISK] = "Need access to UpToDate data",
76 [-SS_NO_LOCAL_DISK] = "Can not resync without local disk",
77 [-SS_NO_REMOTE_DISK] = "Can not resync without remote disk",
78 [-SS_CONNECTED_OUTDATES] = "Refusing to be Outdated while Connected",
79 [-SS_PRIMARY_NOP] = "Refusing to be Primary while peer is not outdated",
80 [-SS_RESYNC_RUNNING] = "Can not start OV/resync since it is already active",
81 [-SS_ALREADY_STANDALONE] = "Can not disconnect a StandAlone device",
82 [-SS_CW_FAILED_BY_PEER] = "State change was refused by peer node",
83 [-SS_IS_DISKLESS] = "Device is diskless, the requested operation requires a disk",
84 [-SS_DEVICE_IN_USE] = "Device is held open by someone",
85 [-SS_NO_NET_CONFIG] = "Have no net/connection configuration",
86 [-SS_NO_VERIFY_ALG] = "Need a verify algorithm to start online verify",
87 [-SS_NEED_CONNECTION] = "Need a connection to start verify or resync",
88 [-SS_NOT_SUPPORTED] = "Peer does not support protocol",
89 [-SS_LOWER_THAN_OUTDATED] = "Disk state is lower than outdated",
90 [-SS_IN_TRANSIENT_STATE] = "In transient state, retry after next state change",
91 [-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted",
92 [-SS_OUTDATE_WO_CONN] = "Need a connection for a graceful disconnect/outdate peer",
93 [-SS_O_VOL_PEER_PRI] = "Other vol primary on peer not allowed by config",
94 };
95
96 const char *drbd_conn_str(enum drbd_conns s)
97 {
98 /* enums are unsigned... */
99 return s > C_BEHIND ? "TOO_LARGE" : drbd_conn_s_names[s];
100 }
101
102 const char *drbd_role_str(enum drbd_role s)
103 {
104 return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s];
105 }
106
107 const char *drbd_disk_str(enum drbd_disk_state s)
108 {
109 return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s];
110 }
111
112 const char *drbd_set_st_err_str(enum drbd_state_rv err)
113 {
114 return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" :
115 err > SS_TWO_PRIMARIES ? "TOO_LARGE"
116 : drbd_state_sw_errors[-err];
117 }