Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp881881pxk; Thu, 17 Sep 2020 20:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpjWCe/tyHG/hnxDPKW6/WBu54vHTrl9RbYBVrTMbF3NoUmIUwSvKNUCP5uKZZ/0E2i8VF X-Received: by 2002:a50:8c24:: with SMTP id p33mr36519555edp.330.1600398823729; Thu, 17 Sep 2020 20:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398823; cv=none; d=google.com; s=arc-20160816; b=gVhlGg+q5apdo3bBKZ8yYRvzS8ZW5v1PM6SzX8kQRbIxLHnYmJ7Gnu7jZ6kXkfzD7n nUX7lNPkg6AcS0ivQVZ8Gpi1pJRVewlJkBfAip5K+I20Uoen/LC+X5JZEdppia/RlHT9 tFXyDtxISOnKBCwRyxH+rAqa3uY5TVoKdNDPsK5LqUG4/WpTSZU4IFcE4zd2tVwFUV6G bk7lnu04/iuGJXXuks/Ge3+kinFnvLx37cKwIWJ+KiDmzIP0nPQ2CcRR5PE1wHH4y8nC hJyX32D9Lgu4Hw+W7gpIKoVjdGRBd459Eshjfu9aF/juxDh86Ce5NXSss3MedPI2U1eV Ti0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ph69cU/ENB8+91zzjgCplgFQUBaiCXsxiY47dDXnwyE=; b=i9ixjrBcTzvEgn0bxxbuffPgg3yPXgmcRbJsvX4N+fvpTGDwgtGHmUxU+jNaxS3d31 vKTuT9JZKJM1yNZSiwyQx/kRFnZB6X4Dm8WOsl+FCIcm1xdUdbYohnrHjuvRlTjPwEfs nUdnDFCp88V7iYwwcTHgYNDgQsTVX2HRgPVkYq0NL7IWglxUr+xF6/bFzXsym0ZZ6Nwk HkuSrQO49xxfgRW3wIcg3GSV/KaQ1LyaIIsLZeO7zCTmec1W6KWyUKoJzrSDB6KRS8+m ArxOAZKuoJkeP7h1aMMWLrx+CzRurorwJL6DCFK/Vxp09oiNXA8sbUXBLoL4DxQfvZ9w 7oQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LOO6QKLY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si1273269ede.8.2020.09.17.20.13.20; Thu, 17 Sep 2020 20:13:43 -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=pass header.i=@kernel.org header.s=default header.b=LOO6QKLY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726769AbgIRCCb (ORCPT + 99 others); Thu, 17 Sep 2020 22:02:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:47702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgIRCC3 (ORCPT ); Thu, 17 Sep 2020 22:02:29 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C91F323741; Fri, 18 Sep 2020 02:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394547; bh=gIhC3ilpTfqrolrhepjUWk2QSeVf3R4QWY5CuNHCfWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LOO6QKLYLr+xCVL7uFXInMt1joP5edQIJgjXgL65MsZFwzRwxA20BdOPyJtlqfuqf SjndfXVgQAUT26vyPFq7xCqMoGbmLKxiBe5uKR0iudcv38w41+GVOcEJCxh0FS1Mgm tMHZQO6F2Mpn3z7rWmwvwsC9i379ySgVs6u+EL4k= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jaegeuk Kim , Ramon Pantin , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.4 064/330] f2fs: stop GC when the victim becomes fully valid Date: Thu, 17 Sep 2020 21:56:44 -0400 Message-Id: <20200918020110.2063155-64-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jaegeuk Kim [ Upstream commit 803e74be04b32f7785742dcabfc62116718fbb06 ] We must stop GC, once the segment becomes fully valid. Otherwise, it can produce another dirty segments by moving valid blocks in the segment partially. Ramon hit no free segment panic sometimes and saw this case happens when validating reliable file pinning feature. Signed-off-by: Ramon Pantin Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/gc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e611d768efde3..a78aa5480454f 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1012,8 +1012,14 @@ next_step: block_t start_bidx; nid_t nid = le32_to_cpu(entry->nid); - /* stop BG_GC if there is not enough free sections. */ - if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) + /* + * stop BG_GC if there is not enough free sections. + * Or, stop GC if the segment becomes fully valid caused by + * race condition along with SSR block allocation. + */ + if ((gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) || + get_valid_blocks(sbi, segno, false) == + sbi->blocks_per_seg) return submitted; if (check_valid_map(sbi, segno, off) == 0) -- 2.25.1