Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp41245rdb; Thu, 25 Jan 2024 07:43:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKHAY9bz31mBGTv+HAqA71sAv/w5SXOSkmdhSBSszvQS0/vdOBE21opCU1rvHccWbztbfb X-Received: by 2002:a17:90a:ca93:b0:28e:8ce3:733f with SMTP id y19-20020a17090aca9300b0028e8ce3733fmr924006pjt.30.1706197418605; Thu, 25 Jan 2024 07:43:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706197418; cv=pass; d=google.com; s=arc-20160816; b=fEc3tvn0eAf0M9SeZalavI84sjbgiw0tbSPz4zIMFcG6K1/S1Gqf9JeEK7pZzNNxro K/iwEoTbe9lHWYBK7splpWQGWuz4N/9mYFQvEIuz22W6q1vNHVv0UENYNP3umB3TefHK UWm7IRYkYkVaT/2UtfhNEW7ISs8Ia58en2eUos23rhEdPLFHrshC7eBc57DG70IajpNJ NcGP7o8LK4fPMZZMgdAoDkq+Guh9eWYkY3BVIPHDG0yZ6WUCvDni6yZS1muPhGEc1W3Y ivhLh5k+e+WA1b8vzcrJZUjPLMI5IVRmFMMgjP1skoEvCq2JZ5UQnshXzgtm1v+eJkXg IlvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mQziaJTCCDa3AbhWn4nD8iCuTBFEarj2zw47+pSlXVY=; fh=4n+2OJvAjB92nIDNIVn6PB+TJURVaRmLWxWqLJknBpc=; b=WKVZtNFolr+498RMxPfZcaApiKI9ITD5AQwX93knac+udr79SwlLVx7NU41eGVKwg1 bG1ANk2rH3z0sxlE6tWbhBwvlwYmVRp3bLcGfy3zgJqs4ED0l+uBUTB0jMPh0cIo6FKk jDE4CN48zhP2evc7h62QFvFIe36CBwlt9eBwV8RZhVmA6mX1zDpz+LtwgLT9YZBQyN0d dJk+d1M6UEOOshrh7cgyE5JrgbI/PjenF5unk3DFiJ4NNX6mAw9n+mJNQb1LWsx4lW7o /EWZi3q9sJ7m3bbeqwO7+7bShJ2uEHcVhePBWsvA5fZsHqtcGY6WRRpVhnp+eOtmdq0M CfhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Oy0oWNx0; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38206-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id in10-20020a17090b438a00b0028cd4e6e480si1502604pjb.22.2024.01.25.07.43.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 07:43:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Oy0oWNx0; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-38206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38206-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8F73DB26E8A for ; Thu, 25 Jan 2024 09:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E6EC1C6BE; Thu, 25 Jan 2024 08:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Oy0oWNx0" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B0891C693; Thu, 25 Jan 2024 08:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173110; cv=none; b=hKGdGNHP93wZMl1wm11o/xrinoLp9BXZkHqfO8ZC937n1GjxCoo6yTJPptPgrCABv2x5dhOigiYH9ipOglcaks5yowhq+uKOW/YL7uKRFPoa/4WIfZZ45WVJZgQJl3alSAbSpfMngVLhGsPJDm52OwJxLwqFg4bHTpJrlEdZW3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706173110; c=relaxed/simple; bh=h1WkeET2lfFtwK9LREQo75a5pNm0E02jhMP21bYuj1Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kfPX6E8gw01jSY3jvTv+dWPF6R4VBvDJN7UOF/q/kyc10bXLSC+t44PUXf2l4h92UQE+YiWrcPodoM9dpCuJVt69dYrvLqCkSzhUd/p39Ar1hF/lATWJAFoQX7kNxh8YtNc/MGKqisReiGKHSpuzYEabRCKAI2RkpNtYkGN+wSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Oy0oWNx0; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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; } -- 2.39.2