142 / 163 · C11 · 8 min
Redundant Arrays of Inexpensive Disks (RAID)
RAID organizes multiple inexpensive disks into an array that simultaneously improves capacity, throughput and fault tolerance while remaining completely transparent to the host. This chapter covers the external interface, the assumed fault model, the three evaluation axes and the simplest striping organization.
In this lesson
Motivation and Transparent Deployment
A lone disk readily becomes a bottleneck in speed, space and lifetime. Treating several disks as one unit yields parallel request service, a larger contiguous address space and redundancy that masks individual failures. The decisive property is that the whole still looks like an ordinary disk, so neither the operating system nor applications need any modification.
External Interface and Controller Internals
The file system above sees only a linear array of blocks and issues ordinary logical reads and writes. The controller translates each logical request into one or more physical disk operations while managing buffers and any needed checksums. A hardware realization typically contains its own microprocessor, volatile and non-volatile memory plus a dedicated parity engine—essentially a computer dedicated to storage firmware.
Fault Assumption and Three-Axis Evaluation
The simplest fail-stop model is used: a disk is either fully operational or permanently lost, and the loss is immediately visible to the controller. Every concrete scheme is judged on three mutually constraining axes: usable capacity seen by clients, the number of simultaneous disk failures that can be survived, and realized bandwidth plus latency under sequential versus random workloads.
RAID-0 Striping Organization
The simplest arrangement places successive logical blocks round-robin across the disks, wasting no space and adding no redundancy. Blocks that sit in the same “row” form a stripe, so a large sequential read can start every disk at once. Chunk size decides how many consecutive blocks stay on one disk before the next disk is used, trading off small-random versus large-sequential performance.
Pitfalls
- Computing only raw capacity while ignoring parallelism differences under real workloads
- Simplifying the fault model to “whole-disk instantly detectable” and thereby ignoring silent corruption
Run an example
Minimum C11 · complete program · Download .c
#include <stdio.h>
int main(void) {
const int N = 4;
const int C = 1;
printf("RAID Level 0 mapping for first 16 logical blocks\n");
for (int lb = 0; lb < 16; lb++) {
int d = (lb / C) % N;
int off = (lb / (N * C)) * C + (lb % C);
printf("LB %2d maps to disk %d offset %d\n", lb, d, off);
}
return 0;
}
Compile locally
gcc -std=c11 -Wall -Wextra -Wpedantic -Werror ostep-38-raid.c -o example && ./exampleExpected result
RAID Level 0 mapping for first 16 logical blocks
LB 0 maps to disk 0 offset 0
LB 1 maps to disk 1 offset 0
LB 2 maps to disk 2 offset 0
LB 3 maps to disk 3 offset 0
LB 4 maps to disk 0 offset 1
LB 5 maps to disk 1 offset 1
LB 6 maps to disk 2 offset 1
LB 7 maps to disk 3 offset 1
LB 8 maps to disk 0 offset 2
LB 9 maps to disk 1 offset 2
LB 10 maps to disk 2 offset 2
LB 11 maps to disk 3 offset 2
LB 12 maps to disk 0 offset 3
LB 13 maps to disk 1 offset 3
LB 14 maps to disk 2 offset 3
LB 15 maps to disk 3 offset 3
CHECK YOUR UNDERSTANDING
Close the answer. Explain it.
In a 4-disk RAID-0 with chunk size 1, on which disk and offset does logical block 11 land?
Show a reference answer
Disk 3, offset 2. After dividing by chunk size 1, 11 mod 4 equals 3 and the integer division by 4 yields offset 2.
Check the sources
Drafts and official chapters change. The version mark is only the example’s minimum.