Received: by 2002:a05:7412:8d06:b0:f9:332d:97f1 with SMTP id bj6csp10924rdb; Mon, 18 Dec 2023 07:38:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIF2pdzgPEUxI8knE+h+G+IAgtpiTprapb0HxQuOQr+wXF9GmAoXfJgjgmXWsEyJyTqJLR X-Received: by 2002:a17:902:bc8c:b0:1d0:6ffd:9e2b with SMTP id bb12-20020a170902bc8c00b001d06ffd9e2bmr14013139plb.125.1702913886941; Mon, 18 Dec 2023 07:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702913886; cv=none; d=google.com; s=arc-20160816; b=DgRvzKBigiE+PRQ2V+0uhPzOZ7miUjVK9ell7l3MraAiD92XURWqt2yKl++2wgKOoH lhCoYmcQ9EfGMsGCnDvm2JEXXeB3c9eC9zo+KU1mJu3JY3IgumFOueI4prKUxCIOZ3gz WTmZ0Qv88jZguQ10ihDIjSiny8dVxVIJiMrCxuY61yhmqtRKfrI+QkZiv07GfdbnH111 OHUiwSr+pvmoF7cU9r0T73CuKZCwtAIPjhxa7eadt6F8j4Ls5wKSQwxEBzHE9IYG1q9F H4KABYlU+CvfbW+efkyJVMyHSd9SDPjNxzy/cNyOxi97r1XD+If5snhQIu4lek6Uind6 waRA== ARC-Message-Signature: i=1; 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=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; fh=m0HBXuwgOCKat7wyuY7vstPypqMqxNmINnjBv5+EUjU=; b=a28h4B6hSvVF2Ahynu+KYvd65i5kFnIZ1NNvndp9jdVS7vA8rQX6QA/vEtfV1phEQr 2wrHcuRJM6moP9lTZx3mo4YSkfttbFf30wvj+huAG6wQIJXdL+l20wGLCET57iOhoumD ULRsRgM/6FA8YKRiCPuDSsYYd6+prshyfTSiPQJt5jG4OutQ17/fshiRiHnj4ecn3XdJ TxwZdEJkBY6Lwva5ORpoxIZbGduk4Kxn4gLSpKCWEORMiC4kFHMZVdK+yyrnnZlgfdt4 8Y08rr9A9xHhzz+XMmdrbeOqy15LExtkqEGZ2pIJJEFAH9BDgNjaNCctUVxJ9egvpcXg DGZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=pass (google.com: domain of linux-kernel+bounces-3948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3948-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s13-20020a170902b18d00b001d3442ef0b5si10282355plr.423.2023.12.18.07.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=pass (google.com: domain of linux-kernel+bounces-3948-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3948-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 97399283B2D for ; Mon, 18 Dec 2023 15:38:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40FF55BF83; Mon, 18 Dec 2023 15:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VdO2027f" X-Original-To: linux-kernel@vger.kernel.org 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 2DF1C5A865; Mon, 18 Dec 2023 15:36:13 +0000 (UTC) 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=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; b=VdO2027fZSQ6+ARV1T/HY1vjUJ qO+GRQF4owYZjioIiUVuSwZTEQ/cN/nrg5ibAjNHnyq/cr4zSGzlcM3y2Q1UMgHoJjGN5t8V1EETI Dpwa6PCMko3S+HiZS52aj4OQNyFjw58ZygjiHjXBfLsvnE/Xaz+CYmUQUEyXNr1g8ps8aTfa+ueqv L5OSfZ0qwYzFm6wuHHBT8kMKqm3isVDi4DjtWHI7vcv8A1rqKaok+5uIIQfDRfIgfvKrprHGmV/PM XheCITb/c+GkDmqgc2t1vJgBr7RoVG3iJpGyIdSONPMKpgv5v6LKHArfqGzB8I/iBFTcGlAch4WA7 2FJMcPyw==; 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 1rFFf3-00BEKx-2M; Mon, 18 Dec 2023 15:36:06 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Date: Mon, 18 Dec 2023 16:35:40 +0100 Message-Id: <20231218153553.807799-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-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 --- 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 7ed6c2bc8dd51c..c798c0d6d0abb4 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