From a05015225482b16e05ee1fa1faaafa2a15daa8e0 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 6 Jun 2017 14:32:29 -0700 Subject: [PATCH] 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 --- kmod/src/ring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kmod/src/ring.c b/kmod/src/ring.c index 7eb61b0a..47a21bc9 100644 --- a/kmod/src/ring.c +++ b/kmod/src/ring.c @@ -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);