md_u.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
  3. Copyright (C) 1998 Ingo Molnar
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. You should have received a copy of the GNU General Public License
  9. (for example /usr/src/linux/COPYING); if not, write to the Free
  10. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  11. */
  12. #ifndef _MD_U_H
  13. #define _MD_U_H
  14. /*
  15. * Different major versions are not compatible.
  16. * Different minor versions are only downward compatible.
  17. * Different patchlevel versions are downward and upward compatible.
  18. */
  19. #define MD_MAJOR_VERSION 0
  20. #define MD_MINOR_VERSION 90
  21. /*
  22. * MD_PATCHLEVEL_VERSION indicates kernel functionality.
  23. * >=1 means different superblock formats are selectable using SET_ARRAY_INFO
  24. * and major_version/minor_version accordingly
  25. * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT
  26. * in the super status byte
  27. * >=3 means that bitmap superblock version 4 is supported, which uses
  28. * little-ending representation rather than host-endian
  29. */
  30. #define MD_PATCHLEVEL_VERSION 3
  31. /* ioctls */
  32. /* status */
  33. #define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
  34. #define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
  35. #define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
  36. #define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
  37. #define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
  38. #define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
  39. /* configuration */
  40. #define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
  41. #define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
  42. #define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
  43. #define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t)
  44. #define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
  45. #define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
  46. #define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
  47. #define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
  48. #define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
  49. #define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
  50. #define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a)
  51. #define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int)
  52. /* usage */
  53. #define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
  54. /* 0x31 was START_ARRAY */
  55. #define STOP_ARRAY _IO (MD_MAJOR, 0x32)
  56. #define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
  57. #define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
  58. /* 63 partitions with the alternate major number (mdp) */
  59. #define MdpMinorShift 6
  60. #ifdef __KERNEL__
  61. extern int mdp_major;
  62. #endif
  63. typedef struct mdu_version_s {
  64. int major;
  65. int minor;
  66. int patchlevel;
  67. } mdu_version_t;
  68. typedef struct mdu_array_info_s {
  69. /*
  70. * Generic constant information
  71. */
  72. int major_version;
  73. int minor_version;
  74. int patch_version;
  75. int ctime;
  76. int level;
  77. int size;
  78. int nr_disks;
  79. int raid_disks;
  80. int md_minor;
  81. int not_persistent;
  82. /*
  83. * Generic state information
  84. */
  85. int utime; /* 0 Superblock update time */
  86. int state; /* 1 State bits (clean, ...) */
  87. int active_disks; /* 2 Number of currently active disks */
  88. int working_disks; /* 3 Number of working disks */
  89. int failed_disks; /* 4 Number of failed disks */
  90. int spare_disks; /* 5 Number of spare disks */
  91. /*
  92. * Personality information
  93. */
  94. int layout; /* 0 the array's physical layout */
  95. int chunk_size; /* 1 chunk size in bytes */
  96. } mdu_array_info_t;
  97. /* non-obvious values for 'level' */
  98. #define LEVEL_MULTIPATH (-4)
  99. #define LEVEL_LINEAR (-1)
  100. #define LEVEL_FAULTY (-5)
  101. /* we need a value for 'no level specified' and 0
  102. * means 'raid0', so we need something else. This is
  103. * for internal use only
  104. */
  105. #define LEVEL_NONE (-1000000)
  106. typedef struct mdu_disk_info_s {
  107. /*
  108. * configuration/status of one particular disk
  109. */
  110. int number;
  111. int major;
  112. int minor;
  113. int raid_disk;
  114. int state;
  115. } mdu_disk_info_t;
  116. typedef struct mdu_start_info_s {
  117. /*
  118. * configuration/status of one particular disk
  119. */
  120. int major;
  121. int minor;
  122. int raid_disk;
  123. int state;
  124. } mdu_start_info_t;
  125. typedef struct mdu_bitmap_file_s
  126. {
  127. char pathname[4096];
  128. } mdu_bitmap_file_t;
  129. typedef struct mdu_param_s
  130. {
  131. int personality; /* 1,2,3,4 */
  132. int chunk_size; /* in bytes */
  133. int max_fault; /* unused for now */
  134. } mdu_param_t;
  135. #endif