summaryrefslogtreecommitdiff
path: root/fs/f2fs/extent_cache.c
diff options
context:
space:
mode:
authorqixiaoyu1 <qxy65535@gmail.com>2023-02-04 17:43:45 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2023-02-07 10:39:19 -0800
commitd23be468eada21c828058e0e8d60409eaec373ab (patch)
tree6505bfba955c0b157c2f6d0fc476e6eebda22e2e /fs/f2fs/extent_cache.c
parent04d7a7ae43fc4eed800efadbb4a18059172afb19 (diff)
f2fs: add sysfs nodes to set last_age_weight
Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> Signed-off-by: xiongping1 <xiongping1@xiaomi.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/extent_cache.c')
-rw-r--r--fs/f2fs/extent_cache.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index c8efc957c230..aef308e871ab 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -871,19 +871,21 @@ unlock_out:
}
#endif
-static unsigned long long __calculate_block_age(unsigned long long new,
+static unsigned long long __calculate_block_age(struct f2fs_sb_info *sbi,
+ unsigned long long new,
unsigned long long old)
{
unsigned int rem_old, rem_new;
unsigned long long res;
+ unsigned int weight = sbi->last_age_weight;
- res = div_u64_rem(new, 100, &rem_new) * (100 - LAST_AGE_WEIGHT)
- + div_u64_rem(old, 100, &rem_old) * LAST_AGE_WEIGHT;
+ res = div_u64_rem(new, 100, &rem_new) * (100 - weight)
+ + div_u64_rem(old, 100, &rem_old) * weight;
if (rem_new)
- res += rem_new * (100 - LAST_AGE_WEIGHT) / 100;
+ res += rem_new * (100 - weight) / 100;
if (rem_old)
- res += rem_old * LAST_AGE_WEIGHT / 100;
+ res += rem_old * weight / 100;
return res;
}
@@ -917,7 +919,7 @@ static int __get_new_block_age(struct inode *inode, struct extent_info *ei,
cur_age = ULLONG_MAX - tei.last_blocks + cur_blocks;
if (tei.age)
- ei->age = __calculate_block_age(cur_age, tei.age);
+ ei->age = __calculate_block_age(sbi, cur_age, tei.age);
else
ei->age = cur_age;
ei->last_blocks = cur_blocks;
@@ -1244,6 +1246,7 @@ void f2fs_init_extent_cache_info(struct f2fs_sb_info *sbi)
atomic64_set(&sbi->allocated_data_blocks, 0);
sbi->hot_data_age_threshold = DEF_HOT_DATA_AGE_THRESHOLD;
sbi->warm_data_age_threshold = DEF_WARM_DATA_AGE_THRESHOLD;
+ sbi->last_age_weight = LAST_AGE_WEIGHT;
}
int __init f2fs_create_extent_cache(void)