1. Crash Consistency
-
Initial file system, one file, one block: B[v1], I[v1], Da
Data block Db appended, requires 3 writes: B[v2], I[v2], Db
Crash Scenarios:
- B[v2] written, but not I[v2] and Db
- I[v2] written, but not B[v2] and Db
- Db written, but not B[v2] and I[v2]
- B[v2] and I[v2] written, but not Db
- I[v2] and Db written, but not B[v2]
- B[v2] and Db written, but not I[v2]
Which leave file system inconsistent?
How to fix?
2. fsck
-
File System Checks:
- Superblock
- Free blocks: inode and data bitmaps
- Inode state
- Inode link counts
- Duplicates
- Bad blocks
- Directory consistency
Slow.
3. Data Journaling
-
Write-ahead logging
Without journal:
With journal:
Journal:
4. Exercises
-
Using fsck.py:
$ python ./fsck.py -n 6 -i 8 -d 8 -c Initial state of file system: 01234567 inode bitmap 10001101 0 1 2 3 4 5 6 7 inodes [d a:0 r:3] [] [] [] [d a:3 r:2] [f a:-1 r:1] [] [f a:6 r:1] 01234567 data bitmap 10010010 0 1 2 3 4 5 6 7 data [(.,0) (..,0) (g,4) (t,7)] [] [] [(.,4) (..,0) (x,5)] [] [] [z] [] --> determine which files and directories are there Final state of file system: 01234567 inode bitmap 10001101 0 1 2 3 4 5 6 7 inodes [d a:0 r:3] [] [] [] [d a:4 r:2] [f a:-1 r:1] [] [f a:6 r:1] 01234567 data bitmap 10010010 0 1 2 3 4 5 6 7 data [(.,0) (..,0) (g,4) (t,7)] [] [] [(.,4) (..,0) (x,5)] [] [] [z] [] --> CORRUPTION = ?