162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci drbd.h 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci This file is part of DRBD by Philipp Reisner and Lars Ellenberg. 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci Copyright (C) 2003-2008, LINBIT Information Technologies GmbH. 862306a36Sopenharmony_ci Copyright (C) 2003-2008, Philipp Reisner <philipp.reisner@linbit.com>. 962306a36Sopenharmony_ci Copyright (C) 2003-2008, Lars Ellenberg <lars.ellenberg@linbit.com>. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci*/ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <linux/drbd.h> 1562306a36Sopenharmony_ci#include "drbd_strings.h" 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistatic const char * const drbd_conn_s_names[] = { 1862306a36Sopenharmony_ci [C_STANDALONE] = "StandAlone", 1962306a36Sopenharmony_ci [C_DISCONNECTING] = "Disconnecting", 2062306a36Sopenharmony_ci [C_UNCONNECTED] = "Unconnected", 2162306a36Sopenharmony_ci [C_TIMEOUT] = "Timeout", 2262306a36Sopenharmony_ci [C_BROKEN_PIPE] = "BrokenPipe", 2362306a36Sopenharmony_ci [C_NETWORK_FAILURE] = "NetworkFailure", 2462306a36Sopenharmony_ci [C_PROTOCOL_ERROR] = "ProtocolError", 2562306a36Sopenharmony_ci [C_WF_CONNECTION] = "WFConnection", 2662306a36Sopenharmony_ci [C_WF_REPORT_PARAMS] = "WFReportParams", 2762306a36Sopenharmony_ci [C_TEAR_DOWN] = "TearDown", 2862306a36Sopenharmony_ci [C_CONNECTED] = "Connected", 2962306a36Sopenharmony_ci [C_STARTING_SYNC_S] = "StartingSyncS", 3062306a36Sopenharmony_ci [C_STARTING_SYNC_T] = "StartingSyncT", 3162306a36Sopenharmony_ci [C_WF_BITMAP_S] = "WFBitMapS", 3262306a36Sopenharmony_ci [C_WF_BITMAP_T] = "WFBitMapT", 3362306a36Sopenharmony_ci [C_WF_SYNC_UUID] = "WFSyncUUID", 3462306a36Sopenharmony_ci [C_SYNC_SOURCE] = "SyncSource", 3562306a36Sopenharmony_ci [C_SYNC_TARGET] = "SyncTarget", 3662306a36Sopenharmony_ci [C_PAUSED_SYNC_S] = "PausedSyncS", 3762306a36Sopenharmony_ci [C_PAUSED_SYNC_T] = "PausedSyncT", 3862306a36Sopenharmony_ci [C_VERIFY_S] = "VerifyS", 3962306a36Sopenharmony_ci [C_VERIFY_T] = "VerifyT", 4062306a36Sopenharmony_ci [C_AHEAD] = "Ahead", 4162306a36Sopenharmony_ci [C_BEHIND] = "Behind", 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cistatic const char * const drbd_role_s_names[] = { 4562306a36Sopenharmony_ci [R_PRIMARY] = "Primary", 4662306a36Sopenharmony_ci [R_SECONDARY] = "Secondary", 4762306a36Sopenharmony_ci [R_UNKNOWN] = "Unknown" 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic const char * const drbd_disk_s_names[] = { 5162306a36Sopenharmony_ci [D_DISKLESS] = "Diskless", 5262306a36Sopenharmony_ci [D_ATTACHING] = "Attaching", 5362306a36Sopenharmony_ci [D_FAILED] = "Failed", 5462306a36Sopenharmony_ci [D_NEGOTIATING] = "Negotiating", 5562306a36Sopenharmony_ci [D_INCONSISTENT] = "Inconsistent", 5662306a36Sopenharmony_ci [D_OUTDATED] = "Outdated", 5762306a36Sopenharmony_ci [D_UNKNOWN] = "DUnknown", 5862306a36Sopenharmony_ci [D_CONSISTENT] = "Consistent", 5962306a36Sopenharmony_ci [D_UP_TO_DATE] = "UpToDate", 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistatic const char * const drbd_state_sw_errors[] = { 6362306a36Sopenharmony_ci [-SS_TWO_PRIMARIES] = "Multiple primaries not allowed by config", 6462306a36Sopenharmony_ci [-SS_NO_UP_TO_DATE_DISK] = "Need access to UpToDate data", 6562306a36Sopenharmony_ci [-SS_NO_LOCAL_DISK] = "Can not resync without local disk", 6662306a36Sopenharmony_ci [-SS_NO_REMOTE_DISK] = "Can not resync without remote disk", 6762306a36Sopenharmony_ci [-SS_CONNECTED_OUTDATES] = "Refusing to be Outdated while Connected", 6862306a36Sopenharmony_ci [-SS_PRIMARY_NOP] = "Refusing to be Primary while peer is not outdated", 6962306a36Sopenharmony_ci [-SS_RESYNC_RUNNING] = "Can not start OV/resync since it is already active", 7062306a36Sopenharmony_ci [-SS_ALREADY_STANDALONE] = "Can not disconnect a StandAlone device", 7162306a36Sopenharmony_ci [-SS_CW_FAILED_BY_PEER] = "State change was refused by peer node", 7262306a36Sopenharmony_ci [-SS_IS_DISKLESS] = "Device is diskless, the requested operation requires a disk", 7362306a36Sopenharmony_ci [-SS_DEVICE_IN_USE] = "Device is held open by someone", 7462306a36Sopenharmony_ci [-SS_NO_NET_CONFIG] = "Have no net/connection configuration", 7562306a36Sopenharmony_ci [-SS_NO_VERIFY_ALG] = "Need a verify algorithm to start online verify", 7662306a36Sopenharmony_ci [-SS_NEED_CONNECTION] = "Need a connection to start verify or resync", 7762306a36Sopenharmony_ci [-SS_NOT_SUPPORTED] = "Peer does not support protocol", 7862306a36Sopenharmony_ci [-SS_LOWER_THAN_OUTDATED] = "Disk state is lower than outdated", 7962306a36Sopenharmony_ci [-SS_IN_TRANSIENT_STATE] = "In transient state, retry after next state change", 8062306a36Sopenharmony_ci [-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted", 8162306a36Sopenharmony_ci [-SS_OUTDATE_WO_CONN] = "Need a connection for a graceful disconnect/outdate peer", 8262306a36Sopenharmony_ci [-SS_O_VOL_PEER_PRI] = "Other vol primary on peer not allowed by config", 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciconst char *drbd_conn_str(enum drbd_conns s) 8662306a36Sopenharmony_ci{ 8762306a36Sopenharmony_ci /* enums are unsigned... */ 8862306a36Sopenharmony_ci return s > C_BEHIND ? "TOO_LARGE" : drbd_conn_s_names[s]; 8962306a36Sopenharmony_ci} 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ciconst char *drbd_role_str(enum drbd_role s) 9262306a36Sopenharmony_ci{ 9362306a36Sopenharmony_ci return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s]; 9462306a36Sopenharmony_ci} 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciconst char *drbd_disk_str(enum drbd_disk_state s) 9762306a36Sopenharmony_ci{ 9862306a36Sopenharmony_ci return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s]; 9962306a36Sopenharmony_ci} 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciconst char *drbd_set_st_err_str(enum drbd_state_rv err) 10262306a36Sopenharmony_ci{ 10362306a36Sopenharmony_ci return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" : 10462306a36Sopenharmony_ci err > SS_TWO_PRIMARIES ? "TOO_LARGE" 10562306a36Sopenharmony_ci : drbd_state_sw_errors[-err]; 10662306a36Sopenharmony_ci} 107