dm-raid.rst 17 KB

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