diff mbox

f2fs: collect prefree segments to avoild write checkpoint fail

Message ID 1503748019-152845-1-git-send-email-yunlong.song@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yunlong Song Aug. 26, 2017, 11:46 a.m. UTC
In come corner case, the reserved segments are used to do gc, and there are
not enough free segments for write checkpoint to finish its job, then the
gc process will fail to change the prefree segments to free segments.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/gc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Chao Yu Aug. 28, 2017, 9:52 a.m. UTC | #1
Hi Yunlong,

On 2017/8/26 19:46, Yunlong Song wrote:
> In come corner case, the reserved segments are used to do gc, and there are
> not enough free segments for write checkpoint to finish its job, then the
> gc process will fail to change the prefree segments to free segments.

How about doing investigate that why we haven't enough free segment for GC?

Thanks,

> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>  fs/f2fs/gc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index cd147e7..c8a828f 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -1056,6 +1056,13 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
>  	if (!sync) {
>  		if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
>  			segno = NULL_SEGNO;
> +			if (prefree_segments(sbi) &&
> +				has_not_enough_free_secs(sbi,
> +					reserved_sections(sbi), 0)) {
> +				ret = write_checkpoint(sbi, &cpc);
> +				if (ret)
> +					goto stop;
> +			}
>  			goto gc_more;
>  		}
>  
>
diff mbox

Patch

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index cd147e7..c8a828f 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1056,6 +1056,13 @@  int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
 	if (!sync) {
 		if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
 			segno = NULL_SEGNO;
+			if (prefree_segments(sbi) &&
+				has_not_enough_free_secs(sbi,
+					reserved_sections(sbi), 0)) {
+				ret = write_checkpoint(sbi, &cpc);
+				if (ret)
+					goto stop;
+			}
 			goto gc_more;
 		}