Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2971786pxa; Tue, 18 Aug 2020 03:06:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcYXRNMxbnGy6cbODOiXdhgb/pslGuyl4eEdybmXAYnucNS3X39pbvrp9h5B2SvoC4Qs3O X-Received: by 2002:a17:907:398:: with SMTP id ss24mr18489222ejb.311.1597745195632; Tue, 18 Aug 2020 03:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597745195; cv=none; d=google.com; s=arc-20160816; b=F0pwXR1C36o2S+3PFxEG6VOuDhc+99xq4l7Vg/oFelW1m+BYGwm2QlSdH+uk0o4GBC mSQ0j4edwITkrY6F/AlVSUjBRqqFLdVsEscpx17IfWEtV7gnZoF0pDj7IjP4vP+GJZrV M4JSxrtBERmAcq1PECXXq060xq/E7+T5E1nkB6WlW04vXyYBWmmH+t+e26Hh0cXopq+m VCTa7XRRaRvl56GMG2vJHMY8ZiHirgm9wwJsgkmsIw9NIz4MDFx/TK9ZUXENIbA5CN+g wLeCzCd3KUVYejeXO31/JXaKjx05jSOsHCvlIh9C5nvl3pfdvPxhxgWDK5B8nIH5+O61 35Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature; bh=T1CCGquylX71KDdCAwA2iJHahtHl1/4eQuBxd7BGCEw=; b=yjv9V4xFAatwp0COZCPQBkpKNq2I1rZ6CaxaOrjXxHxSAQgLdidfgxcso96gL5cxh2 mFoPCPyT6OkNjdJVLi2cPX+fGl3HTnE74C49hj/8ug32SJ7ZukyynyRRoGhblJlLz/Em Mj7MpMJ8IT8g29MVRldObu7kEZ1bKN/nlYsJtMEVGDR0k8gGobGiGJVa+NvYDNM1+Y+b ZuUgUBbQUgTI8si2h3kdKnUDIwZNJrSndA6W1oYI+INr4L2s9c65xltlDZlqRWQ/EVga PZmneDRveSud2M2MJaUvpDL8ecVcvRI1Bv3zufshQE/seb2KI2lr41ijOBrvCutOzgjR zGHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=Ryao98Z2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e24si12442296eds.212.2020.08.18.03.06.12; Tue, 18 Aug 2020 03:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=Ryao98Z2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726684AbgHRKFI (ORCPT + 99 others); Tue, 18 Aug 2020 06:05:08 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:45202 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgHRKFH (ORCPT ); Tue, 18 Aug 2020 06:05:07 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597745107; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=T1CCGquylX71KDdCAwA2iJHahtHl1/4eQuBxd7BGCEw=; b=Ryao98Z27uF+QR4rZM0/4Rr9IZRghu47p6EMbX3z72dqxJ0PsAcu6Kzg6EgEKJIxuPrYp7Uv mcyMXLH4zEpefKKj5Fo4EQ1JFvv3J8KLPb2Cx3nPvh/CfSwaHvLsGFHTo6nJCgGAQocTI6YX iZ/whtzj2EAuxZM98E1tJx/hYwY= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n10.prod.us-west-2.postgun.com with SMTP id 5f3ba7b51e4d3989d41f4651 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 18 Aug 2020 10:04:37 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4B65FC433CA; Tue, 18 Aug 2020 10:04:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from codeaurora.org (unknown [202.46.22.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: stummala) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3B6E7C433C6; Tue, 18 Aug 2020 10:04:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3B6E7C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=stummala@codeaurora.org Date: Tue, 18 Aug 2020 15:34:31 +0530 From: Sahitya Tummala To: Chao Yu Cc: Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, stummala@codeaurora.org Subject: Re: [PATCH] f2fs: fix indefinite loop scanning for free nid Message-ID: <20200818100431.GB5062@codeaurora.org> References: <1597392335-4998-1-git-send-email-stummala@codeaurora.org> <20200818095547.GA5062@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200818095547.GA5062@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 18, 2020 at 03:25:47PM +0530, Sahitya Tummala wrote: > On Tue, Aug 18, 2020 at 04:29:05PM +0800, Chao Yu wrote: > > On 2020/8/14 16:05, Sahitya Tummala wrote: > > >If the sbi->ckpt->next_free_nid is not NAT block aligned and if there > > >are free nids in that NAT block between the start of the block and > > >next_free_nid, then those free nids will not be scanned in scan_nat_page(). > > >This results into mismatch between nm_i->available_nids and the sum of > > >nm_i->free_nid_count of all NAT blocks scanned. And nm_i->available_nids > > >will always be greater than the sum of free nids in all the blocks. > > >Under this condition, if we use all the currently scanned free nids, > > >then it will loop forever in f2fs_alloc_nid() as nm_i->available_nids > > >is still not zero but nm_i->free_nid_count of that partially scanned > > >NAT block is zero. > > > > > >Fix this to align the nm_i->next_scan_nid to the first nid of the > > >corresponding NAT block. > > > > > >Signed-off-by: Sahitya Tummala > > >--- > > > fs/f2fs/node.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > >diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > > >index 9bbaa26..d615e59 100644 > > >--- a/fs/f2fs/node.c > > >+++ b/fs/f2fs/node.c > > >@@ -2402,6 +2402,8 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi, > > > if (IS_ERR(page)) { > > > ret = PTR_ERR(page); > > > } else { > > >+ if (nid % NAT_ENTRY_PER_BLOCK) > > >+ nid = NAT_BLOCK_OFFSET(nid) * NAT_ENTRY_PER_BLOCK; > > > > How about moving this logic to the beginning of __f2fs_build_free_nids(), > > after nid reset? > > > > Sure, I will move it. > > > BTW, it looks we can add unlikely in this judgment condition? > > But it may not be an unlikely as it can happen whenever checkpoint is done, > based on the next available free nid in function next_free_nid(), which can happen > quite a few times, right? > > Hitting the loop forever issue condition due to this could be a rare/difficult to > reproduce but this check itself may not be unlikely in my opinion. > Sorry, I was wrong above. During CP we update only ckpt->next_free_nid but not the nm_i->next_free_nid, which is done only once during boot up. So yes, I will mark it as unlikely conditiona. Thanks, > Thanks, > > > > > Thanks, > > > > > ret = scan_nat_page(sbi, page, nid); > > > f2fs_put_page(page, 1); > > > } > > > > > -- > -- > Sent by a consultant of the Qualcomm Innovation Center, Inc. > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. -- -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.