diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-09-15 06:05:44 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-09-23 14:10:23 -0400 |
commit | 210f41bc048263d572515e1e0edc28d362ce673e (patch) | |
tree | 63f13e141529262c19db28156fc46933f9a24ccf | |
parent | 26666c8a4366debae30ae37d0688b2bec92d196a (diff) |
f2fs: fix to search whole dirty segmap when get_victim
In ->get_victim we get max_search value from dirty_i->nr_dirty without
protection of seglist_lock, after that, nr_dirty can be increased/decreased
before we hold seglist_lock lock.
Then in main loop we attempt to traverse all dirty section one time to find
victim section, but it's not accurate to use max_search as the total loop count,
because we might lose checking several sections or check sections redundantly
for the case of nr_dirty are increased or decreased previously.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/gc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index dca7818c0662..7bf8392d555f 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c | |||
@@ -263,14 +263,14 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, | |||
263 | unsigned int secno, max_cost; | 263 | unsigned int secno, max_cost; |
264 | int nsearched = 0; | 264 | int nsearched = 0; |
265 | 265 | ||
266 | mutex_lock(&dirty_i->seglist_lock); | ||
267 | |||
266 | p.alloc_mode = alloc_mode; | 268 | p.alloc_mode = alloc_mode; |
267 | select_policy(sbi, gc_type, type, &p); | 269 | select_policy(sbi, gc_type, type, &p); |
268 | 270 | ||
269 | p.min_segno = NULL_SEGNO; | 271 | p.min_segno = NULL_SEGNO; |
270 | p.min_cost = max_cost = get_max_cost(sbi, &p); | 272 | p.min_cost = max_cost = get_max_cost(sbi, &p); |
271 | 273 | ||
272 | mutex_lock(&dirty_i->seglist_lock); | ||
273 | |||
274 | if (p.alloc_mode == LFS && gc_type == FG_GC) { | 274 | if (p.alloc_mode == LFS && gc_type == FG_GC) { |
275 | p.min_segno = check_bg_victims(sbi); | 275 | p.min_segno = check_bg_victims(sbi); |
276 | if (p.min_segno != NULL_SEGNO) | 276 | if (p.min_segno != NULL_SEGNO) |