f2fs: make sure f2fs_gc returns consistent errno
PATCH 1/1 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.
--- fs/f2fs/gc.c | 3 +++ 1 file changed, 3 insertions(+)
fs/f2fs/gc.c +3 -0
@@ -965,6 +965,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, cpc.reason =__get_cp_reason (sbi); gc_more: + ret = -EINVAL ;if (unlikely (!(sbi->sb->s_flags &MS_ACTIVE ))) goto stop;if (unlikely (f2fs_cp_error (sbi))) {
@@ -982,6 +983,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, ret =write_checkpoint (sbi, &cpc);if (ret) goto stop; +else + ret = -EINVAL ; }if (has_not_enough_free_secs (sbi,0 ,0 )) gc_type =FG_GC ;
Signature · 6 lines
2.10.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Chao Yu
maintainerQuoted 3 lines · Weichao Guo
By default,
f2fs_gcreturns-EINVALin general error cases, e.g., no victim was selected. However, the default errno may be overwritten in two cases:gc_moreandBG_GC->FG_GC. We should return consistent errno in such cases.
How about clean up this patch as below, which always set return value before jumping to 'stop' tag.
fs/f2fs/gc.c +5 -2
@@ -957,7 +957,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 = {
@@ -967,8 +967,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;
@@ -989,6 +991,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;
Thanks,
Quoted 20 lines
Signed-off-by Weichao Guo <[email protected]>--- fs/f2fs/gc.c | 3 +++ 1 file changed, 3 insertions(+)fs/f2fs/gc.c +1
-0@@ -965,6 +965,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, cpc.reason =__get_cp_reason (sbi); gc_more: + ret = -EINVAL ;if (unlikely (!(sbi->sb->s_flags &MS_ACTIVE ))) goto stop;if (unlikely (f2fs_cp_error (sbi))) {
fs/f2fs/gc.c int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, · line 990
Quoted 8 lines
fs/f2fs/gc.c +2
-0@@ -982,6 +983,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, ret =write_checkpoint (sbi, &cpc);if (ret) goto stop; +else + ret = -EINVAL ; }if (has_not_enough_free_secs (sbi,0 ,0 )) gc_type =FG_GC ;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Agree, I will send a new verison of this patch.
-----邮件原件-----
发件人: Chao Yu [mailto:[email protected]]
发送时间: 2017年5月9日 23:26
收件人: guoweichao; [email protected]
抄送: [email protected]
主题: Re: [f2fs-dev] [PATCH] f2fs: make sure f2fs_gc returns consistent errno
Quoted 3 lines · Weichao Guo
By default,
f2fs_gcreturns-EINVALin general error cases, e.g., no victim was selected. However, the default errno may be overwritten in two cases:gc_moreandBG_GC->FG_GC. We should return consistent errno in such cases.
How about clean up this patch as below, which always set return value before jumping to 'stop' tag.
fs/f2fs/gc.c +5 -2
@@ -957,7 +957,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 = {
@@ -967,8 +967,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;
@@ -989,6 +991,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;
Thanks,
Quoted 19 lines
Signed-off-by Weichao Guo <[email protected]>--- fs/f2fs/gc.c | 3 +++ 1 file changed, 3 insertions(+)fs/f2fs/gc.c +1
-0@@ -965,6 +965,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, cpc.reason =__get_cp_reason (sbi); gc_more: + ret = -EINVAL ;if (unlikely (!(sbi->sb->s_flags &MS_ACTIVE ))) goto stop;if (unlikely (f2fs_cp_error (sbi))) {
fs/f2fs/gc.c int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, · line 990
Quoted 8 lines
fs/f2fs/gc.c +2
-0@@ -982,6 +983,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, ret =write_checkpoint (sbi, &cpc);if (ret) goto stop; +else + ret = -EINVAL ; }if (has_not_enough_free_secs (sbi,0 ,0 )) gc_type =FG_GC ;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel