From patchwork Mon Feb 12 07:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13552755 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 F13A1C4829B for ; Mon, 12 Feb 2024 07:14:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B42C6B008C; Mon, 12 Feb 2024 02:14:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 73B4C6B0092; Mon, 12 Feb 2024 02:14:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 601B28D0001; Mon, 12 Feb 2024 02:14:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4D7EB6B008C for ; Mon, 12 Feb 2024 02:14:40 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F0775A07C3 for ; Mon, 12 Feb 2024 07:14:39 +0000 (UTC) X-FDA: 81782289078.20.BDB9663 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 5927B180018 for ; Mon, 12 Feb 2024 07:14:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qGm4DgDh; spf=none (imf06.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707722078; a=rsa-sha256; cv=none; b=WtHgDkN4pvM+BUeSqSEKVu4zZydTXZo16BDBf4vkoUJ1X111SNPf5StmLsieRohU/1R6Cs dXZBUc/vR+1a2O7fmRnO3QGLh7VM37jv6CtyjxikNguZoqn79vd7fzCF3kVDwA5jiClWQE KpLidUZo6YU7RJXIYfLBPPFNrODH93E= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qGm4DgDh; spf=none (imf06.hostedemail.com: domain of BATV+56c964bc8172c8a9ee6e+7477+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+56c964bc8172c8a9ee6e+7477+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=1707722078; 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=KFNTqb7k3Ymo30IuEwDaihs1yCQpUBV3RN+kFxOoV/I=; b=GaYHLwH/wbI82mIh0XWkkW5aSt5JzNUNc3BFNobtI4JG/b0+3yKKbEreCpIbS0PedU0gB/ nvycnIi0PR7OsAoF2/gaFMt7dpPJYkXJrcuK5+kraID2LOdBvShM29iv/NqzvslZDNBPyu l4awRIF/O1RJGVA321mEOpB0uXMQa3A= 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=KFNTqb7k3Ymo30IuEwDaihs1yCQpUBV3RN+kFxOoV/I=; b=qGm4DgDhGagw28iocodC5iIhS6 xsiMjPN63KLn6sFjMYCPL7iseVbubE2wS8w6bXJ+dcbmYvOHEWzOAZUcrSN0z9s6qgqeA4zE+v25Z Ieo4AhffrF+snI/gQkbKzpqjnhFvronw/KWUEfMYR/mvFkRA7Rkarbpg0iWyZZlXzrZJHp4jqfsi9 q9boZv/wYg0kxsnUDqX9688gwSdlI9bqz14Z3r5AjizGcXXBELXp/TxTAsBR1zhWDROEl8xd9MQ6z QcXvVjnwYut7/ExXvXXIN3edVcs960N7aYgwjVh71uI9ph52Edo7WhetgJdrGm5ARyCfAEeyxZjds ynVt7v1g==; Received: from [2001:4bb8:190:6eab:75e9:7295:a6e3:c35d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZQWT-00000004T5c-0Fro; Mon, 12 Feb 2024 07:14:37 +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 Subject: [PATCH 14/14] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Mon, 12 Feb 2024 08:13:48 +0100 Message-Id: <20240212071348.1369918-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212071348.1369918-1-hch@lst.de> References: <20240212071348.1369918-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-Server: rspam08 X-Rspamd-Queue-Id: 5927B180018 X-Stat-Signature: ugjizqdghpmw8duhywwizo9ouyebwc31 X-Rspam-User: X-HE-Tag: 1707722078-386430 X-HE-Meta: U2FsdGVkX19m5rXeLXfrQ5GP8AiUm5xItHzCr9APtKP8YAVG6c+937WY/K0wIii0zsB/Eq00+dwdJdDPMNqLSFgz6zogtXhVFOgwjFT7l9s95GGIBu1AA5WizrEKl4qZkUxVR/7CXrkoVQnXpO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jkvudapjiw2ukIRF2hgIaG/mFaxZuuGONXlSt+Bh6WviDRStR0Ynrxw97OVl3OO8fDSubAMQT9iw3THYfgj2EAUYTMm+TP/UDHgUvpHoQSoHZeUtxUiOhdJMWN45of90VnnK+0w8359cHkcvV9qkhiRwIjR9NMH8B1UYCu+SSq9NK8zP9C63u4mXocg/V6ayl71cCywK1wXdbuYmoKK61wSSCbtZ1p+hGsUumZ5GDLFHvQf7nsNux0FMKvmPHH8yITp8xC6+W7RprlZiXO7kCH9zSSkFUEtf5cU1DtXuoLpStgPOEXw4GYREnKA 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: From: "Matthew Wilcox (Oracle)" Use the new writeback_iter() directly instead of indirecting through a callback. Signed-off-by: Matthew Wilcox (Oracle) [hch: ported to the while based iter style] Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Jan Kara --- mm/page-writeback.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 1996200849e577..2fd83d438f92bd 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2577,12 +2577,24 @@ int write_cache_pages(struct address_space *mapping, } EXPORT_SYMBOL(write_cache_pages); -static int writepage_cb(struct folio *folio, struct writeback_control *wbc, - void *data) +static int writeback_use_writepage(struct address_space *mapping, + struct writeback_control *wbc) { - struct address_space *mapping = data; + struct folio *folio = NULL; + struct blk_plug plug; + int err; - return mapping->a_ops->writepage(&folio->page, wbc); + blk_start_plug(&plug); + while ((folio = writeback_iter(mapping, wbc, folio, &err))) { + err = mapping->a_ops->writepage(&folio->page, wbc); + if (err == AOP_WRITEPAGE_ACTIVATE) { + folio_unlock(folio); + err = 0; + } + } + blk_finish_plug(&plug); + + return err; } int do_writepages(struct address_space *mapping, struct writeback_control *wbc) @@ -2598,12 +2610,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) if (mapping->a_ops->writepages) { ret = mapping->a_ops->writepages(mapping, wbc); } else if (mapping->a_ops->writepage) { - struct blk_plug plug; - - blk_start_plug(&plug); - ret = write_cache_pages(mapping, wbc, writepage_cb, - mapping); - blk_finish_plug(&plug); + ret = writeback_use_writepage(mapping, wbc); } else { /* deal with chardevs and other special files */ ret = 0;