Skip to content

Commit 28f66cc

Browse files
Zhiguo NiuJaegeuk Kim
authored andcommitted
f2fs: fix to check return value __allocate_new_segment
__allocate_new_segment may return error when get_new_segment fails, so its caller should check its return value. Signed-off-by: Zhiguo Niu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 36959d1 commit 28f66cc

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

fs/f2fs/f2fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,7 @@ void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type,
37053705
unsigned int start, unsigned int end);
37063706
int f2fs_allocate_new_section(struct f2fs_sb_info *sbi, int type, bool force);
37073707
int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi);
3708-
void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi);
3708+
int f2fs_allocate_new_segments(struct f2fs_sb_info *sbi);
37093709
int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range);
37103710
bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,
37113711
struct cp_control *cpc);

fs/f2fs/recovery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
851851
f2fs_ra_meta_pages_cond(sbi, blkaddr, ra_blocks);
852852
}
853853
if (!err)
854-
f2fs_allocate_new_segments(sbi);
854+
err = f2fs_allocate_new_segments(sbi);
855855
return err;
856856
}
857857

fs/f2fs/segment.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,16 +3163,19 @@ int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi)
31633163
return err;
31643164
}
31653165

3166-
void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)
3166+
int f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)
31673167
{
31683168
int i;
3169+
int err = 0;
31693170

31703171
f2fs_down_read(&SM_I(sbi)->curseg_lock);
31713172
down_write(&SIT_I(sbi)->sentry_lock);
31723173
for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++)
3173-
__allocate_new_segment(sbi, i, false, false);
3174+
err += __allocate_new_segment(sbi, i, false, false);
31743175
up_write(&SIT_I(sbi)->sentry_lock);
31753176
f2fs_up_read(&SM_I(sbi)->curseg_lock);
3177+
3178+
return err;
31763179
}
31773180

31783181
bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,

0 commit comments

Comments
 (0)