From patchwork Wed Oct 11 13:25:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunlong Song X-Patchwork-Id: 9999623 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 C6376602BF for ; Wed, 11 Oct 2017 13:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8CA228A1E for ; Wed, 11 Oct 2017 13:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD09C28A1A; Wed, 11 Oct 2017 13:25:52 +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 2237728A1A for ; Wed, 11 Oct 2017 13:25:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757274AbdJKNZh (ORCPT ); Wed, 11 Oct 2017 09:25:37 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8001 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752100AbdJKNZg (ORCPT ); Wed, 11 Oct 2017 09:25:36 -0400 Received: from 172.30.72.58 (EHLO DGGEMS405-HUB.china.huawei.com) ([172.30.72.58]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIY05531; Wed, 11 Oct 2017 21:25:33 +0800 (CST) Received: from huawei.com (10.107.193.250) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.301.0; Wed, 11 Oct 2017 21:25:24 +0800 From: Yunlong Song To: , , , , CC: , , , , Subject: [PATCH] f2fs: update dirty status for CURSEG as well Date: Wed, 11 Oct 2017 21:25:18 +0800 Message-ID: <1507728318-113117-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 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.0A020203.59DE1BCE.002F, 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: 5f1a4f439766378f70923c96dc5546de 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 Without this patch, it will cause all the free segments using up in some corner case. For example, there are 100 segments, and 20 of them are reserved for ovp. If 79 segments are full of data, segment 80 becomes CURSEG segment, write 512 blocks and then delete 511 blocks. Since it is CURSEG segment, the __locate_dirty_segment will not update its dirty status. Then the dirty_segments(sbi) is 0, f2fs_gc will fail to get_victim, and f2fs_balance_fs will fail to trigger gc action. After f2fs_balance_fs returns, f2fs can continue to write data to segment 81. Again, segment 81 becomes CURSEG segment, write 512 blocks and delete 511 blocks, the dirty_segments(sbi) is 0 and f2fs_gc fail again. This can finally use up all the free segments and cause panic. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index bfbcff8..0ff52d5 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -686,10 +686,6 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); - /* need not be added */ - if (IS_CURSEG(sbi, segno)) - return; - if (!test_and_set_bit(segno, dirty_i->dirty_segmap[dirty_type])) dirty_i->nr_dirty[dirty_type]++;