hammer2 - Fix bulkfree bug, Fix chain->parent bug, refactor dedup a bit
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 27 Aug 2017 04:56:14 +0000 (21:56 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 27 Aug 2017 05:22:14 +0000 (22:22 -0700)
commitb49f72c388b8abdc9d74fa508d5dddf2ee0d6c6e
treeeeea2a87fbcabbeaaee68797088969f62379ac39
parentbd1442a2d049c60c09190c201ca18033f9dfac1e
hammer2 - Fix bulkfree bug, Fix chain->parent bug, refactor dedup a bit

* Fix a bulkfree bug where live->linear was being calculated using
  HAMMER2_FREEMAP_BLOCK_SIZE instead of HAMMER2_BMAP_INDEX_SIZE.
  This calculation was still block-size-aligned and couldn't cause
  any damage.  However, the conditional itself was in error and
  could prevent bulkfree from correcting an unaligned live->linear
  value.

  The new code unconditoinally corrects live->linear for now.
  Bulkfree doesn't collect sufficiently fine-grained data to set
  it properly.

* bulkfree now also requires live->linear to be reasonable when deciding
  to skip bitmaps.

* hammer2_chain_modify() needs to know when a dedup has been registered
  for a (data) block.  We previously cleared the CHAIN_MODIFIED bit to
  force a reallocation, but doing so interferes with the flush code
  (even though UPDATE remains set).

  Fix this by adding a chain flag.  Also properly set the flag only if
  a dedup has actually been registered, and properly clear the flag once
  the underlying storage has been reallocated.

* Refactor hammer2_chain_getparent() and add hammer2_chain_repparent().
  Have these functions deal with all chain->parent race conditions
  themselves.

  This fixes a race condition in two places, most importantly in
  hammer2_xop_nrename() (albeit limited to directory-embedded inodes,
  which would only be the super-root entries).

* Do a better job protecting the chain->parent field.  Require that
  chain->core.spin be held for field modifications in addition to
  parent->core.spin.  This fixes a race against hammer2_chain_setflush()
  that could cause the flush code to miss chains.

* Disable TIMER() debugging for now.
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_bulkfree.c
sys/vfs/hammer2/hammer2_chain.c
sys/vfs/hammer2/hammer2_freemap.c
sys/vfs/hammer2/hammer2_inode.c
sys/vfs/hammer2/hammer2_strategy.c
sys/vfs/hammer2/hammer2_xops.c