dm-raid.txt 14 KB

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