Skip to content

Commit e9a844f

Browse files
Yongpeng YangJaegeuk Kim
authored andcommitted
f2fs: The GC triggered by ioctl also needs to mark the segno as victim
In SSR mode, the segment selected for allocation might be the same as the target segment of the GC triggered by ioctl, resulting in the GC moving the CURSEG_I(sbi, type)->segno. Thread A Thread B or Thread A - f2fs_ioc_gc_range - __f2fs_ioc_gc_range(.victim_segno=segno#N) - f2fs_gc - __get_victim - f2fs_get_victim : segno#N is valid, return segno#N as source segment of GC - f2fs_allocate_data_block - need_new_seg - get_ssr_segment - f2fs_get_victim : get segno #N as destination segment - change_curseg Fixes: e066b83 ("f2fs: add ioctl to flush data from faster device to cold area") Signed-off-by: Yongpeng Yang <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 5f65945 commit e9a844f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/f2fs/gc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,14 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
806806
goto out;
807807
}
808808

809-
if (sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result)))
809+
if (sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result))) {
810810
ret = -EBUSY;
811-
else
812-
p.min_segno = *result;
813-
goto out;
811+
goto out;
812+
}
813+
if (gc_type == FG_GC)
814+
clear_bit(GET_SEC_FROM_SEG(sbi, *result), dirty_i->victim_secmap);
815+
p.min_segno = *result;
816+
goto got_result;
814817
}
815818

816819
ret = -ENODATA;

0 commit comments

Comments
 (0)