Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 14 · From Scratch · Systems from scratch · about 19 min to read

Play it as a journeyTutor comes with a plan

A file system of your own

WAL & Recovery
WAL & Recovery · Open board

: write the note first, then the change, then replay the note after a crash. This lesson applies that same idea to a file system.

Before you start. A file system keeps each file as an inode (a numbered record of size and block locations) and a name in a directory that points at that number (The filing cabinet: how a file system is built). A save first lands in memory, so “saved” does not yet mean “safe on disk” (The drawer that says it saved). A write-ahead log is a file where you record a change before you make it, so a crash leaves the change done or not done (Write-Ahead Log). The same idea guarded a key-value store in LSM 01-02: The Memtable and the Log. Here it guards a whole file system.

Lesson 108 of 117 in From Scratch

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • November 2001: a crash should not mean waiting for fsck
  • The inode: where a file’s facts live
  • The directory: names that point at inode numbers
  • The crash: four writes, and the power goes after two
  • The journal: write the plan on rough paper first
  • Recovery: replay the journal when the disk starts
  • The model, and what it does not prove
  • The program
  • Run it
  • Break it: commit record first
  • Edge cases and trade-offs

Terms it explains: inode, directory, bitmaps, journal, commit record, Replay.

Lab

You checkpoint three times as often for a faster restart. Why does the log get bigger?

Drag How long the log may run between checkpoints to its shortest, press Add next write repeatedly, and watch If the power died now.

Open The write-ahead log

Related papers

Review From Scratch