drbd_strings.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. };
  44. static const char *drbd_role_s_names[] = {
  45. [R_PRIMARY] = "Primary",
  46. [R_SECONDARY] = "Secondary",
  47. [R_UNKNOWN] = "Unknown"
  48. };
  49. static const char *drbd_disk_s_names[] = {
  50. [D_DISKLESS] = "Diskless",
  51. [D_ATTACHING] = "Attaching",
  52. [D_FAILED] = "Failed",
  53. [D_NEGOTIATING] = "Negotiating",
  54. [D_INCONSISTENT] = "Inconsistent",
  55. [D_OUTDATED] = "Outdated",
  56. [D_UNKNOWN] = "DUnknown",
  57. [D_CONSISTENT] = "Consistent",
  58. [D_UP_TO_DATE] = "UpToDate",
  59. };
  60. static const char *drbd_state_sw_errors[] = {
  61. [-SS_TWO_PRIMARIES] = "Multiple primaries not allowed by config",
  62. [-SS_NO_UP_TO_DATE_DISK] = "Refusing to be Primary without at least one UpToDate disk",
  63. [-SS_NO_LOCAL_DISK] = "Can not resync without local disk",
  64. [-SS_NO_REMOTE_DISK] = "Can not resync without remote disk",
  65. [-SS_CONNECTED_OUTDATES] = "Refusing to be Outdated while Connected",
  66. [-SS_PRIMARY_NOP] = "Refusing to be Primary while peer is not outdated",
  67. [-SS_RESYNC_RUNNING] = "Can not start OV/resync since it is already active",
  68. [-SS_ALREADY_STANDALONE] = "Can not disconnect a StandAlone device",
  69. [-SS_CW_FAILED_BY_PEER] = "State change was refused by peer node",
  70. [-SS_IS_DISKLESS] = "Device is diskless, the requested operation requires a disk",
  71. [-SS_DEVICE_IN_USE] = "Device is held open by someone",
  72. [-SS_NO_NET_CONFIG] = "Have no net/connection configuration",
  73. [-SS_NO_VERIFY_ALG] = "Need a verify algorithm to start online verify",
  74. [-SS_NEED_CONNECTION] = "Need a connection to start verify or resync",
  75. [-SS_NOT_SUPPORTED] = "Peer does not support protocol",
  76. [-SS_LOWER_THAN_OUTDATED] = "Disk state is lower than outdated",
  77. [-SS_IN_TRANSIENT_STATE] = "In transient state, retry after next state change",
  78. [-SS_CONCURRENT_ST_CHG] = "Concurrent state changes detected and aborted",
  79. };
  80. const char *drbd_conn_str(enum drbd_conns s)
  81. {
  82. /* enums are unsigned... */
  83. return s > C_PAUSED_SYNC_T ? "TOO_LARGE" : drbd_conn_s_names[s];
  84. }
  85. const char *drbd_role_str(enum drbd_role s)
  86. {
  87. return s > R_SECONDARY ? "TOO_LARGE" : drbd_role_s_names[s];
  88. }
  89. const char *drbd_disk_str(enum drbd_disk_state s)
  90. {
  91. return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s];
  92. }
  93. const char *drbd_set_st_err_str(enum drbd_state_ret_codes err)
  94. {
  95. return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" :
  96. err > SS_TWO_PRIMARIES ? "TOO_LARGE"
  97. : drbd_state_sw_errors[-err];
  98. }