[PATCH 02/20] Fix check for balancing versus merging btree blocks
Valerie Aurora
val at versity.com
Thu Jun 12 13:10:54 PDT 2025
The check for whether a block should be merged or rebalanced with its
neighbor had the sense reversed. We want to return true and rebalance
when the average free space per block is *less* than the free space
merge threshold.
Signed-off-by: Valerie Aurora <val at versity.com>
---
shared/btree.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/shared/btree.c b/shared/btree.c
index 39a9b57..8071f6f 100644
--- a/shared/btree.c
+++ b/shared/btree.c
@@ -656,8 +656,12 @@ static int merge_block(struct ngnfs_fs_info *nfi, struct ngnfs_transaction *txn,
if (ret < 0)
goto out;
- /* balance items between blocks if together they're both above threshold */
- until_balanced = (le16_to_cpu(trav->bt->total_free) + le16_to_cpu(nei->total_free)) >
+ /*
+ * Balance items between blocks if the result is two blocks
+ * whose average of free space is less than the merge free
+ * threshold, otherwise merge them.
+ */
+ until_balanced = le16_to_cpu(trav->bt->total_free) + le16_to_cpu(nei->total_free) <
(NGNFS_BTREE_MERGE_FREE_THRESH * 2);
/* expand our range so we can insert nei's items without triggering assertions */
--
2.49.0
More information about the ngnfs-devel
mailing list