From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793AbdJ3Jkl (ORCPT ); Mon, 30 Oct 2017 05:40:41 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9476 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751476AbdJ3Jkj (ORCPT ); Mon, 30 Oct 2017 05:40:39 -0400 Subject: Re: [f2fs-dev] [PATCH] f2fs: optimize __update_nat_bits To: Fan Li , CC: , References: <000e01d3514f$a93addf0$fbb099d0$@samsung.com> From: Chao Yu Message-ID: Date: Mon, 30 Oct 2017 17:39:20 +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: <000e01d3514f$a93addf0$fbb099d0$@samsung.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.0A090205.59F6F385.0247,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: f07559382c89c58015c948b388667e0f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/10/30 15:19, Fan Li wrote: > Make three modification for __update_nat_bits: > 1. Take the codes of dealing the nat with nid 0 out of the loop > Such nat only needs to be dealt with once at beginning. > 2. Use " nat_index == 0" instead of " start_nid == 0" to decide if it's the first nat block > It's better that we don't assume @start_nid is the first nid of the nat block it's in. > 3. Use " if (nat_blk->entries[i].block_addr != NULL_ADDR)" to explicitly comfirm the value of block_addr > use constant to make sure the codes is right, even if the value of NULL_ADDR changes. > > Signed-off-by: Fan li Reviewed-by: Chao Yu Thanks, > --- > fs/f2fs/node.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index ac629d6..b97a031 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -2407,15 +2407,17 @@ static void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid, > unsigned int nat_index = start_nid / NAT_ENTRY_PER_BLOCK; > struct f2fs_nat_block *nat_blk = page_address(page); > int valid = 0; > - int i; > + int i = 0; > > if (!enabled_nat_bits(sbi, NULL)) > return; > > - for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) { > - if (start_nid == 0 && i == 0) > - valid++; > - if (nat_blk->entries[i].block_addr) > + if (nat_index == 0) { > + valid = 1; > + i = 1; > + } > + for (; i < NAT_ENTRY_PER_BLOCK; i++) { > + if (nat_blk->entries[i].block_addr != NULL_ADDR) > valid++; > } > if (valid == 0) { > -- > 2.7.4 > > >