Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp297390ima; Wed, 24 Oct 2018 01:09:39 -0700 (PDT) X-Google-Smtp-Source: AJdET5fkxynHAAxT6JnQ1rMK4l9PjEYbfHy2D0EH/HNNFUVP+mX2jUPG6f4uF1BsV3noON8EXPZ+ X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr1578886plc.323.1540368579439; Wed, 24 Oct 2018 01:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540368579; cv=none; d=google.com; s=arc-20160816; b=LMEwtq/iiWuzsK9tGkn4a7TOCvmveZLF22PwhmEzVnrKcPX6jxXVc/ZitvqXJZVd6N ROu/KoQfrxE67kH3QZ5f5qvjTEEsZz1AJJ2yGf1nTk+f29whTh8w9yKtJpNLD0PVPNrw lMA3ol2spEIF80BDqT7w5lY+CDMKa2nATJiGFfb5+eHf7pfexKwqN1NYj7iMUnAMSczR 8fEls64dDhfLispR50+QO5L9BIY8b0LBHw21cTcr7oDGQy91qQkfQwZDxhV6s8ENfVxO VBvrB7oHOoyZVwsT1a/AYQGRLCSi4QnSX+6X60muKwpJixbDTN73DsUKalm2hpgMSNeo Bdpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=vBT76zZqe4W4U9b3Ou+IksZiUlM/0iPWplh9B5XH24s=; b=zJwBfUQbr748Q6ugAd+s1Zior7WBOkSqNsqwir7Gpn4Xy5CKjfy4RmN6L0qiLzdMwl giUJ1pJ9ORBAWvg285Icd/WViYfbOCwK9ZwLxIOqZi/oak9InACkqSHU9dyD5o/VWp2n nUdn0EtbLHuTU1ZXXSiCsaaic1FlpmTjViMRnUrWno9rVe8GYWtayHTdyityYvB/MHda 288nW82Y1L+6lc3sb+vqJ5AZRA9UjDw/mpipVLhuJxnw7mIVGeIrS/3wYWzx7jVly6xy co4gPFmb8XghLzcQGrVqfOAxSApKSwSs90q5c7aP0hazXogebP+VEqt0PbCDzO2THIaS AXMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v128-v6si4292107pfc.193.2018.10.24.01.09.24; Wed, 24 Oct 2018 01:09:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727613AbeJXQf6 (ORCPT + 99 others); Wed, 24 Oct 2018 12:35:58 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56618 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727512AbeJXQf6 (ORCPT ); Wed, 24 Oct 2018 12:35:58 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7CEFBCEA933F0; Wed, 24 Oct 2018 16:08:53 +0800 (CST) Received: from huawei.com (10.113.189.234) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.408.0; Wed, 24 Oct 2018 16:08:45 +0800 From: Yunlong Song To: , , , , CC: , , , , , Subject: [PATCH v2] f2fs: fix count of seg_freed to make sec_freed correct Date: Wed, 24 Oct 2018 16:08:30 +0800 Message-ID: <1540368510-14270-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1539168739-79848-1-git-send-email-yunlong.song@huawei.com> References: <1539168739-79848-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.113.189.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When sbi->segs_per_sec > 1, and if some segno has 0 valid blocks before gc starts, do_garbage_collect will skip counting seg_freed++, and this will cause seg_freed < sbi->segs_per_sec and finally skip sec_freed++. Signed-off-by: Yunlong Song Signed-off-by: Chao Yu --- fs/f2fs/gc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index a07241f..57841e9 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1130,9 +1130,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, GET_SUM_BLOCK(sbi, segno)); f2fs_put_page(sum_page, 0); - if (get_valid_blocks(sbi, segno, false) == 0 || - !PageUptodate(sum_page) || - unlikely(f2fs_cp_error(sbi))) + if (get_valid_blocks(sbi, segno, false) == 0) + goto freed; + if (!PageUptodate(sum_page) || unlikely(f2fs_cp_error(sbi))) goto next; sum = page_address(sum_page); @@ -1160,6 +1160,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, stat_inc_seg_count(sbi, type, gc_type); +freed: if (gc_type == FG_GC && get_valid_blocks(sbi, segno, false) == 0) seg_freed++; -- 1.8.5.2