From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754807AbdKKAvj (ORCPT ); Fri, 10 Nov 2017 19:51:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:37754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754310AbdKKAvi (ORCPT ); Fri, 10 Nov 2017 19:51:38 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 773A6218E3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=chao@kernel.org Subject: Re: [f2fs-dev] [PATCH] f2fs: validate before set/clear free nat bitmap To: LiFan , "'Chao Yu'" , "'Jaegeuk Kim'" Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, chao@kernel.org References: <000101d359f7$77d1aae0$677500a0$@samsung.com> From: Chao Yu Message-ID: <8fc91640-b15a-452b-2bfc-d6603a80c58d@kernel.org> Date: Sat, 11 Nov 2017 08:51:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <000101d359f7$77d1aae0$677500a0$@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/11/10 15:41, LiFan wrote: > In flush_nat_entries, all dirty nats will be flushed and if > their new address isn't NULL_ADDR, their bitmaps will be updated, > the free_nid_count of the bitmaps will be increaced regardless > of whether the nats have already been occupied before. > This could lead to wrong free_nid_count. > So this patch checks the status of the bits beforeactually > set/clear them. Thanks for fixing this. :) Please add: Fixes: 586d1492f301 ("f2fs: skip scanning free nid bitmap of full NAT blocks") > > Signed-off-by: Fan li Reviewed-by: Chao Yu Thanks, > --- > fs/f2fs/node.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index d234c6e..b965a53 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -1906,15 +1906,18 @@ static void update_free_nid_bitmap(struct > f2fs_sb_info *sbi, nid_t nid, > if (!test_bit_le(nat_ofs, nm_i->nat_block_bitmap)) > return; > > - if (set) > + if (set) { > + if (test_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) > + return; > __set_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); > - else > - __clear_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); > - > - if (set) > nm_i->free_nid_count[nat_ofs]++; > - else if (!build) > - nm_i->free_nid_count[nat_ofs]--; > + } else { > + if (!test_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs])) > + return; > + __clear_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]); > + if (!build) > + nm_i->free_nid_count[nat_ofs]--; > + } > } > > static void scan_nat_page(struct f2fs_sb_info *sbi, >