From patchwork Fri Sep 1 12:00:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunlong Song X-Patchwork-Id: 9934019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0DE460309 for ; Fri, 1 Sep 2017 12:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9839827FA5 for ; Fri, 1 Sep 2017 12:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B8BA285B3; Fri, 1 Sep 2017 12:00:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F41B27FA5 for ; Fri, 1 Sep 2017 12:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751778AbdIAMAi (ORCPT ); Fri, 1 Sep 2017 08:00:38 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5508 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751540AbdIAMAh (ORCPT ); Fri, 1 Sep 2017 08:00:37 -0400 Received: from 172.30.72.59 (EHLO DGGEMS409-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DGI30923; Fri, 01 Sep 2017 20:00:35 +0800 (CST) Received: from huawei.com (10.107.193.250) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.301.0; Fri, 1 Sep 2017 20:00:25 +0800 From: Yunlong Song To: , , , , CC: , , , , Subject: [PATCH v2] f2fs: collect prefree segments to avoild write checkpoint fail Date: Fri, 1 Sep 2017 20:00:19 +0800 Message-ID: <1504267219-76575-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1503748019-152845-1-git-send-email-yunlong.song@huawei.com> References: <1503748019-152845-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.59A94BE3.0327, 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: 0f400943ea5fa1f267ae902357ccbbd9 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index cd147e7..6552b04 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1056,6 +1056,16 @@ 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; +#ifndef CONFIG_F2FS_CHECK_FS + if (prefree_segments(sbi) && + has_not_enough_free_secs(sbi, + reserved_sections(sbi), 0)) { + ret = write_checkpoint(sbi, &cpc); + if (ret) + goto stop; + sec_freed = 0; + } +#endif goto gc_more; }