← Documents Documentation/admin-guide/device-mapper/dm-raid.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Device Mapper

dm-raid

DM에서 MD RAID를 구성하는 RAID type, parameter, RAID10 layout, reshape·journal, status·message와 discard 규칙입니다.

Source pathDocumentation/admin-guide/device-mapper/dm-raid.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

RAID 구성과 layout

dm-raid.rst:1-171

지원 RAID type, 일반 parameter와 RAID10 near·far·offset 배치를 설명합니다.

Reshape, journal과 status

dm-raid.rst:172-343

Device tuple, out-of-place reshape, write-hole journal, health와 sync action을 정리합니다.

Discard와 변경 이력

dm-raid.rst:344-423

RAID4/5/6 discard 안전 조건과 target 1.0.0~1.15.1 이력을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Device Mapper와 MD를 잇는 raid target

1-16

Device-mapper RAID, 즉 `dm-raid` target은 DM에서 MD로 이어지는 bridge를 제공합니다. 이를 통해 device-mapper interface로 MD RAID driver에 접근할 수 있습니다.

Mapping target 이름은 `raid`이며 table 형식은 RAID 종류, RAID parameter와 metadata/data device 쌍을 차례로 받습니다.

  <raid_type> <#raid_params> <raid_params> \
    <#raid_devs> <metadata_dev0> <dev0> [.. <metadata_devN> <devN>]
dm-raid 계층
Device Mapper table`raid` targetMD RAID driverMetadata/Data device tuplesMapped RAID device

DM table 구성을 MD RAID personality에 연결해 하나의 mapped device로 노출합니다.

지원 RAID type과 parity layout

17-75
dm-raid RAID type
TypeLayout과 용도
`raid0`복원력 없는 RAID0 striping
`raid1`RAID1 mirroring
`raid4`마지막 전용 parity disk를 쓰는 RAID4
`raid5_n`마지막 전용 parity와 takeover를 지원하는 RAID5. `raid4`와 같은 전이 layout
`raid5_la`Left asymmetric: parity 0 회전, data continuation
`raid5_ra`Right asymmetric: parity N 회전, data continuation
`raid5_ls`Left symmetric: parity 0 회전, data restart
`raid5_rs`Right symmetric: parity N 회전, data restart
`raid6_zr`Zero restart: parity zero가 좌→우 회전, data restart
`raid6_nr`N restart: parity N이 우→좌 회전, data restart
`raid6_nc`N continue: parity N이 우→좌 회전, data continuation
`raid6_n_6`마지막 두 disk에 parity와 Q-syndrome. `raid4`/`raid5_n` takeover용
`raid6_la_6`Source의 `raid_la` layout에 마지막 전용 Q disk를 더해 `raid5_la`와 takeover
`raid6_ra_6``raid5_ra`에 마지막 전용 Q disk를 더해 RAID5/6 takeover
`raid6_ls_6``raid5_ls`에 마지막 전용 Q disk를 더해 RAID5/6 takeover
`raid6_rs_6``raid5_rs`에 마지막 전용 Q disk를 더해 RAID5/6 takeover
`raid10``raid10_format`과 `raid10_copies`로 RAID10 striped mirrors, RAID1E adjacent/offset 등 선택

Striping, mirroring, parity 회전 방향과 takeover용 전이 layout을 구분합니다.

  ============= ===============================================================
  raid0		RAID0 striping (no resilience)
  raid1		RAID1 mirroring
  raid4		RAID4 with dedicated last parity disk
  raid5_n 	RAID5 with dedicated last parity disk supporting takeover
		Same as raid4

		- Transitory layout
  raid5_la	RAID5 left asymmetric

		- rotating parity 0 with data continuation
  raid5_ra	RAID5 right asymmetric

		- rotating parity N with data continuation
  raid5_ls	RAID5 left symmetric

		- rotating parity 0 with data restart
  raid5_rs 	RAID5 right symmetric

		- rotating parity N with data restart
  raid6_zr	RAID6 zero restart

		- rotating parity zero (left-to-right) with data restart
  raid6_nr	RAID6 N restart

		- rotating parity N (right-to-left) with data restart
  raid6_nc	RAID6 N continue

		- rotating parity N (right-to-left) with data continuation
  raid6_n_6	RAID6 with dedicate parity disks

		- parity and Q-syndrome on the last 2 disks;
		  layout for takeover from/to raid4/raid5_n
  raid6_la_6	Same as "raid_la" plus dedicated last Q-syndrome disk

		- layout for takeover from raid5_la from/to raid6
  raid6_ra_6	Same as "raid5_ra" dedicated last Q-syndrome disk

		- layout for takeover from raid5_ra from/to raid6
  raid6_ls_6	Same as "raid5_ls" dedicated last Q-syndrome disk

		- layout for takeover from raid5_ls from/to raid6
  raid6_rs_6	Same as "raid5_rs" dedicated last Q-syndrome disk

		- layout for takeover from raid5_rs from/to raid6
  raid10        Various RAID10 inspired algorithms chosen by additional params
		(see raid10_format and raid10_copies below)

		- RAID10: Striped Mirrors (aka 'Striping on top of mirrors')
		- RAID1E: Integrated Adjacent Stripe Mirroring
		- RAID1E: Integrated Offset Stripe Mirroring
		- and other similar RAID10 variants
  ============= ===============================================================

Parity layout의 기준은 SNIA DDF Technical Position v2.0 4장입니다: `https://www.snia.org/sites/default/files/SNIA_DDF_Technical_Position_v2.0.pdf`.

필수 chunk_size와 일반 optional parameter

76-112

`<#raid_params>`는 뒤따르는 parameter 수입니다. 유일한 필수 parameter인 `<chunk_size>`가 항상 먼저 오며 sector 단위 chunk 크기, 흔히 stripe size라 부르는 값을 지정합니다.

일반 RAID parameter
Parameter동작
`sync` / `nosync`RAID 초기화를 강제하거나 방지
`rebuild <idx>`0부터 시작하는 drive index를 rebuild
`daemon_sleep <ms>`Bitmap bit를 지우는 daemon 실행 간격. 길면 bitmap I/O는 줄지만 장애 후 resync가 느려질 수 있음
`min_recovery_rate <kB/sec/disk>`RAID 초기화 최소 rate 제한
`max_recovery_rate <kB/sec/disk>`RAID 초기화 최대 rate 제한
`write_mostly <idx>`해당 drive index를 write-mostly로 표시
`max_write_behind <sectors>``mdadm --write-behind=`에 해당
`stripe_cache <sectors>`RAID4/5/6 전용 stripe cache 크기
`region_size <sectors>`Region 수와 곱해 array logical size를 구성하며 bitmap이 region별 동기화 상태 기록

초기화, rebuild, bitmap, recovery rate와 RAID4/5/6 cache를 제어합니다.

    Mandatory parameters:
        <chunk_size>:
		      Chunk size in sectors.  This parameter is often known as
		      "stripe size".  It is the only mandatory parameter and
		      is placed first.

    followed by optional parameters (in any order):
	[sync|nosync]
		Force or prevent RAID initialization.

	[rebuild <idx>]
		Rebuild drive number 'idx' (first drive is 0).

	[daemon_sleep <ms>]
		Interval between runs of the bitmap daemon that
		clear bits.  A longer interval means less bitmap I/O but
		resyncing after a failure is likely to take longer.

	[min_recovery_rate <kB/sec/disk>]
		Throttle RAID initialization
	[max_recovery_rate <kB/sec/disk>]
		Throttle RAID initialization
	[write_mostly <idx>]
		Mark drive index 'idx' write-mostly.
	[max_write_behind <sectors>]
		See '--write-behind=' (man mdadm)
	[stripe_cache <sectors>]
		Stripe cache size (RAID 4/5/6 only)
	[region_size <sectors>]
		The region_size multiplied by the number of regions is the
		logical size of the array.  The bitmap records the device
		synchronisation state for each region.

RAID10 copies와 near·far·offset 배치

113-171

`raid10_copies <# copies>`와 `raid10_format <near|far|offset>`은 기본 RAID10 layout을 바꿉니다. Copy 기본값은 2이고 format 기본값은 `near`입니다.

RAID10 near layout
2 drives3 drives4 drives
1A1 A1A1 A1 A2A1 A1 A2 A2
2A2 A2A2 A3 A3A3 A3 A4 A4
3A3 A3A4 A4 A5A5 A5 A6 A6
4A4 A4A5 A6 A6A7 A7 A8 A8
undefinedundefined
undefinedundefined

같은 data copy를 인접 drive에 둡니다. 아래 행은 원문 ASCII layout의 대표 배치입니다.

		========	 ==========	   ==============
		2 drives         3 drives          4 drives
		========	 ==========	   ==============
		A1  A1           A1  A1  A2        A1  A1  A2  A2
		A2  A2           A2  A3  A3        A3  A3  A4  A4
		A3  A3           A4  A4  A5        A5  A5  A6  A6
		A4  A4           A5  A6  A6        A7  A7  A8  A8
		..  ..           ..  ..  ..        ..  ..  ..  ..
		========	 ==========	   ==============

`raid10_copies 2 raid10_format far`에서는 첫 copy 묶음 뒤에 반대 순서의 먼 copy 묶음을 배치합니다.

RAID10 far layout
구간2 drives3 drives4 drives
Near 1A1 A2A1 A2 A3A1 A2 A3 A4
Near 2A3 A4A4 A5 A6A5 A6 A7 A8
Far 1A2 A1A3 A1 A2A2 A1 A4 A3
Far 2A4 A3A6 A4 A5A6 A5 A8 A7

원문 2·3·4 drive ASCII 배치의 앞쪽과 far copy 구간을 구조화했습니다.

		========	     ============	  ===================
		2 drives             3 drives             4 drives
		========	     ============	  ===================
		A1  A2               A1   A2   A3         A1   A2   A3   A4
		A3  A4               A4   A5   A6         A5   A6   A7   A8
		A5  A6               A7   A8   A9         A9   A10  A11  A12
		..  ..               ..   ..   ..         ..   ..   ..   ..
		A2  A1               A3   A1   A2         A2   A1   A4   A3
		A4  A3               A6   A4   A5         A6   A5   A8   A7
		A6  A5               A9   A7   A8         A10  A9   A12  A11
		..  ..               ..   ..   ..         ..   ..   ..   ..
		========	     ============	  ===================

`raid10_copies 2 raid10_format offset`은 copy를 stripe 안에서 offset해 배치하며 RAID1E integrated offset stripe mirroring과 유사합니다.

RAID10 offset layout
2 drives3 drives4 drives
1A1 A2A1 A2 A3A1 A2 A3 A4
2A2 A1A3 A1 A2A2 A1 A4 A3
3A3 A4A4 A5 A6A5 A6 A7 A8
4A4 A3A6 A4 A5A6 A5 A8 A7

각 stripe 직후에 drive 순서를 바꾼 copy stripe가 이어집니다.

		========       ==========         ================
		2 drives       3 drives           4 drives
		========       ==========         ================
		A1  A2         A1  A2  A3         A1  A2  A3  A4
		A2  A1         A3  A1  A2         A2  A1  A4  A3
		A3  A4         A4  A5  A6         A5  A6  A7  A8
		A4  A3         A6  A4  A5         A6  A5  A8  A7
		A5  A6         A7  A8  A9         A9  A10 A11 A12
		A6  A5         A9  A7  A8         A10 A9  A12 A11
		..  ..         ..  ..  ..         ..  ..  ..  ..
		========       ==========         ================

Device reshape, data_offset와 journal

172-216
delta_disks reshape 지원
RAID layout추가제거최소 복원력
RAID4/5지원지원3 devices 유지
RAID6지원지원4 devices 유지
RAID10 near추가만미지원Layout 조건 적용
RAID10 offset추가만미지원Layout 조건 적용
RAID10 farreshape 미지원reshape 미지원해당 없음

`-251 < N < +251` 값으로 device 제거 또는 추가를 요청합니다.

`data_offset <sectors>`는 각 data device에서 user data가 시작하는 offset입니다. Stripe layout을 바꾸는 동안 원본 위에 덮어쓰지 않는 out-of-place reshape 공간을 제공하므로 언제든 interruption이나 crash가 발생해도 data를 잃지 않습니다.

Forward out-of-place reshape
각 device 앞쪽에 새 공간 확보`data_offset`의 기존 stripe 읽기더 큰 stripe 구성CRC/Q-syndrome 계산새 stripe를 offset 0에 기록N-1 후속 stripe 반복
동일 기법RAID allocation algorithm 변경예: `raid5_ls` → `raid5_n`

기존 작은 stripe를 offset에서 읽어 더 많은 device의 새 stripe를 offset 0에 씁니다.

`journal_dev <dev>`는 RAID4/5/6에 journal 장치를 추가해 component device의 비원자적 update가 만드는 write hole을 막습니다. 기본 writethrough이므로 non-journaled array보다 write가 제한되며, journal이 구성된 동안 takeover나 reshape는 할 수 없습니다.

RAID4/5/6 journal
RAID writeJournal deviceWritethrough 또는 writebackComponent data/parity updateWrite-hole 방지
`journal_mode writeback`Journal 자체가 resilient해야 함RAID1/RAID10 권장Single point of failure 방지

Journal이 component update를 보호하고 journal_mode가 cache 정책을 정합니다.

`journal_mode <writethrough|writeback>`은 journaled RAID4/5/6의 cache mode입니다. Writeback journal은 자체 write hole이 없는 resilient 장치여야 합니다.

        [delta_disks <N>]
		The delta_disks option value (-251 < N < +251) triggers
		device removal (negative value) or device addition (positive
		value) to any reshape supporting raid levels 4/5/6 and 10.
		RAID levels 4/5/6 allow for addition of devices (metadata
		and data device tuple), raid10_near and raid10_offset only
		allow for device addition. raid10_far does not support any
		reshaping at all.
		A minimum of devices have to be kept to enforce resilience,
		which is 3 devices for raid4/5 and 4 devices for raid6.

        [data_offset <sectors>]
		This option value defines the offset into each data device
		where the data starts. This is used to provide out-of-place
		reshaping space to avoid writing over data while
		changing the layout of stripes, hence an interruption/crash
		may happen at any time without the risk of losing data.
		E.g. when adding devices to an existing raid set during
		forward reshaping, the out-of-place space will be allocated
		at the beginning of each raid device. The kernel raid4/5/6/10
		MD personalities supporting such device addition will read the data from
		the existing first stripes (those with smaller number of stripes)
		starting at data_offset to fill up a new stripe with the larger
		number of stripes, calculate the redundancy blocks (CRC/Q-syndrome)
		and write that new stripe to offset 0. Same will be applied to all
		N-1 other new stripes. This out-of-place scheme is used to change
		the RAID type (i.e. the allocation algorithm) as well, e.g.
		changing from raid5_ls to raid5_n.

	[journal_dev <dev>]
		This option adds a journal device to raid4/5/6 raid sets and
		uses it to close the 'write hole' caused by the non-atomic updates
		to the component devices which can cause data loss during recovery.
		The journal device is used as writethrough thus causing writes to
		be throttled versus non-journaled raid4/5/6 sets.
		Takeover/reshape is not possible with a raid4/5/6 journal device;
		it has to be deconfigured before requesting these.

	[journal_mode <mode>]
		This option sets the caching mode on journaled raid4/5/6 raid sets
		(see 'journal_dev <dev>' above) to 'writethrough' or 'writeback'.
		If 'writeback' is selected the journal device has to be resilient
		and must not suffer from the 'write hole' problem itself (e.g. use
		raid1 or raid10) to avoid a single point of failure.

Metadata/data device tuple과 missing drive

217-227

`<#raid_devs>`는 array 구성 device 수입니다. 각 device는 metadata device와 data device 두 entry로 이뤄집니다. Target 1.8.0까지 metadata/data entry를 최대 64개 지원했고, 1.9.0부터 MD kernel runtime이 강제하는 최대 253개를 지원합니다.

생성 시 drive가 실패했거나 없으면 해당 위치의 metadata와 data drive 모두에 `-`를 지정할 수 있습니다.

RAID device tuple
Position첫 entry둘째 entryMissing 표현
0 ... NMetadata device 또는 `-`Data device 또는 `-``- -`
Version ≤ 1.8.0최대 64 entriesMetadata/data 포함Target 제한
Version ≥ 1.9.0최대 253MD runtime 제한Kernel이 강제

각 array position은 metadata와 data 두 slot을 가집니다.

<#raid_devs>: The number of devices composing the array.
	Each device consists of two entries.  The first is the device
	containing the metadata (if any); the second is the one containing the
	data. A Maximum of 64 metadata/data device entries are supported
	up to target version 1.8.0.
	1.9.0 supports up to 253 which is enforced by the used MD kernel runtime.

	If a drive has failed or is missing at creation time, a '-' can be
	given for both the metadata and data drives for a given position.

RAID4 table 예제

228-250

첫 예는 metadata 장치 없이 data drive 4개와 마지막 parity drive 1개를 쓰는 RAID4입니다. Chunk는 2048 sector, 즉 1 MiB입니다.

둘째 예는 각 data drive에 대응하는 metadata device를 제공하고 `sync`로 초기화를 강제하며 disk당 최소 recovery rate를 20 KiB/s로 설정합니다.

  # RAID4 - 4 data drives, 1 parity (no metadata devices)
  # No metadata devices specified to hold superblock/bitmap info
  # Chunk size of 1MiB
  # (Lines separated for easy reading)

  0 1960893648 raid \
          raid4 1 2048 \
          5 - 8:17 - 8:33 - 8:49 - 8:65 - 8:81

  # RAID4 - 4 data drives, 1 parity (with metadata devices)
  # Chunk size of 1MiB, force RAID initialization,
  #       min recovery rate at 20 kiB/sec/disk

  0 1960893648 raid \
          raid4 4 2048 sync min_recovery_rate 20 \
          5 8:17 8:18 8:33 8:34 8:49 8:50 8:65 8:66 8:81 8:82
두 RAID4 table 비교
예제RAID paramsDevice tuple
Metadata 없음`raid4 1 2048``- 8:17`, `- 8:33`, `- 8:49`, `- 8:65`, `- 8:81`
Metadata 있음`raid4 4 2048 sync min_recovery_rate 20``8:17 8:18` ... `8:81 8:82`

동일한 5-device RAID4에서 metadata와 optional parameter 유무를 비교합니다.

Table 출력과 status health·sync ratio

251-288

`dmsetup table`은 mapping을 만든 table을 표시합니다. Optional parameter는 원래 load 순서와 무관하게 문서 순서로 출력되며 `sync` 또는 `nosync`가 항상 먼저 옵니다. 반복 가능한 인자는 값 순으로 정렬됩니다.

`dmsetup status`는 array 상태와 health를 반환합니다. 첫 줄은 device-mapper 표준 출력이고 둘째·셋째 부분은 raid target이 만듭니다.

  1: <s> <l> raid \
  2:      <raid_type> <#devices> <health_chars> \
  3:      <sync_ratio> <sync_action> <mismatch_cnt>

예제 `0 1960893648 raid raid4 5 AAAAA 2/490221568 init 0`은 RAID4, device 5개가 모두 alive이며 초기 recovery가 490221568 중 2만큼 완료됐음을 뜻합니다.

        0 1960893648 raid raid4 5 AAAAA 2/490221568 init 0
Status 기본 필드
필드의미
`<raid_type>`생성에 사용한 RAID type
`<#devices>`Array device 수
`<health_chars>`Device마다 한 문자씩 health 표시
`<sync_ratio>``sync_action`이 처리한 양 / 전체 양
`<sync_action>`현재 synchronization 상태
`<mismatch_cnt>`Check에서 찾은 불일치 수

Array identity, health와 진행률을 한 줄에 압축합니다.

Device health 문자
문자상태
`A`Alive and in-sync
`a`Alive but not in-sync
`D`Dead 또는 failed

각 component 위치의 생존과 동기화 상태입니다.

	=============== =========================================================
	<raid_type>     Same as the <raid_type> used to create the array.
	<health_chars>  One char for each device, indicating:

			- 'A' = alive and in-sync
			- 'a' = alive but not in-sync
			- 'D' = dead/failed.
	<sync_ratio>    The ratio indicating how much of the array has undergone
			the process described by 'sync_action'.  If the
			'sync_action' is "check" or "repair", then the process
			of "resync" or "recover" can be considered complete.

sync_action, mismatch, offset와 journal 상태

289-327
sync_action 상태
Action동작
`idle`Synchronization action 없음
`frozen`현재 action 중단
`resync`초기 synchronization 또는 unclean shutdown 후 resync
`recover`Device rebuild 또는 replacement
`check`전체 block 일관성 검사, mismatch 기록, data 변경 없음
`repair`Check와 같지만 불일치를 수정
`reshape`Array reshape 진행

동기화·복구·검사·reshape 작업의 의미입니다.

`sync_ratio`는 해당 action의 처리 비율입니다. Action이 `check`나 `repair`라면 `resync` 또는 `recover`가 끝난 것으로 볼 수 있습니다. `mismatch_cnt`는 RAID1/10 mirror copy 차이 또는 RAID4/5/6 parity 오류 수이며 check 뒤에만 유효하고 healthy array는 0입니다.

`data_offset`은 component device별 user data 시작 위치이며 out-of-place reshape에 사용합니다.

Journal health 문자
문자상태
`A`Active write-through journal
`a`Active write-back journal
`D`Dead journal device
`-`Journal device 없음

Status 끝에서 journal device와 mode를 표시합니다.

	<sync_action>   One of the following possible states:

			idle
				- No synchronization action is being performed.
			frozen
				- The current action has been halted.
			resync
				- Array is undergoing its initial synchronization
				  or is resynchronizing after an unclean shutdown
				  (possibly aided by a bitmap).
			recover
				- A device in the array is being rebuilt or
				  replaced.
			check
				- A user-initiated full check of the array is
				  being performed.  All blocks are read and
				  checked for consistency.  The number of
				  discrepancies found are recorded in
				  <mismatch_cnt>.  No changes are made to the
				  array by this action.
			repair
				- The same as "check", but discrepancies are
				  corrected.
			reshape
				- The array is undergoing a reshape.
	<mismatch_cnt>  The number of discrepancies found between mirror copies
			in RAID1/10 or wrong parity values found in RAID4/5/6.
			This value is valid only after a "check" of the array
			is performed.  A healthy array has a 'mismatch_cnt' of 0.
	<data_offset>   The current data offset to the start of the user data on
			each component device of a raid set (see the respective
			raid parameter to support out-of-place reshaping).
	<journal_char>	- 'A' - active write-through journal device.
			- 'a' - active write-back journal device.
			- 'D' - dead journal device.
			- '-' - no journal device.
	=============== =========================================================

Message interface로 sync action 제어

328-343

`dm-raid` target은 `dmsetup` message interface로 현재 synchronization action을 제어합니다.

지원 message action
Message효과
`idle`현재 sync action 중단
`frozen`현재 sync action freeze
`resync`Resync 시작 또는 계속
`recover`Recover 시작 또는 계속
`check`Array scrub 시작
`repair`Array repair 시작

중단, 재개, scrub과 repair를 runtime에 요청합니다.

	========= ================================================
	"idle"    Halt the current sync action.
	"frozen"  Freeze the current sync action.
	"resync"  Initiate/continue a resync.
	"recover" Initiate/continue a recover process.
	"check"   Initiate a check (i.e. a "scrub") of the array.
	"repair"  Initiate a repair of the array.
	========= ================================================

RAID4/5/6 discard 안전성

344-374

Discard 구현은 vendor마다 다릅니다. 어떤 장치는 discarded block read에 0을 반환하고 `discard_zeroes_data`를 설정하지만, random data를 반환하거나 이 속성을 광고하고도 0을 신뢰성 있게 반환하지 않는 장치가 있습니다.

RAID4/5/6은 여러 장치 block으로 parity를 계산하며 성능상 `discard_zeroes_data`의 신뢰성에 의존합니다. Stripe 중간 block을 discard한 뒤 장치별 read 결과가 일관되지 않으면 parity가 매번 달라져 복원력에 쓸 수 없게 됩니다.

RAID parity와 unsafe discard
Stripe 일부 discard장치별 read 결과0 또는 random dataParity 계산 불일치Redundancy 손상 위험
기본 정책RAID4/5/6 discard 비활성화성능보다 data integrity 우선

일관되지 않은 discarded read가 parity 재계산을 불안정하게 만듭니다.

안전한 장치는 kernel whitelist에 추가되어 신뢰할 수 있습니다. 그러한 장치에서는 `devices_handle_discards_safely` dm-raid module parameter로 RAID4/5/6 discard를 안전하게 활성화할 수 있습니다.

    'devices_handle_discards_safely'

Target version 1.0.0~1.15.1 변경 이력

375-423
dm-raid version history
Version변경
1.0.0초기 버전, RAID4/5/6 지원
1.1.0RAID1 지원
1.2.0Failed device가 포함된 array 생성
1.3.0RAID10 지원
1.3.1RAID10 device replacement/rebuild
1.3.2RAID10 redundancy 검사 수정·개선
1.4.0Mapping 함수 인자 제거, 기능 변화 없음
1.4.1RAID10 redundancy validation 수정, commit `55ebbb5`
1.4.2RAID10 far·offset 알고리즘
1.5.0Message interface와 status의 `sync_action`, `mismatch_cnt`
1.5.1Resume 시 일시 실패 device 복원
1.5.2`[last_]sync_action`이 check가 아니면 mismatch 0
1.6.0Discard와 source 명칭 `devices_handle_discard_safely` parameter
1.7.0MD RAID0 mapping
1.8.0새 target flag 호환성 검사로 reshape 중 data corruption 방지
1.9.0RAID takeover, reshape, region size와 size reduction
1.9.1기존 RAID4/10 mapping 활성화 수정
1.9.2Constructor 실패·missing device의 table/status 출력 수정
1.10.0RAID4/5/6 journal device
1.10.1Reshape 요청의 data corruption 수정
1.11.0`raid10_copies`/`raid10_format` table 인자 순서 수정
1.11.1`journal_mode`의 RAID4/5/6 journal write-back
1.12.1`mddev_suspend()`와 `md_write_start()` deadlock 수정
1.13.0Recover 종료 health를 `a`에서 `A`로 수정
1.13.1조기 `md_stop_writes()` deadlock, size·state race 수정
1.13.2RAID redundancy validation과 frozen 상태 유지 문제 수정
1.14.0Small-device reshape race, stripe-add deadlock/data corruption, rebuild superblock·leg 오류 수정
1.15.0새 MD bitmap page가 있는 size extension synchronization 수정
1.15.1Rebuild, write_mostly, journal_dev/mode status 인자 수·인자 수정

지원 RAID level, reshape·journal·status 기능과 주요 오류 수정을 시간순으로 정리합니다.

 1.0.0	Initial version.  Support for RAID 4/5/6
 1.1.0	Added support for RAID 1
 1.2.0	Handle creation of arrays that contain failed devices.
 1.3.0	Added support for RAID 10
 1.3.1	Allow device replacement/rebuild for RAID 10
 1.3.2	Fix/improve redundancy checking for RAID10
 1.4.0	Non-functional change.  Removes arg from mapping function.
 1.4.1	RAID10 fix redundancy validation checks (commit 55ebbb5).
 1.4.2	Add RAID10 "far" and "offset" algorithm support.
 1.5.0	Add message interface to allow manipulation of the sync_action.
	New status (STATUSTYPE_INFO) fields: sync_action and mismatch_cnt.
 1.5.1	Add ability to restore transiently failed devices on resume.
 1.5.2	'mismatch_cnt' is zero unless [last_]sync_action is "check".
 1.6.0	Add discard support (and devices_handle_discard_safely module param).
 1.7.0	Add support for MD RAID0 mappings.
 1.8.0	Explicitly check for compatible flags in the superblock metadata
	and reject to start the raid set if any are set by a newer
	target version, thus avoiding data corruption on a raid set
	with a reshape in progress.
 1.9.0	Add support for RAID level takeover/reshape/region size
	and set size reduction.
 1.9.1	Fix activation of existing RAID 4/10 mapped devices
 1.9.2	Don't emit '- -' on the status table line in case the constructor
	fails reading a superblock. Correctly emit 'maj:min1 maj:min2' and
	'D' on the status line.  If '- -' is passed into the constructor, emit
	'- -' on the table line and '-' as the status line health character.
 1.10.0	Add support for raid4/5/6 journal device
 1.10.1	Fix data corruption on reshape request
 1.11.0	Fix table line argument order
	(wrong raid10_copies/raid10_format sequence)
 1.11.1	Add raid4/5/6 journal write-back support via journal_mode option
 1.12.1	Fix for MD deadlock between mddev_suspend() and md_write_start() available
 1.13.0	Fix dev_health status at end of "recover" (was 'a', now 'A')
 1.13.1	Fix deadlock caused by early md_stop_writes().  Also fix size an
	state races.
 1.13.2	Fix raid redundancy validation and avoid keeping raid set frozen
 1.14.0	Fix reshape race on small devices.  Fix stripe adding reshape
	deadlock/potential data corruption.  Update superblock when
	specific devices are requested via rebuild.  Fix RAID leg
	rebuild errors.
 1.15.0 Fix size extensions not being synchronized in case of new MD bitmap
        pages allocated;  also fix those not occurring after previous reductions
 1.15.1 Fix argument count and arguments for rebuild/write_mostly/journal_(dev|mode)
        on the status line.