DISK 0DISK 1DISK 2DISK 31pwrite(fd, buf, BS, 4 * BS);2pread(fd, buf, BS, 1 * BS);RAID
Back: four disks, two rows of blocks each (khaki data, gold parity)Front: your program and the RAID layerTiles: blocks moving and being XORed; envelopes: write requestsFour disks at the back, each with two rows of blocks: khaki data blocks and gold parity blocks, each showing 4 bits. The program and the RAID layer in front. Blocks are dealt across disks 0 to 2; disk 3 keeps the XOR of each row. A small write reads and rewrites a block and its parity. When disk 1 dies, its blocks are rebuilt from the rest of each row. RAID 5 moves row 1's parity to disk 2. Real blocks hold 4096 bytes and parity is worked out on every one of their 32768 bits. The figure shows 4 bits of each block, as OSTEP does in its own example; the C program writes those bits as the first byte, 9 (binary 1001).

Striping

  1. One disk has limits: one disk's speed, one disk's size, and when it breaks its data is gone. RAID (a redundant array of inexpensive disks) joins several disks so programs see one. Here the RAID layer joins four.

Parity

When a disk dies

Rotating parity

What happens

;; step 1/12 · one-disk
RAID      redundant array of inexpensive disks
          (Patterson, Gibson and Katz, Berkeley, 1988)
outside   looks like one disk: a row of numbered blocks
inside    several disks + a layer that maps each block

Linux     the md driver (Linux software RAID) joins
          disks into one device, /dev/md0
here      4 disks, 2 rows each, blocks of 4096 bytes

Real blocks hold 4096 bytes and parity is worked out on every one of their 32768 bits. The figure shows 4 bits of each block, as OSTEP does in its own example; the C program writes those bits as the first byte, 9 (binary 1001). The RAID layer can be software in the kernel (the Linux md driver behind /dev/md0) or a hardware RAID card with its own processor and memory. Either way the program just reads and writes numbered blocks.