Chapter 1
Filesystem Fundamentals
Filesystems are the primary interface for storing and accessing data, and their behavior shapes the performance and reliability of everything built on them. This chapter covers the semantics every Linux filesystem shares and one local implementation, ZFS; Network & Distributed Filesystems takes the remote case.
# Chapter Sections
Atomic rename, unlink with open file descriptors, O_TMPFILE, file locking (flock vs fcntl), and sparse files. POSIX operations that reliable software depends on.
IO Modes: Buffered vs Direct IOUnderstanding buffered IO, direct IO (O_DIRECT), synchronous IO flags (O_SYNC, fsync), and how different filesystems handle these modes.
The Linux Page CacheHow the page cache works, read-ahead mechanisms, dirty page writeback, and memory reclaim. Essential for understanding Linux filesystem performance.
Memory-Mapped FilesHow mmap() works, its relationship to the page cache, when writes actually reach disk, and mmap coherence across local and network filesystems.
ZFS: A Modern Local FilesystemEnd-to-end checksumming, copy-on-write architecture, integrated RAID, and snapshots. Understand ZFS's unique features, RAM requirements, and when to choose it over traditional filesystems.
Deep Dive: ZFS recordsizeWhat recordsize controls, compression interaction, workload matching, performance measurement, and code walkthrough.
Synchronization GuaranteesCoordinating concurrent access across processes on one host. POSIX semantics, advisory and mandatory locking, and what the kernel does and does not serialize for you.
Resiliency GuaranteesSurviving crashes, power loss, and corruption. Journaling, copy-on-write, fsync semantics, and checksumming.
Performance CharacteristicsBlock allocation, metadata overhead, caching strategies, and IO patterns on local storage.
Filesystem HacksBattle-tested techniques: squashfs on NFS, tmpfs for performance testing, loop devices, bind mounts, sparse files, and FUSE. Unconventional approaches that solve real problems.
Observability and DebuggingDevice and pool statistics with iostat, blktrace, and zpool iostat, plus eBPF/bpftrace scenarios. Telling a slow device from a stalled writeback from an application waiting on its own fsync.