Skip to content
Ho Dinh Tri
Work

Systems

xv6 RISC-V: Double-Indirect Blocks & Crash Consistency

Extended MIT xv6's file system from a 268 KiB to a 64.3 MiB maximum file size, with leak-free truncation and write-ahead logging.

Key results

maximum file size
268 KiB → 64.3 MiB
≈245×, via double-indirect blocks
blocks freed on truncate
65,803
recursive, leak-free deallocation

Problem#

xv6 inodes address data through direct and single-indirect blocks only, which caps a file at 268 KiB.

Approach#

  • Added double-indirect block allocation, raising the maximum file size to 64.3 MiB.
  • Implemented recursive truncation of up to 65,803 blocks with leak-free deallocation.
  • Wrapped every metadata update in xv6's write-ahead log (log_write) so a crash mid-operation leaves the file system consistent.

How it was evaluated#

A full write/readback stress test at the new maximum size, followed by a free-block count to confirm nothing leaked.

Limitations#

This is a teaching OS running under QEMU. The stress test exercises the paths I changed; it is not a formal proof of crash consistency.

All work