mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
f2fs: make sure f2fs_gc returns consistent errno
By default, f2fs_gc returns -EINVAL in general error cases, e.g., no victim was selected. However, the default errno may be overwritten in two cases: gc_more and BG_GC -> FG_GC. We should return consistent errno in such cases. Signed-off-by: Weichao Guo <guoweichao@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
1c6d8ee4b8
commit
e5dbd9563e
1 changed files with 5 additions and 2 deletions
|
@ -955,7 +955,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
|
|||
{
|
||||
int gc_type = sync ? FG_GC : BG_GC;
|
||||
int sec_freed = 0;
|
||||
int ret = -EINVAL;
|
||||
int ret;
|
||||
struct cp_control cpc;
|
||||
unsigned int init_segno = segno;
|
||||
struct gc_inode_list gc_list = {
|
||||
|
@ -965,8 +965,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
|
|||
|
||||
cpc.reason = __get_cp_reason(sbi);
|
||||
gc_more:
|
||||
if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE)))
|
||||
if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE))) {
|
||||
ret = -EINVAL;
|
||||
goto stop;
|
||||
}
|
||||
if (unlikely(f2fs_cp_error(sbi))) {
|
||||
ret = -EIO;
|
||||
goto stop;
|
||||
|
@ -987,6 +989,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
|
|||
gc_type = FG_GC;
|
||||
}
|
||||
|
||||
ret = -EINVAL;
|
||||
/* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
|
||||
if (gc_type == BG_GC && !background)
|
||||
goto stop;
|
||||
|
|
Loading…
Reference in a new issue