mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-07 11:10:44 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user