From patchwork Sat Feb 3 07:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13543899 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 08AFEC4828F for ; Sat, 3 Feb 2024 07:12:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 849A06B0075; Sat, 3 Feb 2024 02:12:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F9246B0078; Sat, 3 Feb 2024 02:12:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E7D26B007D; Sat, 3 Feb 2024 02:12:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 61CED6B0075 for ; Sat, 3 Feb 2024 02:12:23 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E8E17C0545 for ; Sat, 3 Feb 2024 07:12:22 +0000 (UTC) X-FDA: 81749624124.21.BA7F66A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 49C82C0014 for ; Sat, 3 Feb 2024 07:12:21 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QH+FHNxv; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+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=1706944341; 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=GhmEmGUPN5iqiwr7bHV2cU1PJLEobcTODedxESHF4Gc=; b=IP5uQ/g8zUa4khJlAdSxwKwkYeF67fAM7uCRF3deuJz2eFP2+eYrqoYcOvHIC1/0KXXOET D6UklFvSiKUlZ1FaKIN2pPPRLWr2wWrU2S+p3XJeLC19Vc20R2qdtKR43HTz/vf9jgv9/u Pu+jdIQjHzHl6R3fLNsP4a534P6J/K4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QH+FHNxv; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706944341; a=rsa-sha256; cv=none; b=YqorvsTsv7KZ6oeGRW15wuvkNaL+qCof6pPI3HPROtN3uQ4hAwZb37HQO6IVsggsLM7w4t hyLxC8U3ItFck3J/HEuzqSqvmvgKy86GsjdminDzBRtmEE4uCNybyjSZmDVZ0uUlGuAS0R 3fN1PCZg7ph9FphCTkC1PmNXf14AFv8= 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=GhmEmGUPN5iqiwr7bHV2cU1PJLEobcTODedxESHF4Gc=; b=QH+FHNxvkAB6h4KM2iyT9Hyvsg AfE8Wt9IRK/c15fUAWzpoE0OtkarSrAESliln8xwuU91uqBJnw3VO1ZVOQoYwX84FrKLJob4M3jMF oRjd2HOh1Yp7g+s/i/D020aM/XNuc5Ou1E5OqSB+BoPXYnmXsysVl04sBQn+hyb0r/W9HefFlUQas cX5zi8ABK7rKKEQCa4O6ZDOWajvyMxkBX+pdPcVSoLre58AnwYKNwkfkYrngCfhD9mRSaR7RQeW3j +ZFwoC5ArTW4txv7BDS1lqNVD7QtwiapVkQzDgkl/LFVurH1ZDwJQeCF5Z4DWpsunH5mT9eRUoK2y SAl/WSOA==; Received: from [89.144.222.32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWACJ-0000000Fk2d-1AV7; Sat, 03 Feb 2024 07:12:20 +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/13] writeback: only update ->writeback_index for range_cyclic writeback Date: Sat, 3 Feb 2024 08:11:38 +0100 Message-Id: <20240203071147.862076-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240203071147.862076-1-hch@lst.de> References: <20240203071147.862076-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-Rspam-User: X-Stat-Signature: yk55fei95apazh7tzctr9szx533w1r51 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 49C82C0014 X-HE-Tag: 1706944341-558161 X-HE-Meta: U2FsdGVkX1/ijEPVQzsn0gEEAX580QDkcUqdGCPF+RcMXHn8RaxL3j2TqmOyWfaqDt+sF/cjJCpYGCuTrhFVyIQsC51QAb2yZmGgaS3CKu1TyvomxLLON+mWDMmbM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E8kukh/W+f9b3jxYESQqzGID71bKapP4hsA14VzTarPEaSHd9RF5VkGdstQWig98Mvlgt9r6xoYyXJn/fHwqyAx3nu+wq17uTu0+u+IPdnNBAVta22mtl2YrkcXFLcGubMhu2o2qlik+xp7GUDd+yt20MTDwF0XwAZjlIGSwjYCLPnroKuA/9d/CE/vcb7TikECfQNdKtUmmmBTW0j7UPktoiBZ3Zbr00l1HNICgJ70ba6PqPgXhU0Nrdjv0SaQ= 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 ee9eb347890cd3..c7c494526bc650 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; }