scoutfs: fix ring next/prev walk comparison test

The scoutfs_ring_next() and _prev() functions had a really dumb bug
where they check the sign of comparisons by comparing with 1.  For
example, next would miss that the walk traversed a lesser item
and wouldn't return the next item.

This was causing compaction to miss underlying segments, creating
segments in levels that had overlapping keys, which then totally
confused reading and kept it from finding the items it was looking for.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-06-06 14:32:29 -07:00
parent 79de18443b
commit a050152254

View File

@@ -320,7 +320,7 @@ void *scoutfs_ring_lookup_next(struct scoutfs_ring_info *ring, void *key)
int cmp;
rnode = ring_rb_walk(ring, key, NULL, NULL, &cmp);
if (rnode && (cmp > 1 || rnode->deleted))
if (rnode && (cmp > 0 || rnode->deleted))
rnode = ring_rb_next(rnode);
return rnode_data(rnode);
@@ -332,7 +332,7 @@ void *scoutfs_ring_lookup_prev(struct scoutfs_ring_info *ring, void *key)
int cmp;
rnode = ring_rb_walk(ring, key, NULL, NULL, &cmp);
if (rnode && (cmp < 1 || rnode->deleted))
if (rnode && (cmp < 0 || rnode->deleted))
rnode = ring_rb_prev(rnode);
return rnode_data(rnode);