hammer - Try to fix improper DATA CRC error
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 24 Jul 2016 02:09:26 +0000 (19:09 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 24 Jul 2016 03:59:53 +0000 (20:59 -0700)
commit7d886917ee2576f6736f3f2bb36d153e996dfb26
treecf9afc0a3ef9a655743e739b4bf1a62c968b6b51
parentfd155dfeae6a9f1f9b4ab7fc69fabdf060d6a0ef
hammer - Try to fix improper DATA CRC error

* Under heavy I/O loads HAMMER has an optimization (similar to UFS) where
  the logical buffer is used to issue a write to the underlying device,
  rather than copying the logical buffer to a device buffer.  This
  optmization is earmarked by a hammer2_record.

* If the logical buffer is discarded just after it is written, and then
  re-read, hammer may go through a path which calls
  hammer_ip_resolve_data().  This code failed to check whether the record
  was still in-progress, and in-fact the write to the device may not have
  even been initiated yet, and there could also have been a device buffer
  alias in the buffer cache for the device for the offset.

  This caused the followup read to access the wrong data, causing HAMMER
  to report a DATA CRC error.  The actual media receives the correct data
  eventually and a umount/remount would show an uncorrupted file.

* Try to fix the problem by calling hammer_io_direct_wait() on the record
  in this path to wait for the operation to complete (and also to
  invalidate the related device buffer) before trying to re-read the block
  from the media.
sys/vfs/hammer/hammer_object.c