From patchwork Mon Feb 12 07:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13552746 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 DD403C48297 for ; Mon, 12 Feb 2024 07:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C5F06B007E; Mon, 12 Feb 2024 02:14:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 600156B0080; Mon, 12 Feb 2024 02:14:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F10F6B0081; Mon, 12 Feb 2024 02:14:15 -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 3CE9C6B007E for ; Mon, 12 Feb 2024 02:14:15 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0E25716034C for ; Mon, 12 Feb 2024 07:14:15 +0000 (UTC) X-FDA: 81782288070.04.3272AAD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 7485C4000F for ; Mon, 12 Feb 2024 07:14:13 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QMXkj9OR; dmarc=none; spf=none (imf04.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707722053; 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=KUIj5droJWBY9JuTDNlu6m/OZ7SC5gyUm02IKuKQE8M=; b=i+MfDeUC6DI16hVAMry8jEcbyOiPPnCmde8hiaM7mtAzF3dK8fU+8rpk2J4LzA5ZN39y/o TWgbRxvkRpgl5zyJdQsm6Ynic2LKIjMcXAg3vqshyIZXlOci4s/hjEQuYYugsfyEEXiSjd wDhICRc4c1tPnOsFNTz1StQVzYjuUeY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QMXkj9OR; dmarc=none; spf=none (imf04.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707722053; a=rsa-sha256; cv=none; b=AWDSsQEtc3AqDjmQ6GaLGZkWevr038bLYjLmwhVg5NI6WP1DHh+jt/UIRbJBjS5JO+jpwg 8dF6gYnMHAffLapVjx9rKRSUFXHTlq/QN/HUA4VHt/d0sn4Us7y06whBF3H/ja68bn7JbA isdQ1SyN1r0FEYTaYKZ9S41bpnJN+yU= 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=KUIj5droJWBY9JuTDNlu6m/OZ7SC5gyUm02IKuKQE8M=; b=QMXkj9OR68fUtzLzKk+BxuxP5V lLcsfARWxz3J73jW+4CgAYNChX8vH6k0bYjyje3Ka3UUp3oc6GxLgHxFAdgUXy8I3Q3cRXMjVbNo2 UTdZOTlyUdiKdDXVA+30f9Hz4sGb1b9PlTE9EOQ+6g0S36udj5BbdA6CafPZ9Po96XiHG8eDOgtKG FKwNEztpeIb/BiXUv4XWkKCconDCsJXg0G+1M929zR6uRK51QBCmXgoU2HM5G4xb+Jbb2b9r/568X TIwGtt07kVctUBqVnmuuBQ/x2I5CUpuUf0jYc9Ig1T/eFiRNpVsz+Ge0Z6jbgho4bypbjl34cJZtc ux8+JkwA==; Received: from [2001:4bb8:190:6eab:75e9:7295:a6e3:c35d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZQW4-00000004SsL-0LR5; Mon, 12 Feb 2024 07:14:12 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 05/14] writeback: only update ->writeback_index for range_cyclic writeback Date: Mon, 12 Feb 2024 08:13:39 +0100 Message-Id: <20240212071348.1369918-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212071348.1369918-1-hch@lst.de> References: <20240212071348.1369918-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: 7485C4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bf831dfmgthi9espnc1zzne66mwgdd8m X-HE-Tag: 1707722053-99672 X-HE-Meta: U2FsdGVkX1867sHkAq7X2Fwd5r66mASlDoD4pD3fTw8/yQCSn0PQphEz6XtpkeHK01KKoonaDVmLRWdo6n0C2yZwDVKP4l+XbgxyXJ1vYGns3biNCr8y/FrOzsJBhdE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Ux7OAKVN18W7HvtAY7yTTS/33BxOmacKfhguKZOsLBYPVbYriA9+n9fnvzkler+9HDmh6A8nivQalQ5sNnW/af+9F6fWTHgMoiYl9xBENc9+oZRXraTBfx57KF6paMi6vBOhe5YC8URrk6D3yZ7cCK9PlKE4Q5qoH6aK5bukBdhThj7u9XqTpDdQahWG+GIYCedwJ634/QlfpLZehhBUFYc9r5mw95vhdTxtsoOmzjAH8MfFHyZNDBcrMbGyKLo4HWbRxeR3CCzXNAFQs7o= 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: Brian Foster 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 06afba8f078515..4d862f196d1f05 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); @@ -2518,14 +2515,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; }