Skip to content

Commit 6efc3a0

Browse files
Zhiguo NiuJaegeuk Kim
authored andcommitted
f2fs: enable atgc dynamically if conditions are met
Now atgc can only be enabled when umounted->mounted device even related conditions have reached. If the device has not be umounted->mounted for a long time, atgc can not work. So enable atgc dynamically when atgc_age_threshold is less than elapsed_time and ATGC mount option is on. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Zhiguo Niu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 298b1e4 commit 6efc3a0

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

fs/f2fs/checkpoint.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
17181718
}
17191719

17201720
f2fs_restore_inmem_curseg(sbi);
1721+
f2fs_reinit_atgc_curseg(sbi);
17211722
stat_inc_cp_count(sbi);
17221723
stop:
17231724
unblock_operations(sbi);

fs/f2fs/f2fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,6 +3693,7 @@ void f2fs_release_discard_addrs(struct f2fs_sb_info *sbi);
36933693
int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
36943694
bool f2fs_segment_has_free_slot(struct f2fs_sb_info *sbi, int segno);
36953695
int f2fs_init_inmem_curseg(struct f2fs_sb_info *sbi);
3696+
int f2fs_reinit_atgc_curseg(struct f2fs_sb_info *sbi);
36963697
void f2fs_save_inmem_curseg(struct f2fs_sb_info *sbi);
36973698
void f2fs_restore_inmem_curseg(struct f2fs_sb_info *sbi);
36983699
int f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type,

fs/f2fs/segment.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,12 +2931,12 @@ static int get_atssr_segment(struct f2fs_sb_info *sbi, int type,
29312931
return ret;
29322932
}
29332933

2934-
static int __f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi)
2934+
static int __f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi, bool force)
29352935
{
29362936
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC);
29372937
int ret = 0;
29382938

2939-
if (!sbi->am.atgc_enabled)
2939+
if (!sbi->am.atgc_enabled && !force)
29402940
return 0;
29412941

29422942
f2fs_down_read(&SM_I(sbi)->curseg_lock);
@@ -2953,9 +2953,30 @@ static int __f2fs_init_atgc_curseg(struct f2fs_sb_info *sbi)
29532953
f2fs_up_read(&SM_I(sbi)->curseg_lock);
29542954
return ret;
29552955
}
2956+
29562957
int f2fs_init_inmem_curseg(struct f2fs_sb_info *sbi)
29572958
{
2958-
return __f2fs_init_atgc_curseg(sbi);
2959+
return __f2fs_init_atgc_curseg(sbi, false);
2960+
}
2961+
2962+
int f2fs_reinit_atgc_curseg(struct f2fs_sb_info *sbi)
2963+
{
2964+
int ret;
2965+
2966+
if (!test_opt(sbi, ATGC))
2967+
return 0;
2968+
if (sbi->am.atgc_enabled)
2969+
return 0;
2970+
if (le64_to_cpu(F2FS_CKPT(sbi)->elapsed_time) <
2971+
sbi->am.age_threshold)
2972+
return 0;
2973+
2974+
ret = __f2fs_init_atgc_curseg(sbi, true);
2975+
if (!ret) {
2976+
sbi->am.atgc_enabled = true;
2977+
f2fs_info(sbi, "reenabled age threshold GC");
2978+
}
2979+
return ret;
29592980
}
29602981

29612982
static void __f2fs_save_inmem_curseg(struct f2fs_sb_info *sbi, int type)

0 commit comments

Comments
 (0)