Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751811AbdH2KHM (ORCPT ); Tue, 29 Aug 2017 06:07:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5035 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbdH2KHK (ORCPT ); Tue, 29 Aug 2017 06:07:10 -0400 Subject: Re: [PATCH] f2fs: discard small invalid blocks in current active segments To: Yunlong Song , , , CC: , , , , References: <1503751772-158812-1-git-send-email-yunlong.song@huawei.com> <61d97244-c4e5-0008-ab30-fc52a05e0b24@huawei.com> From: Chao Yu Message-ID: <7e72a04f-b50a-9596-a818-c9e31168f29f@huawei.com> Date: Tue, 29 Aug 2017 18:06:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <61d97244-c4e5-0008-ab30-fc52a05e0b24@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.59A53CC5.0016,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: 15448908f034fea056a27799911d6ef6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1720 Lines: 51 On 2017/8/28 21:21, Yunlong Song wrote: > How? Can the invalid blocks of file A be discarded, if file B is alive > all the time and fggc_threshold is 507 ? As I traced, with small discard, we scan discard candidates from all dirty segments which also include current segment, so seems we don't need to wait log header moving on. Thanks, > > On 2017/8/28 17:59, Chao Yu wrote: >> On 2017/8/26 20:49, Yunlong Song wrote: >>> 1. write file A with 5 blocks to current empty active segment >>> 2. remove file A >>> 3. write checkpoint >>> 4. write file B with 507 blocks to the same active segment >>> >>> If file B is alive all the time, the blocks used by file A will never be >>> discarded. So current active segment should also be treated as a candidate >>> for small discards. >> I don't think that would be a big issue, since there will not be any freezing >> log headers, once log header moves, later invalid blocks could be discarded. >> >> Thanks, >> >>> Signed-off-by: Yunlong Song >>> --- >>> fs/f2fs/segment.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index 8375257..a2e7c8f 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -1339,7 +1339,9 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc, >>> return false; >>> >>> if (!force) { >>> - if (!test_opt(sbi, DISCARD) || !se->valid_blocks || >>> + if (!test_opt(sbi, DISCARD) || >>> + (!se->valid_blocks && >>> + !IS_CURSEG(sbi, cpc->trim_start)) || >>> SM_I(sbi)->dcc_info->nr_discards >= >>> SM_I(sbi)->dcc_info->max_discards) >>> return false; >>> >> >> . >> >