File-System Recovery

File-system recovery 處理 crash / power loss 後,如何讓 metadata 回到 consistent state。根本問題:一個 file operation 通常包含多個 non-atomic metadata updates,且很多 updates 先停在 cache。


Example Failure Window

Create file 可能改:

  • allocate FCB / inode。
  • update directory entry。
  • allocate data blocks。
  • update free-block / free-FCB counts。
  • update timestamps / file size。

Crash 若發生在中間,storage 上可能只完成一部分。


Approaches

ApproachCore ideaCost / limit
D-OS-Ch14ga-Consistency_Checkingreboot 後掃描 metadata 修補large FS 很慢,不一定救得回 data
D-OS-Ch14gb-Journaling_File_Systemupdate 先寫 transaction logjournal space / write overhead
D-OS-Ch14gc-Copy_on_Write_File_System新版本寫到新 blocks,再 atomic switchwrite amplification、free-space 複雜
D-OS-Ch14gd-Backup_and_Restore從外部 copy 還原restore time、backup freshness

Metadata consistent 不等於 user data 最新;沒有 fsync() / sync write 時,crash 後可能看到舊資料或部分寫入。