What are all the possible inconsistent states that the FS can be in after the crash?
data block is updated, but not the data bitmap and inode inode is updated, but but not the data bitmap and data block data bitmap is updated, but not the inode and data block inode and data bitmap updated, but not data block inode and data block updated, but not data bitmap data bitmap and data block updated, but not inode
inode has data block pointer pointing to an unwritten data blockinode, we will read garbage datadata bitmap and the inode: inode says that the data block #5 is used, but data bitmap say it is not.block #5 again and overwrite its data by mistake
inode is not pointing data block #5, so no risk of reading garbage datadata bitmap says data block #5 is used, but in fact it is notdata block #5 will never be used again
block #5 again.
Data bitmap and inode are inconsistent between each other: inode says that the data block #5 is used, but data bitmap say it is notblock #5 again and overwrite its data by mistake
data block #5 is used, but will never know which file uses it
inode or indirect block must be marked used in bitmap inodes must be in some directory entryinode reference count (link count) must match
When updating the disk, before making the actual writes to disk, the FS first writes a little note about what it is about to do, to the journal (or log, at well known location on disk).
Failures become recoverable:
transaction begin (TxB) block, containing a transaction id (TID) followed by blocks with the exact content to be written. transaction end (TxE) block, containing the TID.
inodes will point to garbage data.O(size_of_journal), instead of O(size_of_disk_volume) in fsck.