Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp732073ybc; Fri, 22 Nov 2019 12:12:40 -0800 (PST) X-Google-Smtp-Source: APXvYqwWrNkEf6dTkMsIyo3oaaMPK+i3/xx15WXK77rVzrru4MGTrXhNXw4/P32XUsJIbqRBqGOX X-Received: by 2002:a05:6402:1692:: with SMTP id a18mr3438418edv.297.1574453560445; Fri, 22 Nov 2019 12:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574453560; cv=none; d=google.com; s=arc-20160816; b=ngo7eVZOjtsoEOFv4tET3gVQ+Hi/TyRDbOuJkbZXOfmqUdszZysRHWhp6sVFxvF2yU 4ri7KkuwOCXDJ0nc/xU6G1GiiwieXp1YaxthRrMGVnWWvyz/gk+38g+qeuzO0QYtsCVT VdVVNiZum2L0EWjq8DIJ5E7Ter5nLEESld3PrOSDm+vXs0xr5H2cK7Q9ToJcbZcXbuCP OWFO/lJWYoQvyUoeGMZKnrmhRJIoUEWRjDQHbwo97a8BdGBrxYWJ/AgD+s17bwDxaMvq o1v3LRQE2lWwKU31suoTLeeB8Y2eqU2/i1EZEeFy66QNorwDo9pyVp+SQersHsn+wUQh gF3Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2dEkgfgtGXUDaHISHm8TQguIQkMXpmekUBtrf/y81oE=; b=UiGo3oEqp1FOrg/VY7/ZUcWHt71vLmCT/WHp7fpfiWlW+Y6YL6rwES9mRYS3khrbjd 2lwLBX28AM/1jTd7j6CBqNv7Xr1M2O4afywAaop3kCfvdWXYZpFGvNP/SsaD+Z8U1kbk 9/T9E1ox/oCkcgPL4vgPzSmrYE7JBGsiRpnE+aqiXUF6uj1kRWROcHyaots3YiW4MB21 rs0RJcGnhgBrgt53WdVGgw8bZI/aFNp26hOGt5KufG+D6SDlS/5rJs6gf//yBoCV8bf1 FGOQ6GrxIQx0XIjwFejbzgUFfMEUovE6hMJiJY8w7s1+YdMnB754sqP3gfiGw5f1kFmH PLHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mG6KoUt4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y21si695782ejb.75.2019.11.22.12.12.16; Fri, 22 Nov 2019 12:12:40 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=mG6KoUt4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727205AbfKVUJY (ORCPT + 99 others); Fri, 22 Nov 2019 15:09:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:36714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbfKVUJX (ORCPT ); Fri, 22 Nov 2019 15:09:23 -0500 Received: from localhost (unknown [104.132.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 438402070E; Fri, 22 Nov 2019 20:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574453363; bh=Dvd17sN9aKtG3WDYVBtYh+HeEMUwJ3hipC55jNi6qBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mG6KoUt4L/RNymmjDaeJHrvG8+kzFySvErqhsboZFRI3tUMmhSD0969niKGARYKa2 c0jeZ29pWiSrR50IQ2hrTfzU2oECLvzkBfF1n26yZ+WVCUoMWSVnU0eXPYVEkdawpE waNaodEt78IsNaJZuJ1i07dwHJLurkcdninAbWds= From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , Ramon Pantin Subject: [PATCH 2/2] f2fs: stop GC when the victim becomes fully valid Date: Fri, 22 Nov 2019 12:09:20 -0800 Message-Id: <20191122200920.83941-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20191122200920.83941-1-jaegeuk@kernel.org> References: <20191122200920.83941-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 24a3b6b52210..b3d399623290 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1012,8 +1012,14 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, 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.19.0.605.g01d371f741-goog