Loading fs/f2fs/gc.c +20 −26 Original line number Diff line number Diff line Loading @@ -391,7 +391,7 @@ static int check_valid_map(struct f2fs_sb_info *sbi, * On validity, copy that node with cold status, otherwise (invalid node) * ignore that. */ static void gc_node_segment(struct f2fs_sb_info *sbi, static int gc_node_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, unsigned int segno, int gc_type) { bool initial = true; Loading @@ -411,7 +411,7 @@ static void gc_node_segment(struct f2fs_sb_info *sbi, /* stop BG_GC if there is not enough free sections. */ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0)) return; return 0; if (check_valid_map(sbi, segno, off) == 0) continue; Loading Loading @@ -461,13 +461,11 @@ static void gc_node_segment(struct f2fs_sb_info *sbi, }; sync_node_pages(sbi, 0, &wbc); /* * In the case of FG_GC, it'd be better to reclaim this victim * completely. */ if (get_valid_blocks(sbi, segno, 1) != 0) goto next_step; /* return 1 only if FG_GC succefully reclaimed one */ if (get_valid_blocks(sbi, segno, 1) == 0) return 1; } return 0; } /* Loading Loading @@ -649,7 +647,7 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type) * If the parent node is not valid or the data block address is different, * the victim data block is ignored. */ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, struct gc_inode_list *gc_list, unsigned int segno, int gc_type) { struct super_block *sb = sbi->sb; Loading @@ -672,7 +670,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, /* stop BG_GC if there is not enough free sections. */ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0)) return; return 0; if (check_valid_map(sbi, segno, off) == 0) continue; Loading Loading @@ -737,15 +735,11 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, if (gc_type == FG_GC) { f2fs_submit_merged_bio(sbi, DATA, WRITE); /* * In the case of FG_GC, it'd be better to reclaim this victim * completely. */ if (get_valid_blocks(sbi, segno, 1) != 0) { phase = 2; goto next_step; } /* return 1 only if FG_GC succefully reclaimed one */ if (get_valid_blocks(sbi, segno, 1) == 0) return 1; } return 0; } static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, Loading @@ -761,12 +755,13 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, return ret; } static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, static int do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, struct gc_inode_list *gc_list, int gc_type) { struct page *sum_page; struct f2fs_summary_block *sum; struct blk_plug plug; int nfree = 0; /* read segment summary of victim */ sum_page = get_sum_page(sbi, segno); Loading @@ -786,10 +781,11 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, switch (GET_SUM_TYPE((&sum->footer))) { case SUM_TYPE_NODE: gc_node_segment(sbi, sum->entries, segno, gc_type); nfree = gc_node_segment(sbi, sum->entries, segno, gc_type); break; case SUM_TYPE_DATA: gc_data_segment(sbi, sum->entries, gc_list, segno, gc_type); nfree = gc_data_segment(sbi, sum->entries, gc_list, segno, gc_type); break; } blk_finish_plug(&plug); Loading @@ -798,6 +794,7 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, stat_inc_call_count(sbi->stat_info); f2fs_put_page(sum_page, 0); return nfree; } int f2fs_gc(struct f2fs_sb_info *sbi) Loading Loading @@ -836,13 +833,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi) META_SSA); for (i = 0; i < sbi->segs_per_sec; i++) do_garbage_collect(sbi, segno + i, &gc_list, gc_type); nfree += do_garbage_collect(sbi, segno + i, &gc_list, gc_type); if (gc_type == FG_GC) { if (gc_type == FG_GC) sbi->cur_victim_sec = NULL_SEGNO; nfree++; WARN_ON(get_valid_blocks(sbi, segno, sbi->segs_per_sec)); } if (has_not_enough_free_secs(sbi, nfree)) goto gc_more; Loading Loading
fs/f2fs/gc.c +20 −26 Original line number Diff line number Diff line Loading @@ -391,7 +391,7 @@ static int check_valid_map(struct f2fs_sb_info *sbi, * On validity, copy that node with cold status, otherwise (invalid node) * ignore that. */ static void gc_node_segment(struct f2fs_sb_info *sbi, static int gc_node_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, unsigned int segno, int gc_type) { bool initial = true; Loading @@ -411,7 +411,7 @@ static void gc_node_segment(struct f2fs_sb_info *sbi, /* stop BG_GC if there is not enough free sections. */ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0)) return; return 0; if (check_valid_map(sbi, segno, off) == 0) continue; Loading Loading @@ -461,13 +461,11 @@ static void gc_node_segment(struct f2fs_sb_info *sbi, }; sync_node_pages(sbi, 0, &wbc); /* * In the case of FG_GC, it'd be better to reclaim this victim * completely. */ if (get_valid_blocks(sbi, segno, 1) != 0) goto next_step; /* return 1 only if FG_GC succefully reclaimed one */ if (get_valid_blocks(sbi, segno, 1) == 0) return 1; } return 0; } /* Loading Loading @@ -649,7 +647,7 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type) * If the parent node is not valid or the data block address is different, * the victim data block is ignored. */ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, struct gc_inode_list *gc_list, unsigned int segno, int gc_type) { struct super_block *sb = sbi->sb; Loading @@ -672,7 +670,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, /* stop BG_GC if there is not enough free sections. */ if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0)) return; return 0; if (check_valid_map(sbi, segno, off) == 0) continue; Loading Loading @@ -737,15 +735,11 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, if (gc_type == FG_GC) { f2fs_submit_merged_bio(sbi, DATA, WRITE); /* * In the case of FG_GC, it'd be better to reclaim this victim * completely. */ if (get_valid_blocks(sbi, segno, 1) != 0) { phase = 2; goto next_step; } /* return 1 only if FG_GC succefully reclaimed one */ if (get_valid_blocks(sbi, segno, 1) == 0) return 1; } return 0; } static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, Loading @@ -761,12 +755,13 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, return ret; } static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, static int do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, struct gc_inode_list *gc_list, int gc_type) { struct page *sum_page; struct f2fs_summary_block *sum; struct blk_plug plug; int nfree = 0; /* read segment summary of victim */ sum_page = get_sum_page(sbi, segno); Loading @@ -786,10 +781,11 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, switch (GET_SUM_TYPE((&sum->footer))) { case SUM_TYPE_NODE: gc_node_segment(sbi, sum->entries, segno, gc_type); nfree = gc_node_segment(sbi, sum->entries, segno, gc_type); break; case SUM_TYPE_DATA: gc_data_segment(sbi, sum->entries, gc_list, segno, gc_type); nfree = gc_data_segment(sbi, sum->entries, gc_list, segno, gc_type); break; } blk_finish_plug(&plug); Loading @@ -798,6 +794,7 @@ static void do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int segno, stat_inc_call_count(sbi->stat_info); f2fs_put_page(sum_page, 0); return nfree; } int f2fs_gc(struct f2fs_sb_info *sbi) Loading Loading @@ -836,13 +833,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi) META_SSA); for (i = 0; i < sbi->segs_per_sec; i++) do_garbage_collect(sbi, segno + i, &gc_list, gc_type); nfree += do_garbage_collect(sbi, segno + i, &gc_list, gc_type); if (gc_type == FG_GC) { if (gc_type == FG_GC) sbi->cur_victim_sec = NULL_SEGNO; nfree++; WARN_ON(get_valid_blocks(sbi, segno, sbi->segs_per_sec)); } if (has_not_enough_free_secs(sbi, nfree)) goto gc_more; Loading