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
| Approach | Core idea | Cost / limit |
|---|---|---|
| D-OS-Ch14ga-Consistency_Checking | reboot 後掃描 metadata 修補 | large FS 很慢,不一定救得回 data |
| D-OS-Ch14gb-Journaling_File_System | update 先寫 transaction log | journal space / write overhead |
| D-OS-Ch14gc-Copy_on_Write_File_System | 新版本寫到新 blocks,再 atomic switch | write amplification、free-space 複雜 |
| D-OS-Ch14gd-Backup_and_Restore | 從外部 copy 還原 | restore time、backup freshness |
Metadata consistent 不等於 user data 最新;沒有 fsync() / sync write 時,crash 後可能看到舊資料或部分寫入。