Operating Systems CMPSCI 377 Lecture 23 Advanced File

  • Slides: 25
Download presentation
Operating Systems CMPSCI 377 Lecture 23: Advanced File Systems Emery Berger University of Massachusetts

Operating Systems CMPSCI 377 Lecture 23: Advanced File Systems Emery Berger University of Massachusetts Amherst UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science

Advanced File Systems n n n Motivation & Brief review Journaling Log-structured file system

Advanced File Systems n n n Motivation & Brief review Journaling Log-structured file system UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 2

New Challenges n Servers have special needs! n n n Large hard-disk partitions Quick

New Challenges n Servers have special needs! n n n Large hard-disk partitions Quick crash recovery High-performance I/O Storing thousands of files, TB of data None supported well by ext 2 UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 3

Review: Blocks & Fragmentation n n Logical block – smallest unit of storage that

Review: Blocks & Fragmentation n n Logical block – smallest unit of storage that can be allocated by file system Internal fragmentation – occurs when file does not fill block completely n n Example: file = 10 K, block = 8 K: wastes 6 K External fragmentation – occurs when logical blocks that make up file are scattered over the disk n Causes poor performance UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 4

Review: Organization n Extent – contiguous blocks: n Triple: (file offset, starting block number,

Review: Organization n Extent – contiguous blocks: n Triple: (file offset, starting block number, length) n n file offset – offset of extent's first block from file starting block number – first block in extent length –number of blocks in extent Meta data – file system's internal data structures n Time stamps, ownership, size & locations on UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 5

Extents n n Triple: (offset, start, length) Contiguou s blocks UNIVERSITY OF MASSACHUSETTS, AMHERST

Extents n n Triple: (offset, start, length) Contiguou s blocks UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 6

Review: Inodes n inode – stores information about file n e. g. , permissions,

Review: Inodes n inode – stores information about file n e. g. , permissions, types, # of links to file n pointers to file data blocks (direct pointers) n pointers to direct pointers (indirect pointers) n each has unique inode number n directory = special file: contains pointers to other files U M , A Department of Computer Science NIVERSITY OF ASSACHUSETTS MHERST • 7

UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 8

UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 8

Metadata Updates n Lots of meta data being updated n n Scattered on disk

Metadata Updates n Lots of meta data being updated n n Scattered on disk = slow, and non-atomic Example: Creating a new file n n Modifies inodes, free lists, directory entries What happens if interrupted? n n e. g. , power outage, crash Interrupted meta-data write ) file system in inconsistent state UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 9

Repairing File System Inconsistency n UNIX solution: fsck = “file-system check” n n n

Repairing File System Inconsistency n UNIX solution: fsck = “file-system check” n n n Analogous utilities for Windows, etc. Detect and repair structural integrity problems Scan file system’s entire meta data n n Looks for inconsistencies & fixes them Problems? n n S…l…o…w… Might not succeed UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 10

Journaling File Systems n Solve problem by maintaining journal n n n Log all

Journaling File Systems n Solve problem by maintaining journal n n n Log all transactions to disk Updates to the disk committed atomically Example: Creating a new file n n Log modifications to inodes Log changes to free lists, directory entries Now begin update When finished, write “committed” into journal UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 11

Recovery in JFS n Power outage: n Some updates fully committed to file system

Recovery in JFS n Power outage: n Some updates fully committed to file system n n Not yet fully committed n n No problem File system reads journal, replays transaction Advantages over fsck: n n n Much quicker than scan of disk Guarantees file system always consistent But: does not guarantee zero data loss UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 12

Advanced File Systems n n n Brief review Journaling Log-structured file system UNIVERSITY OF

Advanced File Systems n n n Brief review Journaling Log-structured file system UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 13

LFS: Beyond JFS n n Insight: While logging updates, why not log the data

LFS: Beyond JFS n n Insight: While logging updates, why not log the data too? “Log-structured file system” n n Preserves data integrity Provides improved performance, too! UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 14

Sprite LFS [Rosenblum & Ousterhout] n n n Outperforms then-current Unix file systems by

Sprite LFS [Rosenblum & Ousterhout] n n n Outperforms then-current Unix file systems by an order of magnitude for small-file writes Matches or exceeds Unix performance for reads and large writes Even with overhead n n Can use 70% of disk bandwidth for writing Unix file systems typically can use only 510%M , A Department of Computer Science UNIVERSITY OF ASSACHUSETTS MHERST • 15

Technology Trends n Disk technology improving rapidly n n Increasing RAM ) cache more

Technology Trends n Disk technology improving rapidly n n Increasing RAM ) cache more effective n n But: capacity rather than performance Disk traffic dominated by writes Logs: write new information sequentially n Increase write performance, eliminating seeks UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 16

Existing File Systems n Exercise worst-case given trends! n Information spread around disk n

Existing File Systems n Exercise worst-case given trends! n Information spread around disk n n Many small accesses Synchronous writes n Application performance can be bottlenecked by disk performance UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 17

Log-Structured File Systems n Approach: improve write performance by combining into single sequential writes

Log-Structured File Systems n Approach: improve write performance by combining into single sequential writes n n n Converts small random writes into large sequential transfers Use file cache as write buffer But where does meta data go? UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 18

Structure of LFS (1/3) n Some index structures used to retrieve information n n

Structure of LFS (1/3) n Some index structures used to retrieve information n n Inodes not fixed: inode map used to maintain location of each inode Fixed checkpoint region on each disk: identifies locations of inode map blocks UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 19

Structure of LFS (2/3) n Disk layout (compared with Unix FFS) dir 1 dir

Structure of LFS (2/3) n Disk layout (compared with Unix FFS) dir 1 dir 2 Log file 1 Disk Sprite LFS file 2 file 1 file 2 Disk dir 1 Inode Unix FFS dir 2 Directory Data Inode map UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 20

Structure of LFS (3/3) n Segments n n n Important to maintain large free

Structure of LFS (3/3) n Segments n n n Important to maintain large free extents for writing new data Divide disk into large fixed-size extents called segments Segments always written sequentially n Before segment is rewritten, all live data must be copied out (“cleaned”) UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 21

Crash Recovery (1/2) n Checkpoints n n Position in log at which all of

Crash Recovery (1/2) n Checkpoints n n Position in log at which all of file system structures are consistent and complete Checkpoint region written on special fixed position: n n Periodic intervals When the file system unmounted or shut down UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 22

Crash Recovery (2/2) n Roll-forward n n After crashes, LFS scans through log segments

Crash Recovery (2/2) n Roll-forward n n After crashes, LFS scans through log segments that were written after last checkpoint Use information in segment summary blocks n When summary block indicates presence of new inode, LFS updates inode map UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 23

LFS Wrap-Up n n Extends journaling to data Sequential writes in segments n n

LFS Wrap-Up n n Extends journaling to data Sequential writes in segments n n n Fast! Periodic clean-up Periodic checkpoints UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 24

Summary n n n Traditional filesystems – integrity problems Solved by journaling Log-structured further

Summary n n n Traditional filesystems – integrity problems Solved by journaling Log-structured further improves speed by optimizing write performance UNIVERSITY OF MASSACHUSETTS, AMHERST • Department of Computer Science 25