Fall 2017 :: CSE 306
Basic FS Implementation
Nima Honarmand
Basic FS Implementation Nima Honarmand Fall 2017 :: CSE 306 A - - PowerPoint PPT Presentation
Fall 2017 :: CSE 306 Basic FS Implementation Nima Honarmand Fall 2017 :: CSE 306 A Typical Storage Stack (Linux) User Kernel VFS (Virtual File System) ext4 btrfs fat32 nfs Page Cache Block Device Layer Network IO Scheduler Disk
Fall 2017 :: CSE 306
Nima Honarmand
Fall 2017 :: CSE 306
VFS (Virtual File System) ext4 Page Cache Block Device Layer IO Scheduler Disk Driver Disk
Kernel User
btrfs fat32 nfs Network
: Already covered : To be covered
Fall 2017 :: CSE 306
rest of storage stack
system data and metadata
inodes, dentries and superblocks
and file data
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
I
+ Very good + Easy to find block
+ Very low
Fall 2017 :: CSE 306
+ No external fragmentation +/- Depends on block placement
+ Easy and fast
I
Fall 2017 :: CSE 306
Windows, DOS and OS2
→ Can traverse linked list in memory → Improves random access performance
Fall 2017 :: CSE 306
+ No external fragmentation +/- Depends on block placement + Easy to find block number +/- Easy up to max size; but max is small
IB I
Fall 2017 :: CSE 306
IB IB
I
IB IB IB
I
IB IB
Fall 2017 :: CSE 306
index blocks)
Fall 2017 :: CSE 306
I
2nd Level Indirection Block n Data Blocks n3 Data Blocks 3rd Level Indirection Block IB IB IB 1st Level Indirection Block
IB IB IB IB IB IB IB IB
n2 Data Block s IB
10 Data Blocks
Fall 2017 :: CSE 306
→ allocate indirect blocks only for large files
+/- Maximum file size limited (a few terabytes) + No external fragmentation + Simple and supports small files well + Easy to grow files +/- Sequential access performance depends on block layout +/- Random access performance good for small files; for large files have to read multiple indirect blocks first
Fall 2017 :: CSE 306
file data blocks
→ Most file systems try to keep file data in big chunks of consecutive disk blocks → Why not use this fact to reduce individual block pointers?
Fall 2017 :: CSE 306
direct/indirect pointers used by ext2/3
+ No external fragmentation + Good assuming few large extents + Quick assuming a shallow extent tree + Easy to grow + low, assuming a few extents
Fall 2017 :: CSE 306
forms basis of most FS
i-number determines which block in the table and which inode in the block
Fall 2017 :: CSE 306
7 D D D D D D D D 8 15 D D D D D D D D 16 23 D D D D D D D D 24 31 D D D D D D D D 32 39 D D D D D D D D 40 47 D D D D D D D D 48 55 D D D D D D D D 56 63 S i d I I I I I D : Data block I : Inode block d : Data bitmap i : Inode bitmap S : Superblock
Fall 2017 :: CSE 306
containing a given inode number
inode 16 inode 17 inode 18 inode 19 inode 20 inode 21 inode 22 inode 23 inode 24 inode 25 inode 26 inode 27 inode 28 inode 29 inode 30 inode 31
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
children, free entry management, etc.
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
Super Block Inode Table Data Bitmap Inode Bitmap Data Block
directories indirects
Fall 2017 :: CSE 306
data inode root foo bar root foo bitmap bitmap inode inode inode data data read read read read
Verify that bar does not already exist
Fall 2017 :: CSE 306
data inode root foo bar root foo bitmap bitmap inode inode inode data data read read read read
Why must read bar inode block? How to initialize inode?
read write read write
Fall 2017 :: CSE 306
data inode root foo bar root foo bitmap bitmap inode inode inode data data read read read read
Update directory’s inode (e.g., size) and data
read write write write read write
Fall 2017 :: CSE 306
data inode root foo bar bitmap bitmap inode inode inode root data foo data read read write write write bar data
Need to allocate a data block assuming bar was empty
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
Fall 2017 :: CSE 306
disk immediately
containing fd
this file to disk (including metadata changes)
this file
changed