Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp779245pxk; Mon, 31 Aug 2020 00:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSfNg4QaiwY5jCtzv4KmcN1Zu7cq5Xqmq+F00RMm1aLpjGhfYNTX0p4PxwL8dcWagoOHy8 X-Received: by 2002:a17:906:5e15:: with SMTP id n21mr8836156eju.484.1598857403990; Mon, 31 Aug 2020 00:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598857403; cv=none; d=google.com; s=arc-20160816; b=d0a2QWEkPGuVIECGT9DEKDlAPfROj3AppAUxdHsqZlMHSJdy+uLuROLk47V26W7LWO MNOMBQmjBBFZxgOOW4ZP4EaxdwxFG2ysc8Mzyd5sam0Iqx/cb3qtgGcg3Nx5Wfanetpm IN9Lca/acQSkc7s4uSh4zw2wcFS6KNez8d0IWxTPbRkWUmDItGCb1gFAeZHrsQ1i7v0l PCNJrH7u2eDCBCxYvv/ZlMZ4H8djwwOeG1DlavYSves2j+xRAI+SC68eQTNThhaTS+he 3h4Srhxtr0WOirxMb/4e5QY/H9yB9WTLeg89/X35yhQ6949LzVxCLyAh4alTKNGqGl9e edfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=saH70UpwkKhZJqtIzAmxtDvYezf4ZMHIvzRgs9oJ0eY=; b=rFsPH5UI5NHHLgqKpkLqiN70Ge0USQYbPCZQMJly72D9MiSD3LkWzP8XNrdp24JbHw R6TrNigT6ucSODr3+02f9aANhDbtJv3jrXqCyldKmeZXBZTJJrOUzymWruP+nOfBNDsw CMsgjS4dZSxplNf7ZMDqMGyL24ee2IkADbATAoa9ffc2v9qWJwxYWXqAoEdpaD95XLIy pshZxgX29uVNjxjf14qHXY9aZRiQ297fBiysyJi2FmuThHIZ5FFmb5rnFXS/VoId+3sV QNg/wl7wGMC1thSusk7w6jwQS4glzvTX49/Vqcg2FZ4Mz3RQJMzLp7knlAa8QIZ83XRD A2ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn2si4643472edb.378.2020.08.31.00.03.00; Mon, 31 Aug 2020 00:03:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727910AbgHaG7g (ORCPT + 99 others); Mon, 31 Aug 2020 02:59:36 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10739 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727799AbgHaG7c (ORCPT ); Mon, 31 Aug 2020 02:59:32 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 83A81744CE870CABDBC1; Mon, 31 Aug 2020 14:59:28 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.201) with Microsoft SMTP Server (TLS) id 14.3.487.0; Mon, 31 Aug 2020 14:59:27 +0800 Subject: Re: [PATCH v2 5/5] f2fs: support age threshold based garbage collection To: Jaegeuk Kim CC: , , References: <20200804131449.50517-1-yuchao0@huawei.com> <20200804131449.50517-6-yuchao0@huawei.com> <20200825193404.GA2614120@google.com> From: Chao Yu Message-ID: <7986af8c-1fe9-7140-f1c0-d8b4a58f702c@huawei.com> Date: Mon, 31 Aug 2020 14:59:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200825193404.GA2614120@google.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.114.67] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaegeuk, I've changed code a bit to fix some bugs, including: - gc_idle = 3 (GC_IDLE_AT) description - disallow set gc_idle to 3 if atgc is off - keep compatibility with checkpoint disabling Could you please check and merge below diff? From: Chao Yu Signed-off-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-f2fs | 3 ++- fs/f2fs/gc.c | 12 +++++++++++- fs/f2fs/sysfs.c | 11 ++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 7f730c4c8df2..834d0becae6d 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -22,7 +22,8 @@ Contact: "Namjae Jeon" Description: Controls the victim selection policy for garbage collection. Setting gc_idle = 0(default) will disable this option. Setting gc_idle = 1 will select the Cost Benefit approach & setting - gc_idle = 2 will select the greedy approach. + gc_idle = 2 will select the greedy approach & setting + gc_idle = 3 will select the age-threshold based approach. What: /sys/fs/f2fs//reclaim_segments Date: October 2013 diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 6413886e52d4..3c0edb8b4cc5 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -388,6 +388,16 @@ static void add_victim_entry(struct f2fs_sb_info *sbi, unsigned long long mtime = 0; unsigned int i; + if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { + if (p->gc_mode == GC_AT && + get_valid_blocks(sbi, segno, true) == 0) + return; + + if (p->alloc_mode == AT_SSR && + get_seg_entry(sbi, segno)->ckpt_valid_blocks == 0) + return; + } + for (i = 0; i < sbi->segs_per_sec; i++) mtime += get_seg_entry(sbi, start + i)->mtime; mtime = div_u64(mtime, sbi->segs_per_sec); @@ -721,7 +731,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi, /* Don't touch checkpointed data */ if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED) && get_ckpt_valid_blocks(sbi, segno) && - p.alloc_mode != SSR)) + p.alloc_mode == LFS)) goto next; if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap)) goto next; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 88ed9969cc86..bacfa9c35e6b 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -375,12 +375,17 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } if (!strcmp(a->attr.name, "gc_idle")) { - if (t == GC_IDLE_CB) + if (t == GC_IDLE_CB) { sbi->gc_mode = GC_IDLE_CB; - else if (t == GC_IDLE_GREEDY) + } else if (t == GC_IDLE_GREEDY) { sbi->gc_mode = GC_IDLE_GREEDY; - else + } else if (t == GC_IDLE_AT) { + if (!sbi->am.atgc_enabled) + return -EINVAL; + sbi->gc_mode = GC_AT; + } else { sbi->gc_mode = GC_NORMAL; + } return count; } -- 2.26.2