Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3097502ybi; Thu, 18 Jul 2019 20:59:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqywW5BQXqmE/dOSHe3ekZpeMb7YhyiU6XbT2GGVG67wzlc6LJPs9LnN3jNTShoM5Pr9gY52 X-Received: by 2002:a63:484d:: with SMTP id x13mr51380726pgk.122.1563508769061; Thu, 18 Jul 2019 20:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508769; cv=none; d=google.com; s=arc-20160816; b=tDw03OnZPlFOqBVCU5aa6dqidDdji8uyJrqVasbdeVkSMcKiS3U9xezKLkIOQIDKiL v6ZtsuOKSGU7qbaQtINKRhS8IGXY9jrcnlgk/HIJuXss5BFazim1QNnE0GoUJfpGoxsb 2PDa22tijoh7lFyBitZB0EKY56Kl2iB39UtxSOVr8a+Zn+GPJD+eJuaUoUyduUbj5Aop j28br4st9NBTG50RGyOIzrvxFjjhPiDH342Z8duXa7n6rPC4WEbVufOaDHSMIseytOyC OrmPz1S8m24/p2E8pSbi4IJg59eWK7wrwSC01UrpdebHrvPK+/Hq1q+XldDH8n4iqP3v vCVQ== 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=fMYWYLjBjieIfnwHagYw7+DPi7NIhE7i586MZP0E6BI=; b=iJkaV8CN7KvMdiQi76BC/GCF6ybTdmbcYJZ4RMifTt1GgJsYd/eX4efby88NjIXDf+ RLEG4zLqLR0a5OiXJdiMxr/ryCr32jsAeARdSlVsdPL+qBrkXJRnrkEaTeis+uOmNKSc LQI8BzLijSo73RYeqVr/UO1Dd/7bT5AnHqqOdLufyScOafCjJM9OmYbM7mMBI2qknO2L qjYxYzRuWxNJ0wNPfd6uykYOF2qooUCv8/Qilb7BJvxdkW6hqTOv3qPELx1wEsTHqWbG 4mSQ0vQt7aqZ1lQ6fYnTQSbnzp+A8778wHg73sgmwfNCCxjWg9sMQvzJUV8pXi6hl7/P 1bcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lddfjHPD; 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 a21si381337pgv.185.2019.07.18.20.59.14; Thu, 18 Jul 2019 20:59:29 -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; dkim=pass header.i=@kernel.org header.s=default header.b=lddfjHPD; 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 S1727994AbfGSD6W (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:57648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbfGSD6V (ORCPT ); Thu, 18 Jul 2019 23:58:21 -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 3B08621851; Fri, 19 Jul 2019 03:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508700; bh=aJRvDu9YvM33JggDAoN3fy/XtFIU7MiopLHT5SlzMcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lddfjHPDE2LR9VYNgI2X3oHkz4vTs/Vdb6OQVYRZALdOdeZ9BFbY1584f/eVro4R/ jrbnYtzq2GEf2GKOuMM17z5KVvuLyfvjd3No94wzVTRvT3+i4yVAiRvsED/LaThZ77 8YvUIULfTGwJ/RSftF3guV1z8v9ww732dA1o9dX8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Rosenberg , Chao Yu , Jaegeuk Kim , Sasha Levin , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.2 039/171] f2fs: Lower threshold for disable_cp_again Date: Thu, 18 Jul 2019 23:54:30 -0400 Message-Id: <20190719035643.14300-39-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Rosenberg [ Upstream commit ae4ad7ea09d32ff1b6fb908ff12f8c1bd5241b29 ] The existing threshold for allowable holes at checkpoint=disable time is too high. The OVP space contains reserved segments, which are always in the form of free segments. These must be subtracted from the OVP value. The current threshold is meant to be the maximum value of holes of a single type we can have and still guarantee that we can fill the disk without failing to find space for a block of a given type. If the disk is full, ignoring current reserved, which only helps us, the amount of unused blocks is equal to the OVP area. Of that, there are reserved segments, which must be free segments, and the rest of the ovp area, which can come from either free segments or holes. The maximum possible amount of holes is OVP-reserved. Now, consider the disk when mounting with checkpoint=disable. We must be able to fill all available free space with either data or node blocks. When we start with checkpoint=disable, holes are locked to their current type. Say we have H of one type of hole, and H+X of the other. We can fill H of that space with arbitrary typed blocks via SSR. For the remaining H+X blocks, we may not have any of a given block type left at all. For instance, if we were to fill the disk entirely with blocks of the type with fewer holes, the H+X blocks of the opposite type would not be used. If H+X > OVP-reserved, there would be more holes than could possibly exist, and we would have failed to find a suitable block earlier on, leading to a crash in update_sit_entry. If H+X <= OVP-reserved, then the holes end up effectively masked by the OVP region in this case. Signed-off-by: Daniel Rosenberg Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a96b9e964733..8903b61457e7 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -876,7 +876,9 @@ void f2fs_dirty_to_prefree(struct f2fs_sb_info *sbi) int f2fs_disable_cp_again(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); - block_t ovp = overprovision_segments(sbi) << sbi->log_blocks_per_seg; + int ovp_hole_segs = + (overprovision_segments(sbi) - reserved_segments(sbi)); + block_t ovp_holes = ovp_hole_segs << sbi->log_blocks_per_seg; block_t holes[2] = {0, 0}; /* DATA and NODE */ struct seg_entry *se; unsigned int segno; @@ -891,10 +893,10 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi) } mutex_unlock(&dirty_i->seglist_lock); - if (holes[DATA] > ovp || holes[NODE] > ovp) + if (holes[DATA] > ovp_holes || holes[NODE] > ovp_holes) return -EAGAIN; if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) && - dirty_segments(sbi) > overprovision_segments(sbi)) + dirty_segments(sbi) > ovp_hole_segs) return -EAGAIN; return 0; } -- 2.20.1