From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbdJXIZl (ORCPT ); Tue, 24 Oct 2017 04:25:41 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8979 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751723AbdJXIZd (ORCPT ); Tue, 24 Oct 2017 04:25:33 -0400 Subject: Re: [PATCH v2 6/6] f2fs: give up CP_TRIMMED_FLAG if it drops discards To: CC: Chao Yu , , References: <20171004010837.9809-1-chao@kernel.org> <20171004010837.9809-6-chao@kernel.org> From: Chao Yu Message-ID: <20280b72-f2c1-7a43-ebd4-9c5fbac725a9@huawei.com> Date: Tue, 24 Oct 2017 16:24:22 +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: <20171004010837.9809-6-chao@kernel.org> 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.0A090205.59EEF8F7.0032,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: beb90d6a50f6b84269c1241fb37af67d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaegeuk, On 2017/10/4 9:08, Chao Yu wrote: > From: Chao Yu > > In ->umount, once we drop remained discard entries, we should not > set CP_TRIMMED_FLAG with another checkpoint. > > Signed-off-by: Chao Yu > --- > v2: > - rebase on last codes of Jaegeuk's dev-test branch. > fs/f2fs/f2fs.h | 2 +- > fs/f2fs/segment.c | 15 +++++++++++---- > fs/f2fs/super.c | 5 +++-- > 3 files changed, 15 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index f274805e231d..c85f49c41003 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -2565,7 +2565,7 @@ void init_discard_policy(struct discard_policy *dpolicy, int discard_type, > unsigned int granularity); > void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new); > void stop_discard_thread(struct f2fs_sb_info *sbi); > -void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi); > +bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi); > void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc); > void release_discard_addrs(struct f2fs_sb_info *sbi); > int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra); > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 4a108321233d..bfbcff8339c5 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -1196,12 +1196,13 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, > return issued; > } > > -static void __drop_discard_cmd(struct f2fs_sb_info *sbi) > +static bool __drop_discard_cmd(struct f2fs_sb_info *sbi) > { > struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; > struct list_head *pend_list; > struct discard_cmd *dc, *tmp; > int i; > + bool dropped = false; > > mutex_lock(&dcc->cmd_lock); > for (i = MAX_PLIST_NUM - 1; i >= 0; i--) { > @@ -1209,9 +1210,12 @@ static void __drop_discard_cmd(struct f2fs_sb_info *sbi) > list_for_each_entry_safe(dc, tmp, pend_list, list) { > f2fs_bug_on(sbi, dc->state != D_PREP); > __remove_discard_cmd(sbi, dc); > + dropped = true; > } > } > mutex_unlock(&dcc->cmd_lock); > + > + return dropped; > } > > static void __wait_one_discard_bio(struct f2fs_sb_info *sbi, > @@ -1306,15 +1310,18 @@ void stop_discard_thread(struct f2fs_sb_info *sbi) > } > > /* This comes from f2fs_put_super */ > -void f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) > +bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi) > { > struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; > struct discard_policy dpolicy; > + bool dropped; > > init_discard_policy(&dpolicy, DPOLICY_UMOUNT, dcc->discard_granularity); > __issue_discard_cmd(sbi, &dpolicy); > - __drop_discard_cmd(sbi); > + dropped = __drop_discard_cmd(sbi); > __wait_all_discard_cmd(sbi, &dpolicy); > + > + return dropped; > } > > static int issue_discard_thread(void *data) > @@ -1659,7 +1666,7 @@ void init_discard_policy(struct discard_policy *dpolicy, > dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME; > dpolicy->max_requests = DEF_MAX_DISCARD_REQUEST; > dpolicy->io_aware_gran = MAX_PLIST_NUM; > - dpolicy->io_aware = false; > + dpolicy->io_aware = true; I notice this change should not belong to this patch, could you please help to move this into "f2fs: split discard policy" in your branch? Thanks, > } else if (discard_type == DPOLICY_FSTRIM) { > dpolicy->max_requests = DEF_MAX_DISCARD_REQUEST; > dpolicy->io_aware_gran = MAX_PLIST_NUM; > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index a13269d1a1f0..1d68c18a487b 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -807,6 +807,7 @@ static void f2fs_put_super(struct super_block *sb) > { > struct f2fs_sb_info *sbi = F2FS_SB(sb); > int i; > + bool dropped; > > f2fs_quota_off_umount(sb); > > @@ -827,9 +828,9 @@ static void f2fs_put_super(struct super_block *sb) > } > > /* be sure to wait for any on-going discard commands */ > - f2fs_wait_discard_bios(sbi, true); > + dropped = f2fs_wait_discard_bios(sbi); > > - if (f2fs_discard_en(sbi) && !sbi->discard_blks) { > + if (f2fs_discard_en(sbi) && !sbi->discard_blks && !dropped) { > struct cp_control cpc = { > .reason = CP_UMOUNT | CP_TRIMMED, > }; >