12.6

A power failure that occurs while a disk block is being written could result in a block being only partially written. Assume that partially written blocks can be detected. An atomic block write is one where either the disk block is fully written or nothing is written (i.e., there are no partial writes). Suggest schemes for getting the effect of atomic block writes with the following RAID schemes. Your schemes should involve work on recovery from failure.

  1. RAID level 1 (mirroring)

  2. RAID level 5 (block interleaved, distributed parity)


  1. RAID level 1 (mirroring)

To ensure atomicity, a block write operation is carried out as follows:

  1. Write the information onto the first physical block.
  2. When the first write completes successfully, write the same information onto the second physical block.
  3. The output is declared completed only after the second write completes successfully.

During recovery, each pair of physical blocks is examined. If both are identical and there is no detectable partial-write, then no further actions are necessary. If one block has been partially written, then we replace its contents with the contents of the other block. If there has been no partial-write, but they differ in content, then we replace the contents of the first block with the second, or vice versa. This recovery procedure ensures that a write to stable storage either succeeeds completely (that is, updates both copies) or results in no change.

The requirement of comparing every corresponding pair of blocks during recovery is expensive to meet. We can reduce the cost greatly by keeping track of block writes that are in progress, using a small amount of nonvolatile RAM. On recovery, only blocks for which writes were in progress need to be compared.

  1. RAID level 5 (block interleaved, distributed parity)

The idea is similar here. For any block write, the information block is written first, followed by the corresponding parity block. At the time of recovery, each set consisting of the \(n^{th}\) block of each of the disks is considered. If none of the blocks in the set have been partially written, and the parity block contents are consistent with the contents of the information blocks, the no further action need to be taken. If any block has been partially written, its contents are reconstructed using the other blocks. If no block has been partially written, but the parity block contents do not agree with the information block contents, the parity block’s contents are reconstructed.