summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/gc.c
diff options
context:
space:
mode:
authorChao Yu2015-10-05 16:20:40 +0200
committerJaegeuk Kim2015-10-10 01:20:56 +0200
commit3342bb303bf48dd8bb5ac94c3356489ff53e4d04 (patch)
treed5aa4f6a768a9b50a8ed3662d801a29f285be52d /fs/f2fs/gc.c
parentf2fs: fix to avoid redundant searching in dirty map during gc (diff)
downloadkernel-qcow2-linux-3342bb303bf48dd8bb5ac94c3356489ff53e4d04.tar.gz
kernel-qcow2-linux-3342bb303bf48dd8bb5ac94c3356489ff53e4d04.tar.xz
kernel-qcow2-linux-3342bb303bf48dd8bb5ac94c3356489ff53e4d04.zip
f2fs: skip searching dirty map if dirty segment is not exist
When searching victim during gc, if there are no dirty segments in filesystem, we will still take the time to search the whole dirty segment map, it's not needed, it's better to skip in this condition. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/gc.c')
-rw-r--r--fs/f2fs/gc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index e5c255ba227b..d844a8028527 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -268,6 +268,9 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
p.min_segno = NULL_SEGNO;
p.min_cost = max_cost = get_max_cost(sbi, &p);
+ if (p.max_search == 0)
+ goto out;
+
if (p.alloc_mode == LFS && gc_type == FG_GC) {
p.min_segno = check_bg_victims(sbi);
if (p.min_segno != NULL_SEGNO)
@@ -329,6 +332,7 @@ got_it:
sbi->cur_victim_sec,
prefree_segments(sbi), free_segments(sbi));
}
+out:
mutex_unlock(&dirty_i->seglist_lock);
return (p.min_segno == NULL_SEGNO) ? 0 : 1;