dm-raid.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. dm-raid
  2. =======
  3. The device-mapper RAID (dm-raid) target provides a bridge from DM to MD.
  4. It allows the MD RAID drivers to be accessed using a device-mapper
  5. interface.
  6. Mapping Table Interface
  7. -----------------------
  8. The target is named "raid" and it accepts the following parameters:
  9. <raid_type> <#raid_params> <raid_params> \
  10. <#raid_devs> <metadata_dev0> <dev0> [.. <metadata_devN> <devN>]
  11. <raid_type>:
  12. raid1 RAID1 mirroring
  13. raid4 RAID4 dedicated parity disk
  14. raid5_la RAID5 left asymmetric
  15. - rotating parity 0 with data continuation
  16. raid5_ra RAID5 right asymmetric
  17. - rotating parity N with data continuation
  18. raid5_ls RAID5 left symmetric
  19. - rotating parity 0 with data restart
  20. raid5_rs RAID5 right symmetric
  21. - rotating parity N with data restart
  22. raid6_zr RAID6 zero restart
  23. - rotating parity zero (left-to-right) with data restart
  24. raid6_nr RAID6 N restart
  25. - rotating parity N (right-to-left) with data restart
  26. raid6_nc RAID6 N continue
  27. - rotating parity N (right-to-left) with data continuation
  28. raid10 Various RAID10 inspired algorithms chosen by additional params
  29. - RAID10: Striped Mirrors (aka 'Striping on top of mirrors')
  30. - RAID1E: Integrated Adjacent Stripe Mirroring
  31. - RAID1E: Integrated Offset Stripe Mirroring
  32. - and other similar RAID10 variants
  33. Reference: Chapter 4 of
  34. http://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf
  35. <#raid_params>: The number of parameters that follow.
  36. <raid_params> consists of
  37. Mandatory parameters:
  38. <chunk_size>: Chunk size in sectors. This parameter is often known as
  39. "stripe size". It is the only mandatory parameter and
  40. is placed first.
  41. followed by optional parameters (in any order):
  42. [sync|nosync] Force or prevent RAID initialization.
  43. [rebuild <idx>] Rebuild drive number 'idx' (first drive is 0).
  44. [daemon_sleep <ms>]
  45. Interval between runs of the bitmap daemon that
  46. clear bits. A longer interval means less bitmap I/O but
  47. resyncing after a failure is likely to take longer.
  48. [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization
  49. [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization
  50. [write_mostly <idx>] Mark drive index 'idx' write-mostly.
  51. [max_write_behind <sectors>] See '--write-behind=' (man mdadm)
  52. [stripe_cache <sectors>] Stripe cache size (RAID 4/5/6 only)
  53. [region_size <sectors>]
  54. The region_size multiplied by the number of regions is the
  55. logical size of the array. The bitmap records the device
  56. synchronisation state for each region.
  57. [raid10_copies <# copies>]
  58. [raid10_format <near|far|offset>]
  59. These two options are used to alter the default layout of
  60. a RAID10 configuration. The number of copies is can be
  61. specified, but the default is 2. There are also three
  62. variations to how the copies are laid down - the default
  63. is "near". Near copies are what most people think of with
  64. respect to mirroring. If these options are left unspecified,
  65. or 'raid10_copies 2' and/or 'raid10_format near' are given,
  66. then the layouts for 2, 3 and 4 devices are:
  67. 2 drives 3 drives 4 drives
  68. -------- ---------- --------------
  69. A1 A1 A1 A1 A2 A1 A1 A2 A2
  70. A2 A2 A2 A3 A3 A3 A3 A4 A4
  71. A3 A3 A4 A4 A5 A5 A5 A6 A6
  72. A4 A4 A5 A6 A6 A7 A7 A8 A8
  73. .. .. .. .. .. .. .. .. ..
  74. The 2-device layout is equivalent 2-way RAID1. The 4-device
  75. layout is what a traditional RAID10 would look like. The
  76. 3-device layout is what might be called a 'RAID1E - Integrated
  77. Adjacent Stripe Mirroring'.
  78. If 'raid10_copies 2' and 'raid10_format far', then the layouts
  79. for 2, 3 and 4 devices are:
  80. 2 drives 3 drives 4 drives
  81. -------- -------------- --------------------
  82. A1 A2 A1 A2 A3 A1 A2 A3 A4
  83. A3 A4 A4 A5 A6 A5 A6 A7 A8
  84. A5 A6 A7 A8 A9 A9 A10 A11 A12
  85. .. .. .. .. .. .. .. .. ..
  86. A2 A1 A3 A1 A2 A2 A1 A4 A3
  87. A4 A3 A6 A4 A5 A6 A5 A8 A7
  88. A6 A5 A9 A7 A8 A10 A9 A12 A11
  89. .. .. .. .. .. .. .. .. ..
  90. If 'raid10_copies 2' and 'raid10_format offset', then the
  91. layouts for 2, 3 and 4 devices are:
  92. 2 drives 3 drives 4 drives
  93. -------- ------------ -----------------
  94. A1 A2 A1 A2 A3 A1 A2 A3 A4
  95. A2 A1 A3 A1 A2 A2 A1 A4 A3
  96. A3 A4 A4 A5 A6 A5 A6 A7 A8
  97. A4 A3 A6 A4 A5 A6 A5 A8 A7
  98. A5 A6 A7 A8 A9 A9 A10 A11 A12
  99. A6 A5 A9 A7 A8 A10 A9 A12 A11
  100. .. .. .. .. .. .. .. .. ..
  101. Here we see layouts closely akin to 'RAID1E - Integrated
  102. Offset Stripe Mirroring'.
  103. <#raid_devs>: The number of devices composing the array.
  104. Each device consists of two entries. The first is the device
  105. containing the metadata (if any); the second is the one containing the
  106. data.
  107. If a drive has failed or is missing at creation time, a '-' can be
  108. given for both the metadata and data drives for a given position.
  109. Example Tables
  110. --------------
  111. # RAID4 - 4 data drives, 1 parity (no metadata devices)
  112. # No metadata devices specified to hold superblock/bitmap info
  113. # Chunk size of 1MiB
  114. # (Lines separated for easy reading)
  115. 0 1960893648 raid \
  116. raid4 1 2048 \
  117. 5 - 8:17 - 8:33 - 8:49 - 8:65 - 8:81
  118. # RAID4 - 4 data drives, 1 parity (with metadata devices)
  119. # Chunk size of 1MiB, force RAID initialization,
  120. # min recovery rate at 20 kiB/sec/disk
  121. 0 1960893648 raid \
  122. raid4 4 2048 sync min_recovery_rate 20 \
  123. 5 8:17 8:18 8:33 8:34 8:49 8:50 8:65 8:66 8:81 8:82
  124. Status Output
  125. -------------
  126. 'dmsetup table' displays the table used to construct the mapping.
  127. The optional parameters are always printed in the order listed
  128. above with "sync" or "nosync" always output ahead of the other
  129. arguments, regardless of the order used when originally loading the table.
  130. Arguments that can be repeated are ordered by value.
  131. 'dmsetup status' yields information on the state and health of the array.
  132. The output is as follows (normally a single line, but expanded here for
  133. clarity):
  134. 1: <s> <l> raid \
  135. 2: <raid_type> <#devices> <health_chars> \
  136. 3: <sync_ratio> <sync_action> <mismatch_cnt>
  137. Line 1 is the standard output produced by device-mapper.
  138. Line 2 & 3 are produced by the raid target and are best explained by example:
  139. 0 1960893648 raid raid4 5 AAAAA 2/490221568 init 0
  140. Here we can see the RAID type is raid4, there are 5 devices - all of
  141. which are 'A'live, and the array is 2/490221568 complete with its initial
  142. recovery. Here is a fuller description of the individual fields:
  143. <raid_type> Same as the <raid_type> used to create the array.
  144. <health_chars> One char for each device, indicating: 'A' = alive and
  145. in-sync, 'a' = alive but not in-sync, 'D' = dead/failed.
  146. <sync_ratio> The ratio indicating how much of the array has undergone
  147. the process described by 'sync_action'. If the
  148. 'sync_action' is "check" or "repair", then the process
  149. of "resync" or "recover" can be considered complete.
  150. <sync_action> One of the following possible states:
  151. idle - No synchronization action is being performed.
  152. frozen - The current action has been halted.
  153. resync - Array is undergoing its initial synchronization
  154. or is resynchronizing after an unclean shutdown
  155. (possibly aided by a bitmap).
  156. recover - A device in the array is being rebuilt or
  157. replaced.
  158. check - A user-initiated full check of the array is
  159. being performed. All blocks are read and
  160. checked for consistency. The number of
  161. discrepancies found are recorded in
  162. <mismatch_cnt>. No changes are made to the
  163. array by this action.
  164. repair - The same as "check", but discrepancies are
  165. corrected.
  166. reshape - The array is undergoing a reshape.
  167. <mismatch_cnt> The number of discrepancies found between mirror copies
  168. in RAID1/10 or wrong parity values found in RAID4/5/6.
  169. This value is valid only after a "check" of the array
  170. is performed. A healthy array has a 'mismatch_cnt' of 0.
  171. Message Interface
  172. -----------------
  173. The dm-raid target will accept certain actions through the 'message' interface.
  174. ('man dmsetup' for more information on the message interface.) These actions
  175. include:
  176. "idle" - Halt the current sync action.
  177. "frozen" - Freeze the current sync action.
  178. "resync" - Initiate/continue a resync.
  179. "recover"- Initiate/continue a recover process.
  180. "check" - Initiate a check (i.e. a "scrub") of the array.
  181. "repair" - Initiate a repair of the array.
  182. "reshape"- Currently unsupported (-EINVAL).
  183. Discard Support
  184. ---------------
  185. The implementation of discard support among hardware vendors varies.
  186. When a block is discarded, some storage devices will return zeroes when
  187. the block is read. These devices set the 'discard_zeroes_data'
  188. attribute. Other devices will return random data. Confusingly, some
  189. devices that advertise 'discard_zeroes_data' will not reliably return
  190. zeroes when discarded blocks are read! Since RAID 4/5/6 uses blocks
  191. from a number of devices to calculate parity blocks and (for performance
  192. reasons) relies on 'discard_zeroes_data' being reliable, it is important
  193. that the devices be consistent. Blocks may be discarded in the middle
  194. of a RAID 4/5/6 stripe and if subsequent read results are not
  195. consistent, the parity blocks may be calculated differently at any time;
  196. making the parity blocks useless for redundancy. It is important to
  197. understand how your hardware behaves with discards if you are going to
  198. enable discards with RAID 4/5/6.
  199. Since the behavior of storage devices is unreliable in this respect,
  200. even when reporting 'discard_zeroes_data', by default RAID 4/5/6
  201. discard support is disabled -- this ensures data integrity at the
  202. expense of losing some performance.
  203. Storage devices that properly support 'discard_zeroes_data' are
  204. increasingly whitelisted in the kernel and can thus be trusted.
  205. For trusted devices, the following dm-raid module parameter can be set
  206. to safely enable discard support for RAID 4/5/6:
  207. 'devices_handle_discards_safely'
  208. Version History
  209. ---------------
  210. 1.0.0 Initial version. Support for RAID 4/5/6
  211. 1.1.0 Added support for RAID 1
  212. 1.2.0 Handle creation of arrays that contain failed devices.
  213. 1.3.0 Added support for RAID 10
  214. 1.3.1 Allow device replacement/rebuild for RAID 10
  215. 1.3.2 Fix/improve redundancy checking for RAID10
  216. 1.4.0 Non-functional change. Removes arg from mapping function.
  217. 1.4.1 RAID10 fix redundancy validation checks (commit 55ebbb5).
  218. 1.4.2 Add RAID10 "far" and "offset" algorithm support.
  219. 1.5.0 Add message interface to allow manipulation of the sync_action.
  220. New status (STATUSTYPE_INFO) fields: sync_action and mismatch_cnt.
  221. 1.5.1 Add ability to restore transiently failed devices on resume.
  222. 1.5.2 'mismatch_cnt' is zero unless [last_]sync_action is "check".
  223. 1.6.0 Add discard support (and devices_handle_discard_safely module param).
  224. 1.7.0 Add support for MD RAID0 mappings.