Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399AbdHZLre (ORCPT ); Sat, 26 Aug 2017 07:47:34 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5466 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129AbdHZLrd (ORCPT ); Sat, 26 Aug 2017 07:47:33 -0400 From: Yunlong Song To: , , , , CC: , , , , Subject: [PATCH] f2fs: collect prefree segments to avoild write checkpoint fail Date: Sat, 26 Aug 2017 19:46:59 +0800 Message-ID: <1503748019-152845-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.59A15FD1.0006,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e335f0c5c6269020ec02f1b4e23a70b9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 831 Lines: 29 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 --- 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; } -- 1.8.5.2