hammer2 - Fix serious de-duplication bug and a few other things
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Apr 2020 00:38:10 +0000 (17:38 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 24 Apr 2020 00:47:10 +0000 (17:47 -0700)
commit58898c0eb3f3dcaecea7216c70e96b4be4a3ff7f
treee565718b4394824c4b08e6099fa7273f911dcdd8
parent1711dc2f15093bfab4de9b9688b9a07bd0e2bb4d
hammer2 - Fix serious de-duplication bug and a few other things

* Fix a serious de-duplication bug.  When small files <= 512
  bytes are extended with write()s to being larger than 512 bytes,
  it triggers a de-duplication bug in the first block of the file
  if that block can be de-duplicated from other sources.

  A mishandled skip condition combined with modest buffer cache
  flush loads can cause this first block can wind up getting
  zero'd out and cause a CHECK failure (I/O error) on the file.

  The fixes for this are primarily in hammer2_chain_modify().

* Replace HAMMER2_BREF_FLAG_ZERO in the bref.flags with
  HAMMER2_CHAIN_NOTTESTED in the chain structure and deprecate
  the flag.  This flag could sometimes accidentally be flushed
  to the media.

* Clear HAMMER2_CHAIN_INITIAL in two strategy write paths
  that are not typically hit.  The flag is probably already
  clear at this point since hammer2_chain_modify() has likely
  already been called, but be sure.
sys/vfs/hammer2/hammer2.h
sys/vfs/hammer2/hammer2_chain.c
sys/vfs/hammer2/hammer2_disk.h
sys/vfs/hammer2/hammer2_io.c
sys/vfs/hammer2/hammer2_strategy.c