HAMMER VFS - Version 4 part 1/many - UNDO FIFO layout work.
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 2 Nov 2009 00:35:41 +0000 (16:35 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 2 Nov 2009 00:35:41 +0000 (16:35 -0800)
commit02428fb6131e2f23a94e640dca6b54c0428be2e1
tree2e699be578a58225fca787d1b639c370a28832b4
parent8f51ac0b9a62fc74dd8845876627f0d82b738295
HAMMER VFS - Version 4 part 1/many - UNDO FIFO layout work.

These changes only apply to HAMMER version 4+ filesystems.  HAMMER
versions less then 4 only implement some of these changes and do not
use the new features during crash recovery.

* Add a sequence number of the UNDO FIFO media record format.  The field
  already existed for just this purpose so no media structures changed
  size.

* Change the alignment boundary for HAMMER UNDO records from 16K to 512
  bytes.  This coupled with the sequence number virtually guarantees that
  the recovery code can detect uninterrupted sequences of UNDO records
  without having to relay on the FIFO last_offset field in the volume
  header.

  This isn't as bad as it sounds.  It just means that large UNDO blocks
  are broken up into smaller on-media structures in order to ensure a
  record header occurs on every 512 byte boundary.

* Add HAMMER_HEAD_TYPE_DUMMY and HAMMER_HEAD_TYPE_REDO (Redo is not yet
  used).  The DUMMY type is a dummy record used solely to identify a
  sequence number.  PAD records cannot have sequence numbers so we need
  a DUMMY record for it.

  Remove unused UNDO FIFO record types.

* Adjust the version upgrade code to completely reinitialize the UNDO FIFO
  space when moving from version < 4 to version >= 4.  This puts all blocks
  in the UNDO FIFO in a deterministic state with deterministic sequence
  numbers on 512 byte boundaries.

* Refactor the flush code.  In versions less then 4 the flush code had to
  flush dirty UNDO buffers, synchronize disk, then flush the volume header
  and synchronize disk again, then flush the meta data.  For HAMMER
  versions >= 4 the flush code removes the second disk synchronization
  operation.

* Refactor the crash recovery code.  For versions < 4 the crash recovery
  code relied on the UNDO FIFO first_offset and next_offset indexes in
  the volume header to calculate the UNDO space that needed to be run.
  For versions >= 4 the crash recovery code uses first_offset for the
  beginning of the UNDO space and proactively scans the UNDO FIFO to
  find the end of the space.  This takes longer but allows HAMMER to
  remove one of the two disk sync operations in the flush code.

* Split the crash recovery code into stage 1 and stage 2.  Stage 2 will
  be used to run REDO operations (REDO is not yet implemented).
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_flusher.c
sys/vfs/hammer/hammer_io.c
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_mount.h
sys/vfs/hammer/hammer_recover.c
sys/vfs/hammer/hammer_undo.c
sys/vfs/hammer/hammer_vfsops.c