Download presentation
Presentation is loading. Please wait.
1
SE350: Operating Systems Lecture 12: File Systems
2
Main Points File layout Directory layout
3
Design Challenges Index structure Index granularity Free space maps
How do we locate the blocks of a file? Index granularity What block size do we use? Free space maps How do we find unused blocks on disk? Locality heuristics How do we group data to optimize performance?
4
Named Data in a File System
5
Directories Are Files Directory is a file that contains a collection of file name → file number mappings Can we use open/close/read/write API to access directories? No; kernel should prevent apps from corrupting the file name → file number mappings
6
Recursive Filename Lookup
Directories can be arranged hierarchically A directory can contain the file name → file number mapping for another directory
7
Directory Layout Original Linux ext2 File System
Linked list implementation of a directory Linear search is required to find filename Reasonable implementation for small directories What if there are a few thousand entries?
8
Directory Layout Modern Linux XFS File System
9
Directory Layout Modern Linux XFS File System (cont.)
10
Hard and Soft Links
11
Microsoft File Allocation Table (FAT)
FAT is an array of 32-bit entries Each file corresponds to linked list of FAT entries Simple and easy to implement Still widely used Each FAT entry corresponds to a storage block
12
FAT Pros: Cons: Easy to find free block Easy to append to a file
Easy to delete a file Cons: Random access is very slow Fragmentation and poor locality File blocks for a given file may be scattered Files in the same directory may be scattered Problem becomes worse as disk fills
13
Berkeley UNIX FFS (Fast File System)
Metadata File owner, access permissions, access times, … Set of 12 data pointers With 4KB blocks => max size of 48KB Indirect block pointer Pointer to disk block of data pointers 4KB block size and 4-byte block pointer => 1K direct block pointers => 4MB data (+48kB) Doubly indirect block pointer Doubly indirect block => 1K indirect blocks 4GB (+ 4MB + 48KB) Triply indirect block pointer Triply indirect block => 1K doubly indirect blocks 4TB (+ 4GB + 4MB + 48KB)
14
FFS Inode and Inode Array
15
FFS Asymmetric Tree Small files: shallow tree Large files: deep tree
Efficient storage for small files Large files: deep tree Efficient lookup for random access in large files Sparse files: only fill pointers if needed
16
FFS Locality Block group placement inode table spread throughout disk
Block group is a set of nearby tracks Files in same directory located in same group Subdirectories located in different block groups inode table spread throughout disk inodes, bitmap near file blocks First fit allocation Small files fragmented, large files contiguous
17
FFS Block Groups
18
FFS First Fit Block Allocation
19
FFS First Fit Block Allocation
20
FFS First Fit Block Allocation
21
FFS Pros Cons Efficient storage for both small and large files
Locality for both small and large files Locality for metadata and data Cons Inefficient for tiny files (a 1 byte file requires both an inode and a data block) Inefficient encoding when file is mostly contiguous on disk (no equivalent to superpages) Need to reserve 10-20% of free space to prevent fragmentation
22
Acknowledgment This lecture is a slightly modified version of the one prepared by Tom Anderson
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.