CS FundamentalsVery hardGATE CS

Which sequence of metadata updates for appending a block to a file is SAFEST to write to disk without a journal, so that a crash leaves at worst a leaked block rather than corruption?

  1. A. Update the inode first, then the bitmap, then the data
  2. B. Update the bitmap, the inode and the data in any order
  3. C. Write the data block, then mark it used in the bitmap, then update the inode to point to it
  4. D. Update the inode first, then the data, then the bitmap

Correct answer: C. Write the data block, then mark it used in the bitmap, then update the inode to point to it

If the inode points to a block before the data or bitmap are written, a crash leaves the file pointing at garbage or at a block that could be allocated twice. Writing data and bitmap first means a crash only leaks a block, which fsck can reclaim.

More Operating Systems questions

Exams that ask this topic