From patchwork Mon Dec 18 15:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497158 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 BE5B4C35274 for ; Mon, 18 Dec 2023 15:36:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56B388D000B; Mon, 18 Dec 2023 10:36:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CE698D0009; Mon, 18 Dec 2023 10:36:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31FD98D000B; Mon, 18 Dec 2023 10:36:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 16F998D0009 for ; Mon, 18 Dec 2023 10:36:09 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D2BBF1607E8 for ; Mon, 18 Dec 2023 15:36:08 +0000 (UTC) X-FDA: 81580340016.20.CB04570 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 1D97F40022 for ; Mon, 18 Dec 2023 15:36:06 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913767; 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=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; b=3Az88BrcUVe2aLowr7uxjjoQ3V5taL2GgBTP4GTQzUjXLosLC8PMSK8Aps5cEOy2VSarOF 3T7eaTg+xnHRj04dVBBrrEV4aFMdnyxrpfj9rI/IXrsP0LxcXvqX7yLlM1AWc7fbirq6ux tnKar7yTlO+dFa1TfG4YP9hakRw9q9A= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913767; a=rsa-sha256; cv=none; b=d4QcR2qP4aubqsrrqJWhSHiz8SM2SSws7DJHlPYlAHZZHaEE1pT65hLjc05phpNoPs3ixy G5N59fzmUTQe7E1WR+3kr33OToXDFgXASJnPlHBTKrGxPI0bih/mGLt2FohgKr4n0IEPeF Blf8efeRx2b35KUkKrHa9EHXxewFA8w= 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> 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-Queue-Id: 1D97F40022 X-Rspam-User: X-Stat-Signature: ssob8ahjyi89pk1agy9dzzfth36bjwd8 X-Rspamd-Server: rspam01 X-HE-Tag: 1702913766-627296 X-HE-Meta: U2FsdGVkX19i7ePG6LL6kCYfD4KltEVWBobckGaQNPiKXP9nX1Z8QNohrWACHPBESWWqJEAgurk+Ng9g4gYTgq4dpqte+IucNQozlJBsmRft1ub2A9UBeX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sQ5tLs2IByJNKt3iR9OdhgVeOfKnPqNtNkxwn1LoM+3twk5mO8cv7P5a24DwxDrUEznfgWxY28cmOlHLjUXiMI/c9t7PN0otjk1DWpmMFJXNyb+/f7IOSUKcCc3CpdgQMtcL04FlXE4PxOd56//yQYiFnkua+AfGIdyZmYdAoalO40Fo3z19qndgJUJSEukyTHiHoLxSnQVoQ4KIMaLZYhsdR4zNZLmhYvzWlKRBQGd5JN5s3avv3rK6/QG8w= 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 --- 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; }