hammer2 - Add emergency mode to allow recovery of ENOSPC edge cases
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 29 Sep 2019 18:06:08 +0000 (11:06 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 29 Sep 2019 18:18:16 +0000 (11:18 -0700)
commitacbbd0efe8096cf0ef822670582da7d2cf5c137b
tree7fd86065f6b5b2a3083ed8ac747cd3b3e8df2c0a
parenta860700207674c889204cb3d9052b74feb9fd62d
hammer2 - Add emergency mode to allow recovery of ENOSPC edge cases

* Because HAMMER2 is a copy-on-write filesystem, even 'rm' operations
  require block allocations.  H2 gives 'rm' operations extra reserve
  but it is still relatively easy to get into a situation where the
  normal copy-on-write allocation fails and the filesystem gets stuck
  in a ENOSPC situation that cannot be recovered from under normal
  operation.

  We add two directives, 'emergency-mode-enable' and
  'emergency-mode-disable' as a fail-safe to allow recovery of
  filesystems that have gotten into this situation.

* When this mode is enabled HAMMER2 will still attempt to use a
  copy-on-write operation for any blocks that might have been
  snapshotted.  However, any blocks which have not been snapshotted
  (or if the copy-on-write fails) will now be modified in-place,
  allowing chflags and rm operations to be run even when the filesystem
  is over-full.

  Such operation is fragile because the tree cannot be updated safely,
  so this mode can permanently destroy the filesystem if power is lost
  or a panic occurs during the file removal or chflags/chmod operations.
  Great care must be taken when using this mode.

  In addition, use of this mode will likely corrupt any snapshots sharing
  the same meta-data.  If you use this mode and have snapshots it is
  recommended that the snapshots be deleted.

* If you have to use this mode, be sure to disable it after the
  filesystem is operational again.

* The bulkfree scan now reports which PFS(es) a CRC failure occurs on.
  Bulkfree will attempt to alert the user as to which snapshots are
  corrupt, but it isn't perfect.
13 files changed:
sbin/hammer2/Makefile
sbin/hammer2/cmd_emergency.c [copied from sys/vfs/hammer2/hammer2_mount.h with 67% similarity]
sbin/hammer2/hammer2.8
sbin/hammer2/hammer2.h
sbin/hammer2/main.c
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_bulkfree.c
sys/vfs/hammer2/hammer2_chain.c
sys/vfs/hammer2/hammer2_disk.h
sys/vfs/hammer2/hammer2_ioctl.c
sys/vfs/hammer2/hammer2_ioctl.h
sys/vfs/hammer2/hammer2_mount.h
sys/vfs/hammer2/hammer2_vnops.c