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: 182685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1125555dyi; Fri, 22 Dec 2023 07:10:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtyhAOml0BpSblLkcIMkJdZpjjv4Qj2as4+8+atu5vNA7HREBDGDMuXPFMiaqBU9rnxCb/ X-Received: by 2002:a19:2d12:0:b0:50e:5082:a868 with SMTP id k18-20020a192d12000000b0050e5082a868mr722622lfj.104.1703257807493; Fri, 22 Dec 2023 07:10:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703257807; cv=none; d=google.com; s=arc-20160816; b=vqBeOBazw3vIswJRhynu+nkj3rMqrE6GceZAxCQmfjeCeEAo7DcYCw4touVdg/JIBm rLu9MoU4kUUk3yi/8eQHgliX0wY+VSr8zpFQ5c1f8E/Qbwf9bqbT/l4asBMXUJxQwE0j 30caKZw7dpy96a6dgQjCYTerCh0a66ly9qi2I2ltMk7Cz0LMXVmHpDqkCpi8b8+GoIEw W8X4/e/SmvKy/WEyoacwpi9G91mCH66yQng+vITmMMrAQZi6IDSrVoNu9xYqm8dMs45t BBoA5tboOpEOeHtX3WZkWKAt+Z4Sk1nH5NcHlpQO/O3J1I5Z6xVOhQf67WbdSmENt+nw g7xQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9814-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a19-20020a170906685300b00a1ca020ce03si1767906ejs.787.2023.12.22.07.10.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 07:10:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9814-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9814-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1D6521F2833B for ; Fri, 22 Dec 2023 15:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 683C928DC3; Fri, 22 Dec 2023 15:08:46 +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 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785995259054927424 X-GMAIL-MSGID: 1785995259054927424 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; }