HAMMER VFS - Add a B-Tree rebalancing feature.
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 15 Mar 2009 22:28:38 +0000 (15:28 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 15 Mar 2009 22:28:38 +0000 (15:28 -0700)
commit1775b6a0acbf9ffea2442141c3d913793fe39738
treec9a82009bff87d36cc49e05694110588ad61ada4
parentbd65e5279418f9630b54e4e33fd72d348e88c955
HAMMER VFS - Add a B-Tree rebalancing feature.

This is the initial commit of B-Tree rebalancing support for HAMMER.
The rebalancer may be run using the 'hammer rebalance' utility directive.

The leafs in a HAMMER B-Tree all reside at the same depth.  Insertions and
deletions only collapse the B-Tree when a leaf node becomes empty and then
only if any necessary recursion (possibly reaching the root node) succeeds.
No balancing occurs during normal operation and B-Tree nodes can wind up
with wildly different element counts which bloats the tree and makes
searches less efficient.

The rebalancer effectively does a depth-first traversal of the B-Tree,
visiting leaf nodes first and parent nodes as a trailing function on the
way back up the tree.  For any given internal node the sum total of
elements contained in its children is divided by the number of children.
The effective number of children is reduced as is practical to obtain a 75%
fill level.  The elements are then packed into the children and any
wholely empty children left over are deleted.  The rebalancer does not
create new B-Tree nodes.

Element packing is fairly complex, requiring tracked cursors, on-media
parent pointers, mirror TIDs, and boundary elements to be updated.  The
rebalancer must hold a large number of B-Tree nodes exclusively locked
while running.
sys/conf/files
sys/vfs/hammer/Makefile
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_btree.c
sys/vfs/hammer/hammer_cursor.c
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_rebalance.c [new file with mode: 0644]
sys/vfs/hammer/hammer_reblock.c