Commit a43f7ec3 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to avoid redundant searching in dirty map during gc

When doing gc, we search a victim in dirty map, starting from position of
last victim, we will reset the current searching position until we touch
the end of dirty map, and then search the whole diryt map. So sometimes we
will search the range [victim, last] twice, it's redundant, this patch
avoids this issue.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 5b7ee374
...@@ -257,6 +257,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, ...@@ -257,6 +257,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
struct victim_sel_policy p; struct victim_sel_policy p;
unsigned int secno, max_cost; unsigned int secno, max_cost;
unsigned int last_segment = MAIN_SEGS(sbi);
int nsearched = 0; int nsearched = 0;
mutex_lock(&dirty_i->seglist_lock); mutex_lock(&dirty_i->seglist_lock);
...@@ -277,9 +278,10 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, ...@@ -277,9 +278,10 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
unsigned long cost; unsigned long cost;
unsigned int segno; unsigned int segno;
segno = find_next_bit(p.dirty_segmap, MAIN_SEGS(sbi), p.offset); segno = find_next_bit(p.dirty_segmap, last_segment, p.offset);
if (segno >= MAIN_SEGS(sbi)) { if (segno >= last_segment) {
if (sbi->last_victim[p.gc_mode]) { if (sbi->last_victim[p.gc_mode]) {
last_segment = sbi->last_victim[p.gc_mode];
sbi->last_victim[p.gc_mode] = 0; sbi->last_victim[p.gc_mode] = 0;
p.offset = 0; p.offset = 0;
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment