From patchwork Thu Jan 25 08:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13530237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3B5CC47258 for ; Thu, 25 Jan 2024 08:58:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60B33280008; Thu, 25 Jan 2024 03:58:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BB48280001; Thu, 25 Jan 2024 03:58:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48357280008; Thu, 25 Jan 2024 03:58:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 362AD280001 for ; Thu, 25 Jan 2024 03:58:22 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1C9C840C9E for ; Thu, 25 Jan 2024 08:58:22 +0000 (UTC) X-FDA: 81717232044.21.C7EABFC Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 7EEE14000F for ; Thu, 25 Jan 2024 08:58:20 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Oy0oWNx0; spf=none (imf12.hostedemail.com: domain of BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706173100; a=rsa-sha256; cv=none; b=STkP5Ycki6Hr2fLD/I8d1O268xKZ5BAdgB8sG+YZDlg4SnAWA7yXYRQcxjz6eLpyR76qiQ KfJmdVeWbkzg+ABng9GzJU4r3sHSo9IY9f5Z2BLhN6kMitehNztLlj+EE4NAXnUrrSJROd hp0nbtyzj5xhtfUu+gOW+lCpLAzm2kA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Oy0oWNx0; spf=none (imf12.hostedemail.com: domain of BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b97a0fc658bf3e588113+7459+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706173100; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mQziaJTCCDa3AbhWn4nD8iCuTBFEarj2zw47+pSlXVY=; b=e64L+zKjnVoob5HUnmYCbNK9fIoOGpAvsImuVXzbOb16Q3AuoOICGYCmNatCAaXQO4zo2s G8OJamR3SjHexiU2MaGfbgRiF82OfNxBDk2CHollPhNm8kdATYYxJxalU/KWtAggvRJTLE P8jQT/NCehabKEYP1/2vwIANYCj32SY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mQziaJTCCDa3AbhWn4nD8iCuTBFEarj2zw47+pSlXVY=; b=Oy0oWNx0ILlrqoqY3sBlCvuvXZ S3ehmhURa6VLxlHpNUebI4N5SPtGJYyUtcnpTLpTGZPZ5DMzi4PFRHs17w//dZc0AWskfkia5AQE9 FHQ/03fDGUaRt+Lcj9ip6NCdsmj4KucTZgvLxgWd35fo0XiJNc2frkzg2KeftFKcQkkCyWn1RXmFY XCdgxGihsEj6mcfdRDaaBknMcF9xTHSRcH6C+Z3MaEs0W8F8Wqlg2nDqVca3VE6VqK+sV1FcFxTRJ E+n6eEw+y8DQiZJzll8t8zEmLixh3Aynt5BB1xnOlkvmqSXpG0qZU+h4b8skQ1f43JyvYWur4lVQ9 YWyQ2AnQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rSvYw-007QDX-17; Thu, 25 Jan 2024 08:58:18 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 04/19] writeback: only update ->writeback_index for range_cyclic writeback Date: Thu, 25 Jan 2024 09:57:43 +0100 Message-Id: <20240125085758.2393327-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240125085758.2393327-1-hch@lst.de> References: <20240125085758.2393327-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7EEE14000F X-Stat-Signature: qcn1sydhh13m5pg979izspt6r3m4i95t X-Rspam-User: X-HE-Tag: 1706173100-376328 X-HE-Meta: U2FsdGVkX18UZ44Njn02jFhC5t1oV+ep07m6GIkIQQ8o+ojwq9SY5tfjyf5VLtURopR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e0gQK+ikV6eLvCzR8HVJjuKCj5F5sbk+toI4F2FZ5AwkDZTKd191C1T59rQZfqNVbPRQLUTR/eJl5jlyNWnZatlCscTsbhsyFS+77KZdTei0moQbmtlHJPmsD7NY+FTt+urC4py5gImZ4ee+99kVoZTM8e5LRGurO2IhnKByZoeUCATXdSvVB/qYQtar35+G0Xy0IwIFuduj2MOFHLrFQ9JJHwNBxTOXmFDYZKjHnM9kAQVNRC7ZXmduoy97mdrUXOjqsvq1IIxlv734x0225fgz4Rtxp5OlVlxLv0XOA7e9YmwxNO17gZB4Z5xXeJrqGLdtQlsewiQCv7g8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: mapping->writeback_index is only [1] used as the starting point for range_cyclic writeback, so there is no point in updating it for other types of writeback. [1] except for btrfs_defrag_file which does really odd things with mapping->writeback_index. But btrfs doesn't use write_cache_pages at all, so this isn't relevant here. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 259c37bc34d2a7..437745a511c634 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2403,7 +2403,6 @@ int write_cache_pages(struct address_space *mapping, pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; - int range_whole = 0; xa_mark_t tag; folio_batch_init(&fbatch); @@ -2413,8 +2412,6 @@ int write_cache_pages(struct address_space *mapping, } else { index = wbc->range_start >> PAGE_SHIFT; end = wbc->range_end >> PAGE_SHIFT; - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) - range_whole = 1; } if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) { tag_pages_for_writeback(mapping, index, end); @@ -2514,14 +2511,21 @@ int write_cache_pages(struct address_space *mapping, } /* - * If we hit the last page and there is more work to be done: wrap - * back the index back to the start of the file for the next - * time we are called. + * For range cyclic writeback we need to remember where we stopped so + * that we can continue there next time we are called. If we hit the + * last page and there is more work to be done, wrap back to the start + * of the file. + * + * For non-cyclic writeback we always start looking up at the beginning + * of the file if we are called again, which can only happen due to + * -ENOMEM from the file system. */ - if (wbc->range_cyclic && !done) - done_index = 0; - if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) - mapping->writeback_index = done_index; + if (wbc->range_cyclic) { + if (done) + mapping->writeback_index = done_index; + else + mapping->writeback_index = 0; + } return ret; }