HAMMER VFS - Correct seriuos bug in hammer rebalancing code
commitbbb01e143edc616b0a7ea418ab3a82c6abb1700c
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 2 Mar 2010 22:36:40 +0000 (2 14:36 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 2 Mar 2010 23:02:45 +0000 (2 15:02 -0800)
tree75118de151e007164f3a1e412fa21196922d5584
parent39e88285cb81d7847bb54a08e0f50a61be890e08
HAMMER VFS - Correct seriuos bug in hammer rebalancing code

* Correct a serious bug in the hammer rebalancing code which can cause
  incremental mirrors to lose track of records, resulting in missing records
  on the slave (missing files, missing directory entries, or files
  which improperly contain data holes).

  The rebalancing code needs to update the mirror_tid chain when moving
  elements from one node to another.  It updated the parent node but failed
  to update the internal element linkage pointing to the child.

  This can cause incremental mirroring operations to fail to copy some B-Tree
  records.

* Correct a possible issue between the rebalancing code and B-Tree
  iterations during mirror-write operations.

  When the rebalancer moves an element from one child node to another and
  a cursor exists which is pointing at the parent internal node, the
  cursor will now be mispositioned because elements which were to the
  right of the cursor are now to the left of the cursor.

  Adjust hammer_cursor_moved_element() to properly move the cursor and
  print a debug message to the console so the code path can be tested.

* These bugs are serious but also very rare.  There is a good chance that
  your slaves are just fine, but we recommend validating their contents
  anyway.

* PROCEDURE FOR FIXING BROKEN SLAVES:  With a little help from the sysop
  these problems are self-correcting with the new kernel code in place.

  First make sure both the master and slave are running a kernel with
  the mirroring fix.

  Second, verify the slave matches the master (taking into account
  changes being made to live files).  Probably the easiest way to do
  this is as follows (make sure you push into the softlink, not cpdup
  the softlink itself):

cpdup -v -V /pfs/master/. /pfs/slave/.

  This should get you a list of missing files and directories.  For
  each missing file or directory do a chmod, chown, or chflags on the
  master, then change it back.  This will propagate the updated inode
  to the slave So for example:

chflags nodump file
chflags dump file

  If file data is corrupt on the mirroring slave you need to recopy the
  file on the master, which can be done with dd conv=notrunc:

dd if=file of=file bs=32k conv=notrunc

  These actions will cause the master to re-mirror the related files and
  data to the slave.

Reported-by: Stathis Kamperis <beket@crater.dragonflybsd.org>
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_cursor.c
sys/vfs/hammer/hammer_mirror.c
sys/vfs/hammer/hammer_rebalance.c