Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp858117rdb; Fri, 22 Dec 2023 07:09:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHd7mW0p+19vZZOi7uXHVPAkthQFZeTDsv77BJcteXinPI3XD5ekyfTgpscOBtALgKHNKDr X-Received: by 2002:a05:6102:3f46:b0:466:a1ed:c7bd with SMTP id l6-20020a0561023f4600b00466a1edc7bdmr1203649vsv.18.1703257777126; Fri, 22 Dec 2023 07:09:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703257777; cv=none; d=google.com; s=arc-20160816; b=QsSKRS2zncIbBYOX7QbKRjZf7n0wP3JiwXU88fazrvX9+svdle0qcVcyL/QBCAyPjl Uz9XUMA/ioy8aF7+0oNhhhS6yLkXkKqjhHbcTHxjHeoHl9Ep+8UK5PIYpWqWJvqlL7T8 ZuBCgCyGyih8Ewm9xLRnBDHNtlBXTE6TAL3qE0HEBdcUeyiZLKshzJixLSvUWznISZ2U teo94gsfnsnMMx1fWuN2EFjMt+slpQX/b7qiAf9Ir+mZLd9+VIbxfasjo7lWYKoDw1Mq do+6JBwtSFAbp8LeAzuvFXxKdPyfXnrPywCgK39GMGgNb861Yz/YP5CejHsiNS6BrrQm l8Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0tDqvYwFSGZxiPUTzlW4HNez1MU15vMHRFJdEDf7Dd0=; fh=hzpEVxJ05G9gyZL9WVyKgOEGxITvmFSuTcKyr2ByStg=; b=ojHPiQUbxPlr0beO1A9EjxcuNtH7MpgdIKgA4ECvS0m+bRkX3PTbqMBBxlNDgRZE2B ulv2gDrqRJZ4sb+glA3Hgafr7zx9lqapilcEizzWqxwScRKinC7l8jg4wELZmfkk0JHW dDhUUv4lBVxAwC8LLWDIJ2iT2jJms7DlvdcRQaqsO+mPnMmFUVJ6mPla+Zla34nFDbwC 8O/jvq7doKhlQybc3v7nwdFE0OyurO+lAXudKdLnAc0YEpFwld4gGiLhPi9CTutoivVO 04bgfPFF8CpCryVCrc0RwewlbXWcLh278qRBmgCvkUpdQqXVLx6G0hyA8HJI2o+GePFe dzqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=pass (google.com: domain of linux-kernel+bounces-9814-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9814-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h8-20020a67cfc8000000b00466e44ef8ddsi135054vsm.546.2023.12.22.07.09.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 07:09:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9814-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=pass (google.com: domain of linux-kernel+bounces-9814-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9814-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D7DB51C21B6E for ; Fri, 22 Dec 2023 15:09:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97FF8250EC; Fri, 22 Dec 2023 15:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lyhf1Gv6" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FA382377F; Fri, 22 Dec 2023 15:08:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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; } -- 2.39.2