Summary

Parity-Based Protection: RAID 4 and RAID 5

From: RAID and Data Integrity: Advanced Operating Systems Chapters 38 and 44

Parity-Based Protection: RAID 4 and RAID 5

RAID is used to build a storage system that is faster, larger, and more reliable by using multiple disks together, as described in Chapter 38 and 44(1) (1). For parity-based protection, the key idea is to add redundancy without making a full second copy of every block.

How XOR parity supports protection

In Chapter 38 and 44(1) (1), parity is explained with XOR. XOR produces 0 when there are an even number of 1s and 1 when there are an odd number of 1s. The RAID system maintains an invariant: across a row of data bits plus the parity bit, the total number of 1s must be even.

This makes reconstruction possible after a disk loss. If one disk in a stripe is lost, the system can read the remaining data blocks in that stripe along with the parity block, then use XOR again to recover the missing value. The source gives the example that if column C2 is lost, the missing values can be reconstructed by reading all other values in that row, including parity.

  • Parity is computed from the data blocks in a stripe using XOR.
  • If one block is missing, XOR of the surviving blocks and the parity block reveals the lost block.
  • This works as long as only one disk in the protected group is lost.

Why parity saves space

Compared with mirroring, parity saves space because it does not store a full duplicate of each block. Instead, it stores parity information for a stripe. Thus, parity-based RAID provides redundancy with less capacity overhead than keeping two complete copies of the data, a theme emphasized in the RAID discussion in Chapter 38 and 44(1) (1).

RAID 4: dedicated parity disk

RAID 4 uses striping for data blocks and keeps parity on a single dedicated parity disk. This organization achieves space savings because only parity, not a full mirror, is added.

However, the parity organization affects performance. Because every small write must update the parity information, the dedicated parity disk becomes a bottleneck. Many writes must involve that same disk, limiting write throughput.

  • Space: saves space compared with mirroring.
  • Parity placement: all parity blocks are stored on one disk.
  • Write impact: small writes perform poorly because the parity disk is a hotspot.

RAID 5: rotating parity

RAID 5 keeps the same basic parity idea but changes where parity is stored. Instead of placing all parity on one dedicated disk, RAID 5 rotates parity across all disks. According to Chapter 38 and 44(1) (1), this is better because all disks can be utilized.

This improves performance for random writes compared with RAID 4. The source notes that writes to different blocks can involve different disks for both data and parity, allowing more parallelism across requests. In other words, parity work is distributed instead of concentrated on one disk.

  • Space: still saves space through parity rather than full duplication.
  • Parity placement: parity blocks are distributed across disks.
  • Write impact: better random-write performance than RAID 4 because parity updates are spread out.
  • Parallelism: higher, since different writes can proceed on different disks.

RAID 4 vs. RAID 5

Both RAID 4 and RAID 5 use XOR parity to protect against a single disk failure and both provide redundancy more space-efficiently than mirroring. Their main difference is parity placement, and that difference strongly affects write behavior.

  • Common feature: both use parity with XOR to reconstruct lost data after one disk failure.
  • Space savings: both save space relative to RAID 1 because they store parity instead of a full copy.
  • RAID 4: parity is on one dedicated disk, which can become a write bottleneck.
  • RAID 5: parity is rotated across disks, reducing the bottleneck and improving parallelism.

Key takeaway

Using XOR parity, a RAID can reconstruct missing data from a lost disk by combining the surviving blocks in a stripe with the parity block. As presented in Chapter 38 and 44(1) (1), RAID 4 and RAID 5 both gain space efficiency from parity, but RAID 5 improves on RAID 4 by distributing parity across disks, which reduces the dedicated-parity bottleneck and allows better write parallelism.