The old UNIX file system was beautifully simple β one superblock, an inode region, and the rest data:
It delivered the right abstractions (files and a directory hierarchy), but it had a fatal flaw: it was slow β eventually delivering only ~2% of disk bandwidth.
41.1 The Problem: Poor Performance
The root cause: the old FS treated the disk like random-access memory, ignoring that a disk has real, expensive positioning costs. A fileβs data blocks often landed far from its inode, so the common βread the inode, then read the dataβ pattern paid an expensive seek. And because the free list wasnβt managed for contiguity, the disk grew fragmented β logically sequential files ended up scattered:
1Four files, nicely contiguous
Start with four 2-block files packed together. Reading any file is a clean sequential access β no seeking.
(This scattering is exactly what disk defragmentation tools reorganize away.) A second problem: the 512-byte block was too small for efficient transfer β each tiny block risked its own positioning overhead.
The Crux: How To Organize On-Disk Data For Performance
How can we organize file-system data structures β and what allocation policies do we layer on top β to make the file system disk aware and fast?41.2 FFS: Disk Awareness Is The Solution
A Berkeley group built the Fast File System
(FFS) fast file system FFS: the Berkeley redesign of the old UNIX file system that keeps the SAME interface (open/read/write/β¦) but makes the on-disk structures and allocation policies 'disk aware' β treating the disk like a disk (with real positioning costs) instead of like random-access memory. It set the template that modern file systems still follow.
defined in ch. 41 β open in glossary
: same interface (open, read, write, close β so every
existing program still worked), but internals redesigned to be disk aware.
This move β keep the API, change the internals for performance β is the pattern
essentially every file system since has followed.
41.3 Organizing Structure: The Cylinder Group
FFS divides the disk into cylinder groups. A cylinder cylinder A set of tracks that sit at the same distance from the center of a drive, across all its surfaces/platters β so named for the cylindrical shape they trace. FFS grouped consecutive cylinders to reason about disk locality. defined in ch. 41 β open in glossary is the set of tracks at the same distance from the driveβs center across all its surfaces; FFS groups N consecutive cylinders into a cylinder group cylinder group FFS's unit of locality: N consecutive cylinders grouped together, each group holding its own superblock copy, inode/data bitmaps, inode table, and data blocks. Placing related files in one group keeps their accesses close, avoiding long seeks. defined in ch. 41 β open in glossary . Modern drives hide their geometry, so todayβs file systems (ext2/3/4) use block groups ( block groups block group The modern equivalent of a cylinder group (ext2/3/4): a consecutive portion of the disk's logical block address space. Since disks now hide their geometry, file systems group by block-address range instead of true cylinders, but the locality purpose is identical. defined in ch. 41 β open in glossary ) β consecutive ranges of the logical block address space β instead:
Groups are the whole trick: put two related files in the same group and accessing one after the other wonβt cause a long seek. To make that work, each group is a self-contained mini file system β a superblock copy, its own inode and data bitmaps, an inode table, and data blocks:
The superblock is replicated in every group for reliability: if one copy is corrupted, the FS can still be mounted from another.
Aside: How Much Work Is Creating One File?
Creating/foo/bar.txt (one block) touches a lot: write the inode
bitmap and the new inode; write the data bitmap and the data block; and update
the parent directory foo β its data block (the new entry) and its
inode (new length + times). Thatβs already ~6+ writes to the group, just to
make one small file.Check yourself: the old FS problem and cylinder groups
1.Why did the old UNIX file system perform so poorly (as low as ~2% of disk bandwidth)?
2.In the fragmentation example, why does new 4-block file E end up split across the disk?
3.What was FFS's key move relative to the old file system?
4.What is a cylinder, and what is a cylinder group?
5.Why do modern file systems use block groups instead of true cylinder groups?
6.Why does FFS keep a copy of the superblock in every group?