Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5046728ybe; Tue, 17 Sep 2019 01:29:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBGY/GTc650mlzpW2ys2j/SuarmNNGtR3ds62Ldq1Y/4nPDwB9yogzGGqmui0aBl6lyL6F X-Received: by 2002:a50:93a4:: with SMTP id o33mr3488127eda.0.1568708972189; Tue, 17 Sep 2019 01:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568708972; cv=none; d=google.com; s=arc-20160816; b=bXqfvTyoMR+LuXMhp2JlDwlzvLtGtY7gJACzmWkFS3CuL38mosVcWzqiSNUKw1Awu7 lGcrsDeyN0D7t+LaBTQH3F5MNlRULjNJMx7hl6A0WnPY2FPxW575rKFtXsetWQxMt5st nNLv08gCIvaQdbJGK1p8phvlTsLWWieFTIAN4iiYP8ABmriUnpD3Zd9RMVschAmVXV+h OEsP5ISLEQn0EVOBVKzUnkKMjLrVwReXV2CpHcVb1X8gTrTUXKAzu0ja/8n/PFFF6A8a GAxHObHDS4N3TCr0dN1rc0tO5PBgeDZ+lWB59/Q23MYksNw4DHtkf8L3Idtc6RBLc1kH SbrQ== 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=MOp8lD6PqppcpemLwr7LftJTUKqcsWrYliH5KGEA75Q=; b=VS4JizY1QCcJvCCBEuqG+S0Z4PlMzN1rH42RL2bx+BwclXAodpYrmeNItYfCS/eVFz biFf3eJgOkTJwGwTF9Vg+0kaDvxpN/LtzfnRNzoM2fkAvHULoufKgOzA10tKmEM/1+Zl Y8znwOGwa6H2XQrVlqKnXoUTfr/Ge4sbEbg2ij/6F7fbV9X22iQCysBzg1rr+gxN5vq2 vR+XkeTVbA6iRV0NUehxKpKWFUg5HDCaRYvVeoGL6JytYzz3osBDEq+pZr+A+P9Bz8Jm btoI0qRGocaIPyeNnF3O+YuCCqT1x+WxYYezXbBKy0Yf6+50+rlCxo8E+eERj+VoCia7 T1qg== 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 h14si989945edk.315.2019.09.17.01.29.08; Tue, 17 Sep 2019 01:29:32 -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 S1729030AbfIQBmg (ORCPT + 99 others); Mon, 16 Sep 2019 21:42:36 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2226 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728211AbfIQBmf (ORCPT ); Mon, 16 Sep 2019 21:42:35 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2CBF6CCC4611D44823A1; Tue, 17 Sep 2019 09:42:34 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.209) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 09:42:33 +0800 Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: do not select same victim right again To: Jaegeuk Kim CC: , References: <20190909012532.20454-1-jaegeuk@kernel.org> <69933b7f-48cc-47f9-ba6f-b5ca8f733cba@huawei.com> <20190909080654.GD21625@jaegeuk-macbookpro.roam.corp.google.com> <97237da2-897a-8420-94de-812e94aa751f@huawei.com> <20190909120443.GA31108@jaegeuk-macbookpro.roam.corp.google.com> <27725e65-53fe-5731-0201-9959b8ef6b49@huawei.com> <20190916153736.GA2493@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: Date: Tue, 17 Sep 2019 09:42:32 +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: <20190916153736.GA2493@jaegeuk-macbookpro.roam.corp.google.com> 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 On 2019/9/16 23:37, Jaegeuk Kim wrote: > On 09/16, Chao Yu wrote: >> On 2019/9/9 20:04, Jaegeuk Kim wrote: >>> On 09/09, Chao Yu wrote: >>>> On 2019/9/9 16:06, Jaegeuk Kim wrote: >>>>> On 09/09, Chao Yu wrote: >>>>>> On 2019/9/9 9:25, Jaegeuk Kim wrote: >>>>>>> GC must avoid select the same victim again. >>>>>> >>>>>> Blocks in previous victim will occupy addition free segment, I doubt after this >>>>>> change, FGGC may encounter out-of-free space issue more frequently. >>>>> >>>>> Hmm, actually this change seems wrong by sec_usage_check(). >>>>> We may be able to avoid this only in the suspicious loop? >>>>> >>>>> --- >>>>> 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 e88f98ddf396..5877bd729689 100644 >>>>> --- a/fs/f2fs/gc.c >>>>> +++ b/fs/f2fs/gc.c >>>>> @@ -1326,7 +1326,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, >>>>> round++; >>>>> } >>>>> >>>>> - if (gc_type == FG_GC) >>>>> + if (gc_type == FG_GC && seg_freed) >>>> >>>> That's original solution Sahitya provided to avoid infinite loop of GC, but I >>>> suggest to find the root cause first, then we added .invalid_segmap for that >>>> purpose. >>> >>> I've checked the Sahitya's patch. So, it seems the problem can happen due to >>> is_alive or atomic_file. >> >> For some conditions, this doesn't help, for example, two sections contain the >> same fewest valid blocks, it will cause to loop selecting them if it fails to >> migrate blocks. >> >> How about keeping it as it is to find potential bug. > > I think it'd be fine to merge this. Could you check the above scenario in more > detail? I haven't saw this in real scenario yet. What I mean is if there is a bug (maybe in is_alive()) failing us to GC on one section, when that bug happens in two candidates, there could be the same condition that GC will run into loop (select A, fail to migrate; select B, fail to migrate, select A...). But I guess the benefit of this change is, if FGGC fails to migrate block due to i_gc_rwsem race, selecting another section and later retrying previous one may avoid lock race, right? Thanks, > > Thanks, > >> >> Thanks, >> >>> >>>> >>>> Thanks, >>>> >>>>> sbi->cur_victim_sec = NULL_SEGNO; >>>>> >>>>> if (sync) >>>>> >>> . >>> > . >