f2fs: use aggressive GC policy during f2fs_disable_checkpoint()
Chao Yu
maintainerPATCH 1/1 f2fs: use aggressive GC policy during f2fs_disable_checkpoint()
Use more aggressive GC policy as below to improve performance of GC during f2fs_disable_checkpoint():
- use GC_URGENT_HIGH mode to enable greedy algorithm and SSR allocator;
- use asynchronous GC and in-batch write to imporve possibility of IO merge.
Signed-off-by Chao Yu <[email protected]>
--- fs/f2fs/f2fs.h | 3 +++ fs/f2fs/super.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +3 -0
@@ -589,6 +589,9 @@ enum {/* dirty segments threshold for triggering CP */ #define DEFAULT_DIRTY_THRESHOLD 4 +/* count of section which will be written in-batch during disabling checkpoint */ +#define INBATCH_WRITE_SECTION_COUNT 8 +/* for in-memory extent cache entry */ #define F2FS_MIN_EXTENT_LEN 64/* minimum extent length */
fs/f2fs/super.c +12 -1
@@ -2080,9 +2080,11 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) {unsigned int s_flags = sbi->sb->s_flags;struct cp_control cpc; +unsigned int gc_mode;int err =0 ;int ret;block_t unusable; +int inbatch_cnt =0 ;if (s_flags &SB_RDONLY ) {f2fs_err (sbi,"checkpoint=disable on readonly fs" );
@@ -2092,15 +2094,23 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)f2fs_update_time (sbi,DISABLE_TIME ); + gc_mode = sbi->gc_mode; + sbi->gc_mode =GC_URGENT_HIGH ; +while (!f2fs_time_over (sbi,DISABLE_TIME )) {f2fs_down_write (&sbi->gc_lock); - err =f2fs_gc (sbi, true, false, false,NULL_SEGNO ); + err =f2fs_gc (sbi, false, false, false,NULL_SEGNO );if (err == -ENODATA ) { err =0 ;break ; }if (err && err != -EAGAIN )break ; + +if (++inbatch_cnt ==INBATCH_WRITE_SECTION_COUNT ) { +writeback_inodes_sb (sbi->sb,WB_REASON_SYNC ); + inbatch_cnt =0 ; + } } ret =sync_filesystem (sbi->sb);
@@ -2129,6 +2139,7 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) out_unlock:f2fs_up_write (&sbi->gc_lock); restore_flag: + sbi->gc_mode = gc_mode; sbi->sb->s_flags = s_flags;/* Restore SB_RDONLY status */ return err; }
Signature · 1 line
2.32.0