[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230113125859.15651-1-qixiaoyu1@xiaomi.com>
Date: Fri, 13 Jan 2023 20:58:58 +0800
From: qixiaoyu1 <qxy65535@...il.com>
To: Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>
Cc: linux-kernel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, xiongping1@...omi.com,
qixiaoyu1 <qixiaoyu1@...omi.com>
Subject: [PATCH 1/2] f2fs: fix wrong calculation of block age
Currently we wrongly calculate the new block age to
old * LAST_AGE_WEIGHT / 100.
Fix it to new * (100 - LAST_AGE_WEIGHT) / 100
+ old * LAST_AGE_WEIGHT / 100.
Signed-off-by: qixiaoyu1 <qixiaoyu1@...omi.com>
---
fs/f2fs/extent_cache.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 342af24b2f8c..93a1ab186517 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -874,11 +874,7 @@ void f2fs_update_read_extent_tree_range_compressed(struct inode *inode,
static unsigned long long __calculate_block_age(unsigned long long new,
unsigned long long old)
{
- unsigned long long diff;
-
- diff = (new >= old) ? new - (new - old) : new + (old - new);
-
- return div_u64(diff * LAST_AGE_WEIGHT, 100);
+ return new - new / 100 * LAST_AGE_WEIGHT + old / 100 * LAST_AGE_WEIGHT;
}
/* This returns a new age and allocated blocks in ei */
--
2.36.1
Powered by blists - more mailing lists