Skip to content
hashkey.bond

Archivestorage

Copy-on-Write: Cheap Snapshots, Expensive Fragmentation

Never overwrite in place; write new blocks and flip pointers. Snapshots become free, and so do the problems.

Published
Reading time
1 min read

Copy-on-write (CoW) filesystems and databases write modified data to new blocks and update metadata atomically. The old blocks remain untouched, so a snapshot is just a preserved tree root.

The wins

  • Atomic snapshots and clones at near-zero cost.
  • Crash consistency: a pointer flip is atomic, so there is no torn state.
  • Cheap rollback and test environments from production data.

The bills

  • Fragmentation: sequential writes scatter across free blocks over time.
  • Free-space accounting: reference counts or extent maps get complex.
  • Write amplification when small random writes copy whole blocks.
  • Snapshot retention: old roots pin old blocks; deleting snapshots is the only way to reclaim.

ZFS, btrfs, APFS, and many storage engines use CoW variants; log-structured designs are the extreme case.

Takeaway: CoW is excellent for snapshot-heavy workflows and terrible for sustained random overwrite unless the allocator is tuned. Know which one you are.