Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2967405pxa; Tue, 18 Aug 2020 02:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+ULErJz/vaTLS8jF/VzF8ryrznMYAimVsiAUCflL0MimFIQZGhyXQXrJU/VslYXfYTGi6 X-Received: by 2002:a17:906:660b:: with SMTP id b11mr20304926ejp.509.1597744741933; Tue, 18 Aug 2020 02:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597744741; cv=none; d=google.com; s=arc-20160816; b=UIvkO5wJ4EIW7Sud5tqNRiy9h2IFOB7wB6DMx010BvpOIMtG2FsUFfP3RTaHhCroT5 VRN0V9iNryG5yCUzpu53w0AiobnsNucfrEY7GyvjXhyw52E95SENlaBcCgNc1rB72vjA GVxJVY6FMdhnjNlomoHyYY5/N9TA/no0JOsL+fdaQhaXytjgYOGV6ePfNhHfN/JqAjw3 klPuenZJ841jDkDdAI2EZu8sxo4JZkn4cTN04QCjuF3mb5ikx6pJovfbfJp6fZxfGzqL yTGSDPTw0ChwXzuDIafwtLdB13BMiWhl1gVa81SE4qsBN0iuZTTmKKnk50JyekXKNpHn z1Qw== 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=bLs033Cf2/mJGpTvLPVlFB0f5XmNRv8j2fi6jDDqEvQ=; b=Ny5aSuE6+NG44LVAj7HmcA0hlmzbGv2pq1KzQlA8rqWDxZv3LV68rUZw2Z+7IvspNl WpeSQgqseHjnFxIdq3zZna5v/P/dCoSwhDOt6xeW+TjN8ETJzmWk7ENdY4siDrsCWBWO rhjqnWoJg2oqanqt2jSATI+zLg5ZxgWnGD8/v9E0So0H828wVbuZ1ui8KlFgLbunXOC3 BUAlEtE8dgBg6u5mvlW6UMyjPIqO7rHYvwKf94rQ7L+WJhIIfeoy/QU8gQPveCjhEXMy KZv2J17wRl3r7li0TVq2/XpqFBaQ4GaCnOUpDjvP1z1kTLM7P9I7DzBJRK3vI/08CiFF dWHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=viEDkJie; 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 r29si12971329edx.264.2020.08.18.02.58.37; Tue, 18 Aug 2020 02:59:01 -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=viEDkJie; 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 S1726630AbgHRJz6 (ORCPT + 99 others); Tue, 18 Aug 2020 05:55:58 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:20937 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgHRJz6 (ORCPT ); Tue, 18 Aug 2020 05:55:58 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597744557; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=bLs033Cf2/mJGpTvLPVlFB0f5XmNRv8j2fi6jDDqEvQ=; b=viEDkJieACeljqyPaO1yhxeN0lT4Ta4pHsSd0J7SmgejHdc8PIro3rXCUOQ65j9TsLHClYfY VXAHrfUKlAKl3Kjn34o67dXBR0WwaQGXODVNnnjvZKkw96uHXty8aktO3ZyfzjtsbHltlXT/ uY/702GA54AOxl7yapBUHQ6JK3Y= X-Mailgun-Sending-Ip: 104.130.122.29 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-n08.prod.us-west-2.postgun.com with SMTP id 5f3ba5a91e4d3989d41c8e04 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 18 Aug 2020 09:55:53 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C8352C4339C; Tue, 18 Aug 2020 09:55:53 +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 autolearn=unavailable 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 22F6DC433C6; Tue, 18 Aug 2020 09:55:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 22F6DC433C6 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:25:47 +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: <20200818095547.GA5062@codeaurora.org> References: <1597392335-4998-1-git-send-email-stummala@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. 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.