diff options
author | Yunlei He <heyunlei@huawei.com> | 2016-07-22 07:08:31 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-07-22 14:55:31 -0400 |
commit | fe94793e555f650fab656649521fc38aaab4874e (patch) | |
tree | 3eda71fb06e91cf9cb5712e89e9dd950fe5bd11a | |
parent | 6f3ec9952c13f0adf632e89456df43946cec6525 (diff) |
f2fs: get victim segment again after new cp
Previous selected segment may become free after write_checkpoint,
if we do garbage collect on this segment, and then new_curseg happen
to reuse it, it may cause f2fs_bug_on as below.
panic+0x154/0x29c
do_garbage_collect+0x15c/0xaf4
f2fs_gc+0x2dc/0x444
f2fs_balance_fs.part.22+0xcc/0x14c
f2fs_balance_fs+0x28/0x34
f2fs_map_blocks+0x5ec/0x790
f2fs_preallocate_blocks+0xe0/0x100
f2fs_file_write_iter+0x64/0x11c
new_sync_write+0xac/0x11c
vfs_write+0x144/0x1e4
SyS_write+0x60/0xc0
Here, maybe we check sit and ssa type during reset_curseg. So, we check
segment is stale or not, and select a new victim to avoid this.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/gc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index de6c41c32c62..06cfb94cc3db 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c | |||
@@ -908,10 +908,13 @@ gc_more: | |||
908 | * enough free sections, we should flush dent/node blocks and do | 908 | * enough free sections, we should flush dent/node blocks and do |
909 | * garbage collections. | 909 | * garbage collections. |
910 | */ | 910 | */ |
911 | if (__get_victim(sbi, &segno, gc_type) || prefree_segments(sbi)) | 911 | if (__get_victim(sbi, &segno, gc_type) || |
912 | prefree_segments(sbi)) { | ||
912 | write_checkpoint(sbi, &cpc); | 913 | write_checkpoint(sbi, &cpc); |
913 | else if (has_not_enough_free_secs(sbi, 0)) | 914 | segno = NULL_SEGNO; |
915 | } else if (has_not_enough_free_secs(sbi, 0)) { | ||
914 | write_checkpoint(sbi, &cpc); | 916 | write_checkpoint(sbi, &cpc); |
917 | } | ||
915 | } | 918 | } |
916 | 919 | ||
917 | if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type)) | 920 | if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type)) |