From: Chao Yu Subject: Re: [PATCH] f2fs: fix a mount fail for wrong next_scan_nid Date: Wed, 3 May 2017 14:26:50 +0800 Message-ID: <7822ea80-3064-0b8e-e3f0-ce5e16217c05@huawei.com> References: <20170426075652.4249-1-heyunlei@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1d5nlO-0004bA-OZ for linux-f2fs-devel@lists.sourceforge.net; Wed, 03 May 2017 06:27:50 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1d5nlL-0002QP-Ti for linux-f2fs-devel@lists.sourceforge.net; Wed, 03 May 2017 06:27:50 +0000 In-Reply-To: <20170426075652.4249-1-heyunlei@huawei.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Yunlei He , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net Hi all, On 2017/4/26 15:56, Yunlei He wrote: > -write_checkpoint > -do_checkpoint > -next_free_nid <--- something wrong with next free nid Since we have figured out how next_scan_nid can be changed to a wrong value, so how about add a bug_on here to detect potential issue for further fixing? Thanks, > > -f2fs_fill_super > -build_node_manager > -build_free_nids > -get_current_nat_page > -__get_meta_page <--- attempt to access beyond end of device > > Signed-off-by: Yunlei He > --- > fs/f2fs/node.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index b99e318..98351a4 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -1955,6 +1955,9 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount) > int i = 0; > nid_t nid = nm_i->next_scan_nid; > > + if (unlikely(nid >= nm_i->max_nid)) > + nid = 0; > + > /* Enough entries */ > if (nm_i->nid_cnt[FREE_NID_LIST] >= NAT_ENTRY_PER_BLOCK) > return; > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot