parityraid

How to calculate RAID 5 parity for even disc count?


When I come to RAID 5 explanations I very often see pictures showing 4 discs with three data blocks and one parity block. As example calculation (on same sites, sometimes) I always see only 3 discs. Most likely because it makes more sense: I can XOR two blocks and create the parity, so three discs needed. On all these pictures the parity block has the same size as the three data blocks.

How can this be? How ist the RAID 5 parity calculated when I have 4 discs, so three even sized blocks that need to build a parity?

(PS. Even doubling the size of parity (from two blocks each) wouldn't help understanding this. Because this would than be RAID 6, wouldn't it?)


Solution

  • Imagine that you have three data disks A, B, and C and an odd parity disk P.

    The following table shows three data bytes and the resulting parity byte:

      A: 0 1 0 1 0 1 0 1
      B: 0 0 1 1 0 0 1 1
      C: 0 0 0 0 1 1 1 1
      P: 0 1 1 0 1 0 0 1
    

    In case, for example, that disk B fails, we are left with A, C and P. The missing B byte can be reconstructed by calculating the odd parity of the surviving disks:

      A: 0 1 0 1 0 1 0 1
      C: 0 0 0 0 1 1 1 1
      P: 0 1 1 0 1 0 0 1
    [ B: 0 0 1 1 0 0 1 1 ]