Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4907273ybi; Tue, 30 Jul 2019 10:12:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRNnk7uw2p9Cr4h5HCuM/yZq+CIHE3UI22RFmh0BxphI15PG+hnhbdJj6k7nUlCnxvHElu X-Received: by 2002:a17:902:2f84:: with SMTP id t4mr112620187plb.57.1564506729042; Tue, 30 Jul 2019 10:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564506729; cv=none; d=google.com; s=arc-20160816; b=oXlhySITVVkV1NRzt1AhvOipflCoVqfhqto/lR83gX+forctuQByDEpt/Kc5M0IL+r AxyQzqPEqkZwZOMtn7xI19S1CMnE/oevwZHCBeo6/DA9jYu4JKkdcHgKSYBzewsjyNOm tuJ50s/zRKKXPLjAee6OYohzEGJ/c7lXOVFz2ya3vusNRZ6i1z+4GgjaDMRxjLdlRxQz c+HH2Y/Jl7WFQcp4DaBg4aiorBry7pxJwUHjbD/SzwaZ+BazLEQWtgRdb2Hf1oMPVcdh S6IsVym25P8SA3/zSzJPOSyG1Ef52d1+fk56qQDAko8yNeurRoyvM23WunEua8eXojCy JDSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=iDlnLcyf19inNTkxNlZwmKWbIKZMmxn1+BK0R4d4xe4=; b=QXVHQTyDygs3Jv8cNUsorGQwzcaSYMXWux2kj9zDIz80k+QwfnO/omiKbVAk/8aq1h 7HguKNw5GQ6wGF9SsrjhjT1SahpzckCpK6yqwfbBWCdvHBXr8LFMjDa1yGtYI0E7M+m8 pMzAft46dwISCz0HoEPaCMs0TvZ5SX1NM721rXFiE0cDglMgKsbcu6Bgqp9vZ708yHp1 7fm2ile3pdUEdgE4FfsGWHtTIFhdETyIipQmRkAcHDCUKf8v27J22CbsjPW4mNlAFVAc geZK3+i6PQtVwdnDqVgpVQdECCwgFGu+0jM1ooMUtncZpfe+j/OurmprZCKuA+WCq5b5 +LCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f26si17213463pfk.81.2019.07.30.10.11.54; Tue, 30 Jul 2019 10:12:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730126AbfG3Mfx (ORCPT + 99 others); Tue, 30 Jul 2019 08:35:53 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3248 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726190AbfG3Mfw (ORCPT ); Tue, 30 Jul 2019 08:35:52 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8BD895BB8DA0E72D615D; Tue, 30 Jul 2019 20:35:49 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.213) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 30 Jul 2019 20:35:47 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: Fix indefinite loop in f2fs_gc() To: Sahitya Tummala , Chao Yu CC: Jaegeuk Kim , , References: <1564377626-12898-1-git-send-email-stummala@codeaurora.org> <20190730043630.GG8289@codeaurora.org> From: Chao Yu Message-ID: <609a502b-1e7f-c9b2-e864-421ffeda298b@huawei.com> Date: Tue, 30 Jul 2019 20:35:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190730043630.GG8289@codeaurora.org> 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sahitya, On 2019/7/30 12:36, Sahitya Tummala wrote: > Hi Chao, > > On Tue, Jul 30, 2019 at 12:00:45AM +0800, Chao Yu wrote: >> Hi Sahitya, >> >> On 2019-7-29 13:20, Sahitya Tummala wrote: >>> Policy - foreground GC, LFS mode and greedy GC mode. >>> >>> Under this policy, f2fs_gc() loops forever to GC as it doesn't have >>> enough free segements to proceed and thus it keeps calling gc_more >>> for the same victim segment. This can happen if the selected victim >>> segment could not be GC'd due to failed blkaddr validity check i.e. >>> is_alive() returns false for the blocks set in current validity map. >>> >>> Fix this by not resetting the sbi->cur_victim_sec to NULL_SEGNO, when >>> the segment selected could not be GC'd. This helps to select another >>> segment for GC and thus helps to proceed forward with GC. >>> >>> Signed-off-by: Sahitya Tummala >>> --- >>> fs/f2fs/gc.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c >>> index 8974672..7bbcc4a 100644 >>> --- a/fs/f2fs/gc.c >>> +++ b/fs/f2fs/gc.c >>> @@ -1303,7 +1303,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, >>> round++; >>> } >>> >>> - if (gc_type == FG_GC) >>> + if (gc_type == FG_GC && seg_freed) >>> sbi->cur_victim_sec = NULL_SEGNO; >> >> In some cases, we may remain last victim in sbi->cur_victim_sec, and jump out of >> GC cycle, then SSR can skip the last victim due to sec_usage_check()... >> > > I see. I have a few questions on how to fix this issue. Please share your > comments. > > 1. Do you think the scenario described is valid? It happens rarely, not very IIRC, we suffered endless gc loop due to there is valid block belong to an opened atomic write file. (because we will skip directly once we hit atomic file) For your case, I'm not sure that would happen, did you look into is_alive(), why will it fail? block address not match? If so, it looks like summary info and dnode block and nat entry are inconsistent. > easy to reproduce. From the dumps, I see that only block is set as valid in > the sentry->cur_valid_map for which I see that summary block check is_alive() > could return false. As only one block is set as valid, chances are there it > can be always selected as the victim by get_victim_by_default() under FG_GC. > > 2. What are the possible scenarios where summary block check is_alive() could > fail for a segment? I guess, maybe after check_valid_map(), the block is been truncated before is_alive(). If so the victim should be prefree directly instead of being selected again... > > 3. How does GC handle such segments? I think that's not a normal case, or I'm missing something. Thanks, > > Thanks, > >> Thanks, >> >>> >>> if (sync) >>> >