The item cache was getting inconsistent as items were removed. This
would manifest in failing to find dirty items that it had counted as it
was writing items into the segment and removing deletion items.
For a start it wasn't using the augmented rb_erase(). We make a
function that everyone uses. There's no augmented rb_replace() so We
just augment erase, restart, and insert. (We could probably augment on
descent and replace/propagate but that can come later.)
Then the augmentation callbacks got the semantics slightly wrong. The
rotation callback is named after a caller that happens to use it, not on
any implied relationship between the nodes. It actually just
recalculates the augmentation value for the two subtrees. Mischief
managed.
(We'll probably rework the augmentation so the value is for the node and
its children and we can get rid of the extra code we have today to
support our augmentation value that is sensitive to the difference
between the left and write subtrees.)
Signed-off-by: Zach Brown <zab@versity.com>