aboutsummaryrefslogtreecommitdiff
path: root/README.org
diff options
context:
space:
mode:
authorLibravatar Martin Michalec <martin@michalec.dev>2026-11-07 07:26:34 +0000
committerLibravatar Martin Michalec <martin@michalec.dev>2026-11-07 08:38:33 +0000
commit7fe23e4a8fa6fce19fb3d5e3a8a1f5472496c928 (patch)
tree64c163a368fa600d6054796e05a4d8847ed1cd53 /README.org
downloadlab-7fe23e4a8fa6fce19fb3d5e3a8a1f5472496c928.tar.gz
publishHEADmaster
Diffstat (limited to 'README.org')
-rw-r--r--README.org359
1 files changed, 359 insertions, 0 deletions
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..79efc39
--- /dev/null
+++ b/README.org
@@ -0,0 +1,359 @@
1#+title: RAID 50 simulation
2#+subtitle: with message size of 8 bytes and 6 disks
3#+date: 2024H1
4
5* Task
6:PROPERTIES:
7:CUSTOM_ID: task
8:END:
9#+begin_note
10This is a machine translation.[fn:1]
11#+end_note
12
13Each student individually needs to develop an application that
14simulates the operation of a RAID array at levels 6 and 50 (5+0) with
15a specified size of the original message and the number of disks. The
16application performs read and write operations on the message at the
17specified address (a linear array of strings with indices from 0 to
1863). A table with task options is attached to the email, where one "+"
19symbol indicates one available option. Distribute them among
20yourselves in such a way that each person gets their own variant. The
21work must be completed in the form of an executable application file,
22a report, and an archive with the source code.
23
24The parameters for the task variants are from the table.
251) Array type: RAID 6 or RAID 50 (5+0). Information about these levels
26 in a simple and accessible form with explanatory images:
27 https://en.wikipedia.org/wiki/Standard_RAID_levels. RAID 6 Arrays
28 must restore data in case of failure of any two disks, RAID 50
29 arrays -- in case of failure of any one disk.
302) Redundancy calculation: XOR and/or POLY. XOR -- calculating the
31 value of a redundancy block using the "exclude or" operation for a
32 pair of blocks. In case of a larger and/or an odd number of blocks
33 messages can use a hierarchical XOR calculation., adding a fixed
34 service value (for example, a set of "1" according to the block
35 size) and any other techniques you choose discretion. POLY --
36 calculating the value of the redundancy block with using polynomial
37 expressions (for example, a pair of polynomials the first level is
38 A-B+C-D+E=X and A+2B-3C+4D-5E=Y for a RAID 6 array of seven disks,
39 where A..E are the blocks that make up the original message, X and
40 Y are redundancy blocks).
413) Message size: 8, 10, 12, 14 bytes. This is the size of the
42 original (whole) message to be written to the array and read from
43 the array. Message This size is specified by the user when
44 selecting a write operation, and the same size messages are given
45 to the user when selecting a read operation.
464) Number of disks: 3, 4, 5, 6, 7, 8, 10. This is the total number
47 disks in the array for writing message blocks and redundancy
48 blocks.
49
50Comments on the table.
511) You can, if you wish, choose a more complex RAID array
52 configuration, such as RAID 60 (6+0), if you’re interested, but
53 this must be согласован with me.
542) You can, if you wish, choose any other method of calculating
55 redundancy blocks, if you’re interested, but this must be
56 согласован. with me. You also need to be sure that the chosen
57 method allows you to fully restore the original message in case of
58 loss. any two blocks for RAID 6/60 (any message block + any block
59 redundancy, any two message blocks, two redundancy blocks). The
60 hierarchical calculation of XOR is demonstrated by the following
61 example. Let's give a RAID 5 array on five disks and the message
62 12345678(hex). Then the message blocks will be: 12, 34, 56, 78. We
63 count the XOR separately for the first pair of blocks: 12 XOR 34 =
64 26, separately for the second pair blocks: 56 XOR 78 = 2E, then
65 count the XOR for these two results: 26 XOR 2E = 08 -- we will
66 write this value in the block. redundancy. Now, if we lose any
67 message block (for example, 34), we will restore it. First, let's
68 check which original pair the block is missing from and calculate
69 the XOR of the remaining pair: 56 XOR 78 = 2E, now we count the XOR
70 of our redundancy block with the resulting result: 08 XOR 2E = 26
71 -- got the XOR of the first pair of values, now we find the lost
72 block from this value and the saved one. message block: 26 XOR 12
73 = 34 — the message block is restored, we can fully reconstruct the
74 original message. Adding a fixed service value can help, for
75 example, if the number of blocks is odd. Let’s say we have a RAID
76 5 array on four disks and the message is 123456(hex). Then the
77 message blocks will be: 12, 34, 56. You can add a service value,
78 for example, FF as of a fixed “virtual” block and completely repeat
79 the algorithm described above. Or you can do it differently:
80 calculate the XOR for the first pair of message blocks, then
81 calculate the XOR of the resulting value and the remaining message
82 block. That is: 12 XOR 34 = 26, 26 XOR 56 = 70 — this value will be
83 written to the redundancy block.
843) After analyzing the message size and the number of disks, you can
85 see that the message is not always "divided" into an integer number
86 of blocks. This should not bother you, because you can always
87 adopt rules according to which you will supplement the message
88 block with seniors. zeros so that all blocks have the same size.
89 For example, let given a RAID 6 array on five disks and a 5 byte
90 message (Martin: If we take ASCII, not hex...): 12345(hex). Given
91 that two disks will be used for redundancy when writing the
92 message, we need to divide the original message into three blocks:
93 12, 34, 5. The last block can be supplemented with a leading zero
94 to get the value 05, which will be written to the disk.
954) Do not forget that the parity in RAID 5 and 6 arrays, as well as in
96 their derivatives, is distributed. That is, when accessing each
97 next "row", the blocks of messages and redundancy will be They can
98 be arranged in different order. You can use a simple technique:
99 create a placement matrix and select a row of the matrix on based
100 on dividing the address modulo the number of disks. For example,
101 let there will be a RAID 5 array on four disks. For him, the
102 matrix of block placements can be as follows (here BS is a message
103 block, BI is a block redundancy).
104
105Your application can use either of two approaches as disks: text files
106(one disk is one file, one message block -- one line of the file) or a
107database (one disk - one table, one message block - one table entry)
108at your discretion. Files and tables must be named
109
110* Documentation
111:PROPERTIES:
112:CUSTOM_ID: documentation
113:END:
114The exported report can be found at [[https://git.michalec.dev/files/uni/term-04/supercomp-arch/lab/releases/latest/report.pdf][this link]].
115
116* Showcase
117:PROPERTIES:
118:CUSTOM_ID: showcase
119:END:
120A sample session of working with the program is provided; lines with
121comments start with =#=.[fn:2]
122#+begin_src text
123# Program start, there are no disk files
124INFO: initializing RAID 50 with XOR on 6 disks with 8 byte messages...
125WARNING: found bad disk (missing): disk0
126WARNING: found bad disk (missing): disk1
127WARNING: found bad disk (missing): disk2
128WARNING: found bad disk (missing): disk3
129WARNING: found bad disk (missing): disk4
130WARNING: found bad disk (missing): disk5
131ERROR: too many bad disks, reinitializing the array with new disks...
132# At this point, the disk files already exist.
133> 0 asdf
134ERROR: invalid command, must be on of (read, write)
135> 0 read asdf
136ERROR: trailing junk after command: asdf
137> 0 write
138ERROR: expected 16 hex digits for message, received 0
139> 0 write 112233445566778
140ERROR: expected 16 hex digits for message, received 15
141> 0 write 11223344556677888
142ERROR: expected 16 hex digits for message, received 17
143> 0 write asdf
144ERROR: message contains invalid character `s'
145> 0 write -10
146ERROR: message contains invalid character `-'
147>
148> 0 write 1122334455667788
149> 1 write 1122334455667788
150> 2 write 1122334455667788
151> 0 read
1521122334455667788
153> 1 read
1541122334455667788
155> 2 read
1561122334455667788
157>
158# Manualy damaged the disk2 file
159> 0 read
160WARNING: found bad disk (corrupted): disk2
161INFO: there is just 1 bad disk, recomputing it...
1621122334455667788
163>
164# Manualy damaged the disk4 file
165> 1 read
166WARNING: found bad disk (corrupted): disk4
167INFO: there is just 1 bad disk, recomputing it...
1681122334455667788
169>
170# Manualy damaged disk0 and disk5 files => we can recover
171> 2 read
172WARNING: found bad disk (corrupted): disk0
173WARNING: found bad disk (corrupted): disk5
174INFO: there are 2 bad disk in separate clusters, recomputing them...
1751122334455667788
176>
177# Manualy damaged disk0 and disk1 files => we can't recover
178> 0 read
179WARNING: found bad disk (corrupted): disk0
180WARNING: found bad disk (corrupted): disk1
181ERROR: too many bad disks, reinitializing the array with new disks...
182No data stored!
183>
184# No message has been recorded at address 0x1F yet
185> 1F read
186No data stored!
187>
188# Attempt to access an address outside the allowed range
189> 40 read
190ERROR: address not in set [0x00; 0x40)
191> AA read
192ERROR: address not in set [0x00; 0x40)
193> 100 read
194ERROR: address not in set [0x00; 0x40)
195> interrupt
196#+end_src
197
198* Releases
199- [[https://git.michalec.dev/files/uni/term-04/supercomp-arch/lab/releases/latest/][latest]]
200- [[https://git.michalec.dev/files/uni/term-04/supercomp-arch/lab/releases/][all]]
201
202* Unlicense
203:PROPERTIES:
204:CUSTOM_ID: unlicense
205:END:
206#+include: UNLICENSE verse
207
208* Footnotes
209:PROPERTIES:
210:CUSTOM_ID: footnotes
211:END:
212[fn:1] Original text:
213#+HTML: <i>
214#+begin_quote
215Каждому студенту индивидуально необходимо разработать приложение,
216моделирующее работу RAID-массива уровней 6 и 50 (5+0) с заданными
217размером исходного сообщения и числом дисков. Приложение выполняет
218операции чтения и записи сообщения по указываемому адресу (линейный
219массив строк с индексами от 0 до 63). К письму приложена таблица с
220вариантами заданий, где один символ "+" обозначает один доступный для
221выбора вариант. Распределите их между собой таким образом, чтобы
222каждому достался свой вариант. Работа должна быть выполнена в виде
223исполняемого файла приложения, отчёта, архива с исходным кодом.
224
225Параметры вариантов задания из таблицы.
2261) Тип массива: RAID 6 или RAID 50 (5+0). Информация об этих уровнях
227 в простой и доступной форме с поясняющими изображениями:
228 https://en.wikipedia.org/wiki/Standard_RAID_levels. Массивы RAID 6
229 должны восстанавливать данные при выходе из строя любых двух
230 дисков, массивы RAID 50 -- при выходе из строя любого одного диска.
2312) Подсчёт избыточности: XOR и/или POLY. XOR -- подсчёт значения
232 блока избыточности с использованием операции "исключающего или" для
233 пары блоков. В случае большего и/или нечётного количества блоков
234 сообщения можно использовать иерархическое вычисление XOR,
235 добавление фиксированного служебного значения (например, набор "1"
236 соответственно размеру блока) и любые другие приёмы на ваше
237 усмотрение. POLY -- подсчёт значения блока избыточности с
238 использованием полиномиальных выражений (например, пара полиномов
239 первого уровня вида A-B+C-D+E=X и A+2B-3C+4D-5E=Y для массива RAID
240 6 из семи дисков, где A..E -- блоки, составляющие исходное
241 сообщение, X и Y -- блоки избыточности).
2423) Размер сообщения: 8, 10, 12, 14 байт. Это размер исходного (целого)
243 сообщения для записи на массив и читаемого с массива. Сообщение
244 такого размера указывает пользователь при выборе операции записи и
245 такого же размера сообщения выдаются пользователю при выборе
246 операции чтения.
2474) Количество дисков: 3, 4, 5, 6, 7, 8, 10. Это общее количество
248 дисков в массиве для записи блоков сообщения и блоков избыточности.
249
250Комментарии по таблице.
2511) Вы можете, по желанию, выбрать более сложный вариант массива RAID
252 60 (6+0), если вам это интересно, но это необходимо согласовать со
253 мной.
2542) Вы можете, по желанию, выбрать любой другой способ подсчёта блоков
255 избыточности, если вам это интересно, но это необходимо согласовать
256 со мной. Также вы должны быть уверены, что выбранный способ
257 позволяет вам полностью восстановить исходное сообщение при потере
258 любых двух блоков для RAID 6/60 (любой блок сообщения + любой блок
259 избыточности, любые два блока сообщения, два блока избыточности).
260 Иерархическое вычисление XOR демонстрируется следующим примером.
261 Пусть дан массив RAID 5 на пяти дисках и сообщение 12345678(hex).
262 Тогда блоки сообщения будут: 12, 34, 56, 78. Считаем XOR отдельно
263 для первой пары блоков: 12 XOR 34 = 26, отдельно -- для второй пары
264 блоков: 56 XOR 78 = 2E, затем считаем XOR для этих двух
265 результатов: 26 XOR 2E = 08 -- это значение и запишем в блок
266 избыточности. Теперь при потере любого блока сообщения
267 (например, 34) восстановим его. Сначала проверим, из какой
268 исходной пары пропал блок и посчитаем XOR оставшейся пары: 56 XOR
269 78 = 2E, теперь считаем XOR нашего блока избыточности с полученным
270 результатом: 08 XOR 2E = 26 -- получили XOR первой пары значений,
271 теперь находим потерянный блок из этого значения и сохранившегося
272 блока сообщения: 26 XOR 12 = 34 -- блок сообщения восстановлен,
273 можем полностью собрать исходное сообщение. Добавление
274 фиксированного служебного значения может помочь, например, если
275 количество блоков нечётное. Пусть дан массив RAID 5 на четырёх
276 дисках сообщение 123456(hex). Тогда блоки сообщения будут: 12,
277 34, 56. Можно добавить служебное значение, например, FF в качестве
278 фиксированного "виртуального" блока и полностью повторить описанный
279 выше алгоритм. А можно и поступить иначе: вычислять XOR для первой
280 пары блоков сообщения, затем вычислять XOR полученного значения и
281 оставшегося блока сообщения. То есть: 12 XOR 34 = 26, 26 XOR 56 =
282 70 -- это значение и запишем в блок избыточности.
2833) Проанализировав размер сообщения и количество дисков, вы можете
284 увидеть, что сообщение не всегда "делится" на целое число блоков.
285 Это не должно вас смущать, поскольку вы всегда можете принять
286 правила, по которым будете дополнять блок сообщения старшими
287 нулями, чтобы все блоки имели одинаковый размер. Например, пусть
288 дан массив RAID 6 на пяти дисках и сообщение размером 5 байт (Мартин:
289 если брать ascii, а не hex...): 12345(hex). Учитывая, что два
290 диска при записи сообщения будут задействованы под избыточность,
291 нам необходимо разделить исходное сообщение на три блока: 12,
292 34, 5. Последний блок можно дополнить старшим нулём, чтобы получить
293 значение 05, которое и будет записано на диск.
2944) Не забывайте, что чётность в массивах RAID 5 и 6, как и в
295 производных от них, распределённая. То есть, при обращении к
296 каждой следующей "строке" блоки сообщений и избыточности будут
297 располагаться в разном порядке. Вы можете использовать простой
298 приём: создать матрицу размещений и выбирать строку матрицы на
299 основе деления адреса по модулю от числа дисков. Например, пусть
300 будет массив RAID 5 на четырёх дисках. Для него матрица размещений
301 блоков может быть такой (здесь БС -- блок сообщения, БИ -- блок
302 избыточности).
303
304В качестве дисков ваше приложение может использовать любой из двух
305подходов: текстовые файлы (один диск -- один файл, один блок сообщения
306-- одна строка файла) или базу данных (один диск -- одина таблица,
307один блок сообщения -- одна запись таблицы) на ваше усмотрение. Файлы
308и таблицы должны быть проименованы как disk0..disk9, файлы должны
309располагаться в рабочем каталоге приложения и не блокироваться для
310записи в процессе его работы (чтобы можно было очистить содержимое
311любого файла или удалить его, моделируя выход диска из строя).
312
313Примеры пользовательских операций (массив RAID 5 на трёх дисках):
314
315=> 00 write 3d6c= (адрес: 00, операция: запись, сообщение: 3D6C, блок
316сообщения для записи на диск 0: 3D, блок сообщения для записи на диск
3171: 6C, блок избыточности для записи на диск 2 -- арифметическая сумма
3183В+6С: A9);
319
320=> 01 write 519a= (адрес: 01, операция: запись, сообщение: 519A, блок
321сообщения для записи на диск 0: 51, блок избыточности для записи на
322диск 2 -- арифметическая сумма 51+9A: EB, блок сообщения для записи на
323диск 1: 9A);
324
325... удаляем содержимое файла или таблицы "disk0";
326
327=> 00 read= (адрес: 00, операция: чтение, диск 0: пусто, диск 1: блок
328сообщения 6C, диск 2: блок избыточности A9, вычисляем блок сообщения
329диска 0: A9-6C=3D, собираем сообщение: 3D6C).
330
331Графика, анимации, счётчики -- ничего этого не нужно, простое
332консольное приложение. При использовании базы данных необходимо
333отдельно приложить файлы сценариев создания таблиц, в качестве
334диалектов допустимы T-SQL и MySQL.
335#+end_quote
336#+HTML: </i>
337
338[fn:2] I've actually implemented all of these configurations:
339- [[file:../tree/src/raid-4-poly-10b-7d.c][raid-4-poly-10b-7d]]
340- [[file:../tree/src/raid-4-poly-8b-6d.c][raid-4-poly-8b-6d]]
341- [[file:../tree/src/raid-4-poly-8b-7d.c][raid-4-poly-8b-7d]]
342- [[file:../tree/src/raid-4-xor-10b-3d.c][raid-4-xor-10b-3d]]
343- [[file:../tree/src/raid-4-xor-10b-6d.c][raid-4-xor-10b-6d]]
344- [[file:../tree/src/raid-4-xor-10b-7d.c][raid-4-xor-10b-7d]]
345- [[file:../tree/src/raid-4-xor-12b-4d.c][raid-4-xor-12b-4d]]
346- [[file:../tree/src/raid-4-xor-12b-5d.c][raid-4-xor-12b-5d]]
347- [[file:../tree/src/raid-4-xor-12b-7d.c][raid-4-xor-12b-7d]]
348- [[file:../tree/src/raid-4-xor-14b-4d.c][raid-4-xor-14b-4d]]
349- [[file:../tree/src/raid-4-xor-14b-5d.c][raid-4-xor-14b-5d]]
350- [[file:../tree/src/raid-4-xor-14b-8d.c][raid-4-xor-14b-8d]]
351- [[file:../tree/src/raid-4-xor-8b-8d.c][raid-4-xor-8b-8d]]
352- [[file:../tree/src/raid-5-poly-14b-4d.c][raid-5-poly-14b-4d]]
353- [[file:../tree/src/raid-5-xor-12b-3d.c][raid-5-xor-12b-3d]]
354- [[file:../tree/src/raid-5-xor-12b-5d.c][raid-5-xor-12b-5d]]
355- [[file:../tree/src/raid-5-xor-12b-6d.c][raid-5-xor-12b-6d]]
356- [[file:../tree/src/raid-50-poly-12b-6d.c][raid-50-poly-12b-6d]]
357- [[file:../tree/src/raid-50-poly-8b-6d.c][raid-50-poly-8b-6d]]
358- [[file:../tree/src/raid-50-xor-12b-6d.c][raid-50-xor-12b-6d]]
359- [[file:../tree/src/raid-50-xor-8b-6d.c][raid-50-xor-8b-6d]]