Skip to content

Commit 22af1b8

Browse files
Zhiguo NiuJaegeuk Kim
authored andcommitted
f2fs: fix to check return value of f2fs_gc_range
f2fs_gc_range may return error, so its caller f2fs_allocate_pinning_section should determine whether to do retry based on ist return value. Also just do f2fs_gc_range when f2fs_allocate_new_section return -EAGAIN, and check cp error case in f2fs_gc_range. Signed-off-by: Zhiguo Niu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 28f66cc commit 22af1b8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

fs/f2fs/gc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,9 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi,
19861986
unsigned int segno;
19871987
unsigned int gc_secs = dry_run_sections;
19881988

1989+
if (unlikely(f2fs_cp_error(sbi)))
1990+
return -EIO;
1991+
19891992
for (segno = start_seg; segno <= end_seg; segno += SEGS_PER_SEC(sbi)) {
19901993
struct gc_inode_list gc_list = {
19911994
.ilist = LIST_HEAD_INIT(gc_list.ilist),

fs/f2fs/segment.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,6 +3109,7 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
31093109
{
31103110
struct curseg_info *curseg = CURSEG_I(sbi, type);
31113111
unsigned int old_segno;
3112+
int err = 0;
31123113

31133114
if (type == CURSEG_COLD_DATA_PINNED && !curseg->inited)
31143115
goto allocate;
@@ -3121,8 +3122,9 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type,
31213122

31223123
allocate:
31233124
old_segno = curseg->segno;
3124-
if (new_curseg(sbi, type, true))
3125-
return -EAGAIN;
3125+
err = new_curseg(sbi, type, true);
3126+
if (err)
3127+
return err;
31263128
stat_inc_seg_type(sbi, curseg);
31273129
locate_dirty_segment(sbi, old_segno);
31283130
return 0;
@@ -3151,13 +3153,14 @@ int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi)
31513153
err = f2fs_allocate_new_section(sbi, CURSEG_COLD_DATA_PINNED, false);
31523154
f2fs_unlock_op(sbi);
31533155

3154-
if (f2fs_sb_has_blkzoned(sbi) && err && gc_required) {
3156+
if (f2fs_sb_has_blkzoned(sbi) && err == -EAGAIN && gc_required) {
31553157
f2fs_down_write(&sbi->gc_lock);
3156-
f2fs_gc_range(sbi, 0, GET_SEGNO(sbi, FDEV(0).end_blk), true, 1);
3158+
err = f2fs_gc_range(sbi, 0, GET_SEGNO(sbi, FDEV(0).end_blk), true, 1);
31573159
f2fs_up_write(&sbi->gc_lock);
31583160

31593161
gc_required = false;
3160-
goto retry;
3162+
if (!err)
3163+
goto retry;
31613164
}
31623165

31633166
return err;

0 commit comments

Comments
 (0)