scoutfs: free all forest iter pos

Forest item iteration allocates iterator positions for each tree root
it reads from.  The postorder destruction of the iterator nodes wasn't
quite right because we were balancing the nodes as they were freed.
That can change parent/child relationships and cause postorder iteration
to skip some nodes, leaking memory.  It would have worked if we just
freed the nodes without using rb_erase to balance.

The fix is to actually iterate over the rbnodes while using the destroy
helper which rebalances as it frees.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2020-03-04 14:00:57 -08:00
committed by Zach Brown
parent e9e515524b
commit debac8ab06

View File

@@ -961,7 +961,10 @@ retry:
unlock:
up_read(&lpriv->rwsem);
rbtree_postorder_for_each_entry_safe(ip, nip, &iter_root, node) {
/* destroy_ rebalances so postorder traversal could skip nodes */
for (ip = first_iter_pos(&iter_root);
ip && (nip = next_iter_pos(ip), 1);
ip = nip) {
destroy_iter_pos(ip, &iter_root);
}