CONTENTS xix
39.6 Writing Immediately with fsync() .............463
39.7 Renaming Files . . . . . . . . . . . . . . . . . . . . . . . . . 464
39.8 Getting Information About Files . . . . . . . . . . . . . . . 465
39.9 Removing Files . . . . . . . . . . . . . . . . . . . . . . . . . 466
39.10 Making Directories . . . . . . . . . . . . . . . . . . . . . . . 466
39.11 Reading Directories . . . . . . . . . . . . . . . . . . . . . . 467
39.12 Deleting Directories . . . . . . . . . . . . . . . . . . . . . . 468
39.13 Hard Links . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
39.14 Symbolic Links . . . . . . . . . . . . . . . . . . . . . . . . . 470
39.15 Making and Mounting a File System . . . . . . . . . . . . . 472
39.16 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
40 File System Implementation 477
40.1 The Way To Think . . . . . . . . . . . . . . . . . . . . . . . 477
40.2 Overall Organization . . . . . . . . . . . . . . . . . . . . . . 478
40.3 File Organization: The Inode . . . . . . . . . . . . . . . . . 480
40.4 Directory Organization . . . . . . . . . . . . . . . . . . . . 485
40.5 Free Space Management . . . . . . . . . . . . . . . . . . . . 485
40.6 Access Paths: Reading and Writing . . . . . . . . . . . . . . 486
40.7 Caching and Buffering . . . . . . . . . . . . . . . . . . . . . 490
40.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
41 Locality and The Fast File System 495
41.1 The Problem: Poor Performance . . . . . . . . . . . . . . . 495
41.2 FFS: Disk Awareness Is The Solution . . . . . . . . . . . . . 497
41.3 Organizing Structure: The Cylinder Group . . . . . . . . . 497
41.4 Policies: How To Allocate Files and Directories . . . . . . . 498
41.5 Measuring File Locality . . . . . . . . . . . . . . . . . . . . 499
41.6 The Large-File Exception . . . . . . . . . . . . . . . . . . . 500
41.7 A Few Other Things About FFS . . . . . . . . . . . . . . . . 502
41.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
42 Crash Consistency: FSCK and Journaling 507
42.1 A Detailed Example . . . . . . . . . . . . . . . . . . . . . . 508
42.2 Solution #1: The File System Checker . . . . . . . . . . . . 511
42.3 Solution #2: Journaling (or Write-Ahead Logging) . . . . . 513
42.4 Solution #3: Other Approaches . . . . . . . . . . . . . . . . 523
42.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
43 Log-structured File Systems 527
43.1 Writ ing To Disk Sequentially . . . . . . . . . . . . . . . . . 528
c
2014, ARPACI-DUSSEAU
THREE
EASY
PIECES