Β§43.1–43.3LFS: Writing Sequentially, and How Much to Buffer

Part III OSTEP pp. 547–550 Β· ~5 min read

  • log-structured file system
  • lfs segment

Every file system so far overwrites structures in place. The log-structured file system (LFS) , built by Rosenblum and Ousterhout, does something radical instead: it turns every write into a sequential write, never overwriting in place. Four observations drove it:

Four early-90s observations that motivated LFS.
observationwhy it favors a log-structured design
memorySystem memories keep growingbigger caches absorb most reads β†’ disk traffic becomes mostly WRITES β†’ write performance dominates
gapSequential I/O ≫ random I/Otransfer bandwidth rises fast, but seek/rotation improve slowly β€” so using the disk sequentially is a huge win
ffsFFS scatters small writescreating a one-block file = ~6 writes (inode, inode bitmap, dir data, dir inode, data, data bitmap) β†’ many short seeks, far below peak
raidFile systems aren't RAID-awarethey ignore RAID-4/5's small-write problem (4 physical I/Os per logical write)
Dotted-underlined cells have explanations β€” click one.

The Crux: How To Make All Writes Sequential Writes

How can a file system transform all writes into sequential writes? (Reads are hopeless β€” a block may be anywhere on disk β€” but for writes, the file system always gets to choose where the data goes.)

43.1–43.2 Writing Sequentially, and Effectively

The core idea: append all updates β€” data and metadata β€” to a log, at unused disk locations. But sequential order alone isn’t fast: if you write to A, wait, then write to A+1, the disk has rotated past A+1 and you eat almost a full rotation. The fix is to issue one large write. So LFS buffers updates in memory and flushes them together as a segment (a few MB):

LFS writes EVERYTHING sequentially to unused disk locations β€” data and metadata alike. It never overwrites in place. (Data brown, inodes dark brown; orange = disk pointers.)
DA0D lands at the next free address

1Write the data block D

Say we write a data block D to a file. LFS places it at the next free spot in the log β€” here disk address A0.

step 1 / 3

Because segments are large, the disk (or RAID) is used efficiently, and write performance approaches the drive’s peak. (This is just write buffering and amortization β€” the same idea as FFS’s large-file chunks, pushed to cover all writes.)

43.3 How Much To Buffer?

How big should a segment be? Enough to amortize the fixed positioning cost. Writing D MB costs the positioning time plus the transfer time:

Twrite=Tposition+DRpeakT_{write} = T_{position} + \frac{D}{R_{peak}}

so the effective write rate is the data over that total:

Reffective=DTwrite=DTposition+DRpeakR_{effective} = \frac{D}{T_{write}} = \frac{D}{T_{position} + \frac{D}{R_{peak}}}

To reach a fraction F of peak bandwidth (set R_effective = F Β· R_peak and solve for D):

D=F1βˆ’FΓ—RpeakΓ—TpositionD = \frac{F}{1 - F} \times R_{peak} \times T_{position}

With a 10 ms positioning time, 100 MB/s peak, and a 90% target (F = 0.9): D = (0.9 / 0.1) Γ— 100 MB/s Γ— 0.01 s = 9 MB. Want 95% or 99% of peak? The buffer must grow fast β€” exactly the amortization trade-off from the disk and FFS chapters, now governing LFS’s segment size.

Check yourself: LFS sequential writing

1.What is the core idea of a log-structured file system?

2.Why did the LFS designers argue that WRITE performance matters most?

3.When LFS writes a data block, what else goes into the log alongside it?

4.Why isn't writing in sequential ORDER (block A, then A+1, then A+2…) enough for good performance?

5.What is a segment in LFS?

6.Using D = F/(1βˆ’F) Γ— R_peak Γ— T_position, how much must LFS buffer for 90% of peak on a disk with 10 ms positioning and 100 MB/s peak?

6 questions