170 likes | 189 Views
Chapter 42 Crash Consistency: FSCK and Journaling. Jeongsoo Shin ( j eongsoo.shin@snu.ac.kr ) School of Computer Science and Engineering Seoul National University. Outline. File Append Example Crash Scenarios FSCK Journaling Data Journaling Metadata Journaling Summary.
E N D
Chapter 42Crash Consistency: FSCK and Journaling Jeongsoo Shin (jeongsoo.shin@snu.ac.kr) School of Computer Science and Engineering Seoul National University
Outline • File Append Example • Crash Scenarios • FSCK • Journaling • Data Journaling • Metadata Journaling • Summary
File Append Example Inode Bitmap Data Bitmap Inodes Data Blocks Db v1 Da v2
Crash Scenarios (1/2) Inode Bitmap Data Bitmap Inodes Data Blocks Db v1 Da Inode Bitmap Data Bitmap Inodes Data Blocks v2 v1 Da Inode Bitmap Data Bitmap Inodes Data Blocks v1 Da
Crash Scenarios (2/2) Inode Bitmap Data Bitmap Inodes Data Blocks v1 Da v2 Db Inode Bitmap Data Bitmap Inodes Data Blocks Db Db v1 Da Inode Bitmap Data Bitmap Inodes Data Blocks v1 Da v2
Solution #1: File System Checker • Scans the entire file system multiple times, identifying and correcting inconsistencies • fsck • Validates the superblock • Rebuild the bitmaps by scanning all inodes • Deletes the duplicated pointers • Removes the bad pointers • Verifies the integrity of all directories
Solution #2: Journaling (or Write-Ahead Logging) Superblock Journal Group 0 Group 1 … Group N Records each update to the file system as a transaction All transactions are written to a log If the file system crashes, all remaining transactions in the log must be performed ext3 and NTFS use journaling
Data Journaling Example I v2 Db TxE ID=1 TxB ID=1 B v2 Journal • Begin a new transaction with a unique ID=k • Write the updated meta-data block(s) • Write the file data block(s) • Write an end-of-transaction with ID=k • Three writes: inode v2, data bitmap v2, data D2
Checkpointing I v2 Db TxE ID=1 TxB ID=1 B v2 Journal Checkpoint Inode Bitmap Data Bitmap Inodes Data Blocks Db v1 Da v2 • Writes the data from the log out to disk
Data Journaling Timeline File System Journal
Crash Recovery (1/2) I v2 Db TxE ID=1 TxB ID=1 B v2 Journal No Change Inode Bitmap Data Bitmap Inodes Data Blocks Db v1 Da • Scenario : system crashes during logging
Crash Recovery (2/2) I v2 Db TxE ID=1 TxB ID=1 B v2 Journal Checkpoint Inode Bitmap Data Bitmap Inodes Data Blocks v2 Db v1 Da Reboot • Scenario : system crashes during checkpointing
Metadata Journaling I v2 TxE TxE ID=1 TxB ID=1 B v2 Journal Inode Bitmap Data Bitmap Inodes Data Blocks v2 Db v1 Da The most expensive part of data journaling is writing the data twice ext3 metadata journaling
Metadata Journaling Timeline Journal File System
Summary • Modern systems use journaling • ext3 / ext4 on Linux • NTFS on Windows • Journaling reduces recovery time • Metadata Journaling reduces the amount of traffic to the journal