From patchwork Thu Feb 15 06:36:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13557448 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 EBBE5C48BEB for ; Thu, 15 Feb 2024 06:37:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B40F6B00BA; Thu, 15 Feb 2024 01:37:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53E486B00BB; Thu, 15 Feb 2024 01:37:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31AFB6B00BC; Thu, 15 Feb 2024 01:37:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 157206B00BA for ; Thu, 15 Feb 2024 01:37:35 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EA90D80F4B for ; Thu, 15 Feb 2024 06:37:34 +0000 (UTC) X-FDA: 81793082028.04.B9DF613 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 30F1D4000D for ; Thu, 15 Feb 2024 06:37:32 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="UwOda/+U"; spf=none (imf07.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=1707979053; 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=qyeWxkzxkEHhHoHK3zWehsRuRg4lFsIMJWfUKexFKxM=; b=tsODBXlnA06T+wsJkuJzMpV2QZPA811tJTVN8T5AKvCeJtwqxmQiyVMuI7KsJv7EiMeJHK 7mKHCjHJ6bB9jcvaNztFBtMRqNAXd0j4k9aukHaUcrg9UGDww+UhJaRoIBK/B6FblKa9MP S5Ja3uHTAgCdirBnOwUQleaYzuSUecg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707979053; a=rsa-sha256; cv=none; b=l44NBSn5ZOgMODb2WV+J/A+9lJmhH6GAUWRegrZwztwsVIANAf4lCZzsUD0fdtFDT6ctRM lKgmLZ+0LGn2SvBUMPjmpU4f2k6JtGQt4YQ+DmB+f28cpRfa4xdyZZijYwask+Ws2vXZxP ohko6ExSLxU4TmAZUsh1/7bz5MhnyG0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="UwOda/+U"; spf=none (imf07.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=qyeWxkzxkEHhHoHK3zWehsRuRg4lFsIMJWfUKexFKxM=; b=UwOda/+UIz7ZD9dTkjlRkVaWv8 BWyV6iZujMnIJ6XzWpZUfU3pVZyrYpLVeDr2j1dT98vNxZwx+F68FuPWm1GYmmmafxg61VsF198h/ GbkpZ13apJgwrnyEzYelBVG/igddDpAHlkj8APo9yuiXnMkPfZ4maR/X4PE/jgT7bYI9d0aHNkN1B le6OpSRgWaeiaw8k3kzD6BlSuMVrfYjljZybQw88yGpIKXWXFTXNn6SbT5mdJXYoQuM4c9Gz76mIz zCqOzR+cEcZviPmZHWqEiM4Tp4RyhRbUK5E4Mm+ZI9VFSwjiHnW/eV/Refh3ZBgN7CVpr5CHh989H wQBZ/r6g==; 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 1raVND-0000000F74L-3wZ0; Thu, 15 Feb 2024 06:37:32 +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: Thu, 15 Feb 2024 07:36:49 +0100 Message-Id: <20240215063649.2164017-15-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: 30F1D4000D X-Rspam-User: X-Stat-Signature: djkzw4bym8kyri3m91837es8txfdaiai X-Rspamd-Server: rspam03 X-HE-Tag: 1707979052-968359 X-HE-Meta: U2FsdGVkX1/Vh2DLg38zxyszTlbMwVU436Q2liXb8OYShH7m1+EmVtQ1T2t5LjN6bwVQOkjfvktHlB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DlrYWAx6NU/JIwgexsBaWTYM6IWWt0SaTOwqlioyZW156KbyelH/DXFlDYQZLQTX3rtBu7N+t8V+pDeKUxtacIxjxaBQs0qaiYhkPzH6G4+RrgSwmvx8+Ylx2F8UclwwoT8OE2Wk1jufynNOnW3B17XE4Kr5YqP05v+xbCD8fyhmUoAUDO5jjjwOq/3QoRDCg4A/ONHotY3hbSHemTHMpNfqo90Z1lFZINFTx2V7ByPHTgpNwyLw7KOb3MgZwZIeTKrrCOerEiXm9eYlamdllB9GIN8hZQ6HF1Aq+ePKhK1dAXHE+RTMm9nhH7wXbAnebsqtcDP2Rztw+HhSD0Ko03ALsDorsWe0hrrGtMg9l2GezRxHAdVgU79Rbwu4A2 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 | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 3da4345f08a335..3e19b87049db17 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2577,15 +2577,25 @@ 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; - int ret = mapping->a_ops->writepage(&folio->page, wbc); + struct folio *folio = NULL; + struct blk_plug plug; + int err; - if (ret < 0) - mapping_set_error(mapping, ret); - return ret; + 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; + } + mapping_set_error(mapping, err); + } + blk_finish_plug(&plug); + + return err; } int do_writepages(struct address_space *mapping, struct writeback_control *wbc) @@ -2601,12 +2611,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;