From patchwork Fri Dec 22 15:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503412 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 3BDF7C46CD2 for ; Fri, 22 Dec 2023 15:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC92B6B0080; Fri, 22 Dec 2023 10:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A29706B0081; Fri, 22 Dec 2023 10:08:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CAA26B0082; Fri, 22 Dec 2023 10:08:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 75CCE6B0080 for ; Fri, 22 Dec 2023 10:08:40 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5127EA0EDA for ; Fri, 22 Dec 2023 15:08:40 +0000 (UTC) X-FDA: 81594786000.20.D5A6216 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 98D52100016 for ; Fri, 22 Dec 2023 15:08:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=none (imf14.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257718; 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=0tDqvYwFSGZxiPUTzlW4HNez1MU15vMHRFJdEDf7Dd0=; b=HSQ+pgmyR4SmZhnGUole0jDZzky7z3M+hdv/kq8HzuQD/+BT14hTFDeqOYonkZ0eB2W+PP ZC/dY+tpPCsx2dQdVOXQLm+gaMJZ53utJpYLJZqKGWpwN4Diq+1nkpXD/1y/nnRlb6ZuO2 dgahBHzg4tCFom4O4aGWfScSyNlUQWA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257718; a=rsa-sha256; cv=none; b=UZUfn3dAubh6KelDB7d7Ba+TzVxL9h7dytdJVbLbAZZgRMYSukcc8mqezOtkgBk9cxI9dT VzSR4Cc3XP3xtZtTdF0g3thmOKWUT1hQzNXST+Hmglbp5TDS0+OtE2n2PN/YDkIbzTsXas Cue9MEi4HfdiLym/jLHmPRIHCEI5+m0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=none (imf14.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=0tDqvYwFSGZxiPUTzlW4HNez1MU15vMHRFJdEDf7Dd0=; b=lyhf1Gv62XTy6SIBb8FrvCwqeh 1RaBZI0ukFpiajsVrAsJrsZE92GjbqPfI6XSdb1FjhFStqbhHLQjcmygA2wH2wRH8g3+05NMl9J+N 42ri8YHKlGerT9Tdd/88EoNNxcMX1xuIID+mZi3Rh1dTDwGk4ls0ipAks+FX5tabN81pWf0lIHPRj NReb01NKF+7sAICLZpkCUU6tt3stIcOSMyEuON9OYEzR6kMjSiPZ2RCiEQU7gotUP29X6VXo8q5pY aZiHY97ygOa2Pd81Mq1Vmwb+9UWfc+APNvoMxS87cC91low9T6nGXFJCO4S6AiYx5ltUy6dTrm+i8 ULWolkew==; 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 1rGh8f-006BNf-1U; Fri, 22 Dec 2023 15:08:37 +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, Jan Kara , Dave Chinner Subject: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Date: Fri, 22 Dec 2023 16:08:14 +0100 Message-Id: <20231222150827.1329938-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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: 98D52100016 X-Rspam-User: X-Stat-Signature: jwcxn98q1zmsaedp7wwk9jnioqt4xdf1 X-Rspamd-Server: rspam03 X-HE-Tag: 1703257718-487239 X-HE-Meta: U2FsdGVkX180BoP2a9brSjfkvffqmA/PGYmk5GEjQP5+EzU3KphCNAEeJ9jGb5VcEXlEQhkV8X/4B3lXaRx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1ODOHEX6RCA5BlNzYMRmUmrSBpMgcDFBR8K6DN0SD/1iZ8HBfyWYG9UR7rz+kS03G+HOBPOdNBBdJqufbffnyvftthnnCjHQXHqlJ3XSRZRu0DKVfV0Pxc+sp23g0FOt7Bcp2bvWZshsHTSIeOrFwcCcLcG+fxlIzAydAzQnAGFyKBohMJUYYhEq9DQ+hC77mG+Ajir8tg+vZv+Rsnnxt5DrSddNWVcnf+sexhfFZk5YN4bGtAirpDdaX9sNa5ZuUizR5JnRA4+1IeqKDAlVjuVHSW/10+x659naRBGwJGh9cdd2BrX7Cq7B1xp0zcCAZkDp/fWuw= 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 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 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; }