From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762426AbdADB5g (ORCPT ); Tue, 3 Jan 2017 20:57:36 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:50827 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbdADB52 (ORCPT ); Tue, 3 Jan 2017 20:57:28 -0500 Subject: Re: [PATCH] f2fs: fix small discards when se->valid_blocks is zero To: Yunlong Song , , , , References: <1483434117-24427-1-git-send-email-yunlong.song@huawei.com> CC: , , , From: Chao Yu Message-ID: <72699809-4316-0390-a09b-eb5d5fc70981@huawei.com> Date: Wed, 4 Jan 2017 09:54:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1483434117-24427-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset="windows-1252" 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.586C55E2.000B,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c10d84bd39c0a0191e188a30e3837c97 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/1/3 17:01, Yunlong Song wrote: > In the small discard case, when se->valid_blocks is zero, the add_discard_addrs > will directly return without __add_discard_entry. This will cause the file > delete have no small discard. The case is like this: > > 1. Allocate free 2M segment > 2. Write a file (size n blocks < 512) in that 2M segment, se->valid_blocks = n > 3. Delete that file, se->valid_blocks = 0, add_discard_addrs will return without > sending any discard of that file, and forever due to cur_map[i] ^ ckpt_map[i] = > 0 after that checkpoint Wouldn't it be discarded as prefree segment? Thanks, > > Signed-off-by: Yunlong Song > --- > fs/f2fs/segment.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 0738f48..8610f14 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -838,7 +838,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) > return; > > if (!force) { > - if (!test_opt(sbi, DISCARD) || !se->valid_blocks || > + if (!test_opt(sbi, DISCARD) || > SM_I(sbi)->nr_discards >= SM_I(sbi)->max_discards) > return; > } >