drbd_strings.c 4.2 KB

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