From patchwork Thu Feb 15 06:36:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13557439 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 C4D67C48BEF for ; Thu, 15 Feb 2024 06:37:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 678496B00B0; Thu, 15 Feb 2024 01:37:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D9CC6B00B1; Thu, 15 Feb 2024 01:37:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42E716B00B2; Thu, 15 Feb 2024 01:37:14 -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 28EE06B00B0 for ; Thu, 15 Feb 2024 01:37:14 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 007C8C0511 for ; Thu, 15 Feb 2024 06:37:13 +0000 (UTC) X-FDA: 81793081146.10.ABF072F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 589B01C0008 for ; Thu, 15 Feb 2024 06:37:12 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sXSaoAWJ; spf=none (imf18.hostedemail.com: domain of BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a252b21bd4a653ddb6e6+7480+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=1707979032; 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=xKyzTXAMH1rh/hkISGxP5mL+5GL5qSZuP787X1EFqpI=; b=Ee0uuLJC+Zhxupdzwl18P96tnfIxCCU8m/kcJtCcULOZ0CZ0K7lK3WjTRdEx7Vb3MWRxu7 wJAs2x1TfW8JcCfcZgP1aHJjAls1kwsgh7K4aanCGOQuTms077zlZWk1AYs4QIgsZ5sBVG 81qRUPxyyoM5YezS66Lg8ERBTxlyUHM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707979032; a=rsa-sha256; cv=none; b=hSEk6QOsJuWbq09uOYaMaPlDv5RZ+UcrqfN6iixu5F482E+u1iMjRZvg7qMLU4Q5lvneX9 eUtbpoenYAJp42zDRaJwhNKzRF/OygVzhWsD0qe9Ejv6NuXFjhUmcSITnryx04SzxyXHSp guy4SSFHBp7m970EsKGbe2a4I1AOluw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sXSaoAWJ; spf=none (imf18.hostedemail.com: domain of BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a252b21bd4a653ddb6e6+7480+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=xKyzTXAMH1rh/hkISGxP5mL+5GL5qSZuP787X1EFqpI=; b=sXSaoAWJwPtvCVhZUDGt68K5Xk wRIacKs9X39sZS58OFVm/UZYlROkXnmTbM1YNk8+SNUaK8La9ctbfp61ePeYGQ4xOywRTPhzEsn3E QOEogTeYSOLM2YlGSXafPgjRrqpYy1/vCrYCup3YcBSmzeXuanP8YMP6anKDq7NQYvmMhiCBYYSEW iElzGVrVXeGUPT9hSGDaqvyhUepWjdiOeTnsUIJKQbByIG104tuJblnE1kpbkn/xmZQfmtCnBH2is l5/ebDiH2HyDNeJE+MDVA/saWA/vYU1YE6Mrlthjh2h0sKnT5r93af1RB9mp34gRBHhpIREexyz0a r1K7JMIg==; 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.97.1 #2 (Red Hat Linux)) id 1raVMt-0000000F6s3-0QQO; Thu, 15 Feb 2024 06:37:11 +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: Thu, 15 Feb 2024 07:36:40 +0100 Message-Id: <20240215063649.2164017-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215063649.2164017-1-hch@lst.de> References: <20240215063649.2164017-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: 589B01C0008 X-Rspam-User: X-Stat-Signature: mucohqdzhewamci7dp8mthths6kh44h4 X-Rspamd-Server: rspam03 X-HE-Tag: 1707979032-460855 X-HE-Meta: U2FsdGVkX19EArjc2zZ6k+zbwh7UCIGLevZ7IOaGals2cysoiCTwhXaywbQ2hwxqP7jm9q3UaPglRIESeq9SU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W47gUzhA/6x/f2EmnfrYXHJCQrn375Raed/Xy1icLWp7aZBapUhfta+L8td9Gr7ciBEh+8IlkmLLMk7340XFr+t2Hc+Il8e0TbwbEUSY3O188V1AfOa8PgmweF99YDXYlo8WMYdAa7R6ULlbaDIHp/rD23QfHMMK22XQfYPH0o/NEOLxToAooYW9Sehq5jaFKtnZHiOIDR6FiytHIaSGes3QwyC0xiwHn0CepBYIYWtgr5xgR7a1fZQ27W4F9mSq0QurCrBX1SKhhcmU1ZghoBsCdCMpJN0NVS9e22Muk+dhvYNFrtjg5y93Uc= 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 abbee369405a83..f02014007b57cc 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; }