From ed222e588034b7b60ca79029379fb6b64f455ebc Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 2 Apr 2026 10:49:00 -0700 Subject: [PATCH] Clear roots when retrying due to stale btree blocks. Before deltas were added this code path was correct, but with deltas we can't just retry this without clearing &root, since it would potentially double count. The condition where this could happen is when there are deltas in several finalized log trees, and we've made progress towards reading some of them, and then encounter a stale btree block. The retry would not clear the collected trees, apply the same delta as was already applied before the retry, and thus double count. Signed-off-by: Auke Kok --- kmod/src/wkic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kmod/src/wkic.c b/kmod/src/wkic.c index 44eef494..58737c62 100644 --- a/kmod/src/wkic.c +++ b/kmod/src/wkic.c @@ -886,8 +886,12 @@ retry_stale: trace_scoutfs_wkic_read_items(sb, key, &start, &end); ret = scoutfs_block_check_stale(sb, ret, &saved, &roots.fs_root.ref, &roots.logs_root.ref); if (ret < 0) { - if (ret == -ESTALE) + if (ret == -ESTALE) { + /* not safe to retry due to delta items, must restart clean */ + free_item_tree(&root); + root = RB_ROOT; goto retry_stale; + } goto out; }