linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] f2fs: fix wrong calculation of block age
@ 2023-01-13 12:58 qixiaoyu1
  2023-01-13 12:58 ` [f2fs-dev] [PATCH 2/2] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
  2023-01-16  3:08 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age qixiaoyu1
  0 siblings, 2 replies; 18+ messages in thread
From: qixiaoyu1 @ 2023-01-13 12:58 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu
  Cc: xiongping1, qixiaoyu1, linux-kernel, linux-f2fs-devel

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@xiaomi.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



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-02-07 18:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 12:58 [f2fs-dev] [PATCH 1/2] f2fs: fix wrong calculation of block age qixiaoyu1
2023-01-13 12:58 ` [f2fs-dev] [PATCH 2/2] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-01-16  3:08 ` [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age qixiaoyu1
2023-01-16  3:08   ` [f2fs-dev] [PATCH 2/2 v2] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-01-28  3:35   ` [f2fs-dev] [PATCH 1/2 v2] f2fs: fix wrong calculation of block age Chao Yu
2023-01-29 11:18     ` qixiaoyu
2023-02-01 12:23       ` qixiaoyu
2023-02-01 12:57         ` Chao Yu
2023-02-01 14:04           ` qixiaoyu
2023-02-02  8:20           ` [f2fs-dev] [PATCH 1/2 v3] " qixiaoyu1
2023-02-02  8:20             ` [f2fs-dev] [PATCH 2/2 v3] f2fs: add sysfs nodes to set last_age_weight qixiaoyu1
2023-02-03  8:31               ` Chao Yu
2023-02-04  9:06                 ` qixiaoyu
2023-02-04  9:43                 ` [f2fs-dev] [PATCH 2/2 v4] " qixiaoyu1
2023-02-07 12:31                   ` Chao Yu
2023-02-07 18:39                     ` Jaegeuk Kim
2023-02-03  6:11             ` [f2fs-dev] [PATCH 1/2 v3] f2fs: fix wrong calculation of block age Chao Yu
2023-02-06  3:40             ` patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).