hammer2 - refactor filesystem sync 2/N
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 9 Nov 2018 01:10:07 +0000 (17:10 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 5 Dec 2018 18:28:39 +0000 (10:28 -0800)
commitecfe89b8868b30c9ddfa9c86cb4b0a20365a248d
tree5db1f0d00db77d6803025f31b1dd86f4efd037ec
parent5afbe9d887367290d89391c2d29697655f9fc1da
hammer2 - refactor filesystem sync 2/N

* Flesh out the flush partitioning code, fixing a number of issues.

* Refactor hammer2_inode_lock() and add hammer2_inode_lock4() to
  interlock against flushes.  This is handled by blocking inode locks
  against SYNCQ, and reordering the inode to the front of the SYNCQ list
  in order to unblock as quickly as possible as the filesystem sync
  progresses.  The result should be relatively few frontend stalls
  during a filesystem sync.

* Disable resource caps for the moment, because synchronous
  operations to prevent resource limits from blowing out break
  the current inode_lock*() code and allow vnode deadlocks to
  occur.

* To avoid deadlocks, the filesystem sync currently must clear SYNCQ
  before locking the inode & vnode, and if it cannot lock a vnode it
  must continue on with the next inode and then restart.  Retried
  vnodes introduce a short delay to give the frontend time to work
  the blocking operation.

  This is necessary because the kernel locks vnodes before entering the
  H2 frontend, and we cannot safely unlock/relock them to work around
  this.  Nor do we necessarily even have full knowledge on which vnodes
  the current thread has locked.

* Does not yet guarantee complete filesystem consistency on-crash.
12 files changed:
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_admin.c
sys/vfs/hammer2/hammer2_chain.c
sys/vfs/hammer2/hammer2_flush.c
sys/vfs/hammer2/hammer2_freemap.c
sys/vfs/hammer2/hammer2_inode.c
sys/vfs/hammer2/hammer2_ioctl.c
sys/vfs/hammer2/hammer2_strategy.c
sys/vfs/hammer2/hammer2_synchro.c
sys/vfs/hammer2/hammer2_vfsops.c
sys/vfs/hammer2/hammer2_vnops.c
sys/vfs/hammer2/hammer2_xops.c