From ff882a4c4fcf87c9b70446069987a839a5553904 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 28 Dec 2020 13:30:12 -0800 Subject: [PATCH] Add btree total_above_join_low_water() test Take the condition used to decide if a btree block needs to be joined and put it in total_above_join_low_water() so that btree_merging will be able to call it to see if the leaf block it's merging into needs to be joined. Signed-off-by: Zach Brown --- kmod/src/btree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kmod/src/btree.c b/kmod/src/btree.c index 96a20ef8..fdcd8996 100644 --- a/kmod/src/btree.c +++ b/kmod/src/btree.c @@ -118,6 +118,11 @@ static unsigned int join_low_watermark(void) return (SCOUTFS_BLOCK_LG_SIZE - sizeof(struct scoutfs_btree_block)) / 4; } +static bool total_above_join_low_water(struct scoutfs_btree_block *bt) +{ + return le16_to_cpu(bt->total_item_bytes) >= join_low_watermark(); +} + /* * return the integer percentages of total space the block could have * consumed by items that is currently consumed. @@ -814,7 +819,7 @@ static int try_join(struct super_block *sb, int to_move; int ret; - if (le16_to_cpu(bt->total_item_bytes) >= join_low_watermark()) + if (total_above_join_low_water(bt)) return 0; scoutfs_inc_counter(sb, btree_join);