RAID 5 utilizes a
parity function to provide redundancy and data
reconstruction. Typically, an "exclusive OR" ("XOR") binary function is used to
compute parity for a given "row" of the array. Anyway, the parity is computed as
a function of several data blocks P=P(D
_{1}, D
_{2}, ... D
_{N-1}) for N disk layout. In
case of a single drive failure, the inverse function is used to compute data
from the remaining data blocks and parity block.
Let's say for example that the Disk 3 fails in configuration illustrated
below.
- Data blocks D_{1} and D_{2} will be read directly from their corresponding
disks (which are operational).
- Parity block P_{1,2} is really not needed (does not contain user data) so
it will be just discarded.
- Data block D_{3} will be read from its corresponding disk (Disk 2).
- Data block D_{4}, which is missing because its drive is offline will be
reconstructed using D_{3} and P_{3,4} like this: D_{4}=P_{inverse}(D_{3},P_{3,4}).
During normal operation, read speed gain is (N-1) times, because requests
will be evenly routed to N-1 disks (parity read is not needed during normal
operations). Write procedure is more complicated, and actually imposes some
speed penalty. Let's say we need to write block D_{1}. We also need to update its
corresponding parity block P_{1,2}. There are two ways to accomplish this:
- Read D_{2}; compute P_{1,2}=P(D_{1},D_{2}); write D_{1} and P_{1,2};
- Read D_{1;old} and P_{1,2;old}; compute P_{1,2}
from these data; write D_{1} and P_{1,2}.
Both of these ways require at least one read operation as the overhead. This
read operation can not be parallelized in any way with its corresponding write
operation, so write speed should decrease (by the factor of two, assuming equal
read and write speed). Most current implementations mitigate this effect by
maintaining the entire "row" (D_{1}, D_{2} and D_{3}) in
the cache.
Minimum of three disks is required to implement RAID5. Storage space
overhead equals the capacity of a single
member disk and does not depend on the number of disks.
Unlike a RAID0, RAID5 can be recovered with one disk missing; please refer to the RAID5 recovery page for more details.