scoutfs: clear seg rb node after replacing

When inserting a newly allocated segment we might find an existing
cached stale segment.  We replace it in the cache so that its user can
keep using its stale contents while we work on the new segment.

Replacing doesn't clear the rb_node, though, so we trip over a warning
when we finally free the segment and it looks like it's still present in
the rb tree.

Clear the node after we replace it so that freeing sees a clear node and
doesn't issue a warning.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-05-16 14:51:36 -07:00
parent 5307c56954
commit 8ea414ac68

View File

@@ -182,6 +182,7 @@ static struct scoutfs_segment *replace_seg(struct segment_cache *cac,
node = &(*node)->rb_right;
} else {
rb_replace_node(&seg->node, &ins->node, root);
RB_CLEAR_NODE(&seg->node);
lru_check(cac, seg);
lru_check(cac, ins);
found = seg;