From patchwork Sat Feb 3 07:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13543908 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 6657EC4828F for ; Sat, 3 Feb 2024 07:13:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED97A6B0092; Sat, 3 Feb 2024 02:13:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E611E6B008C; Sat, 3 Feb 2024 02:13:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDB646B0092; Sat, 3 Feb 2024 02:13:01 -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 B8A376B008A for ; Sat, 3 Feb 2024 02:13:01 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 99A101C1272 for ; Sat, 3 Feb 2024 07:13:01 +0000 (UTC) X-FDA: 81749625762.03.5FAEE63 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id 05029140009 for ; Sat, 3 Feb 2024 07:12:59 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=FDgMugVo; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706944380; a=rsa-sha256; cv=none; b=FRMnNqL8eYuuLrF7f9VHPaxeH5QBRuh7/5vWOqw0UHbcVQVhZ99Go2aqHJD5jJBYdG9KQx pdtpBp9RCzYWOct3ixr1+fVAyaqxLf4ARirHTc7J6I5f9ag+eOFh0Yk63if/66suTbT/u5 6NtdCSqmJ6WWq6JlEytYk+LtuHmvtOA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=FDgMugVo; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+a0ed29cff9639d748e7e+7468+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706944380; 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=aBLx8GrPTTpnrFrYwat6koWXvCPglp7/mI2LOOfVaJQ=; b=D86wwg+UvIOdlhmEjEaGOtLja+HRy30JiSB2913S7alda9R8RxA6cRF1a6udqkfjw1SAFE yruZPQKqnL39EJ5kKEHXp2UZCj1A0deXv17eZuiCShLXdnDlRPlOJoEYJW8+vX//6DYA46 EuIGvZVxyhBCiMHl5An1yepCCWHQQPk= 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=aBLx8GrPTTpnrFrYwat6koWXvCPglp7/mI2LOOfVaJQ=; b=FDgMugVoB7MSUNHernp01Fwg/x MO+pR9JFMoCL9rwCqYotraUCpxDX06NW4fyeZ6vX5JPS0X8tpbgo7moefxhXVI67QAr0Xxmzp5E37 psFmoZYeys27ykwrnviTUvz/SmbokAZR4N9bZEyFSFJOJlxuJ2QZbK1SuEFbb8Vdsk7p/XGeR7TL8 +XGOB5d0OGem8uOS4FN4sM1iYvLyTDpZ+wlMffmwZiv2yPxszrIZH53rlSPctCCQy5qXCcVdpqrYW 3kZ1BMlFOw32O9rX7U/qB7G4p6dLZExzOJuw2VLdjcwXSgL2j1i6HzWGmXtoS3nBfwUSXDi/FI0fc ndPdGBiw==; Received: from [89.144.222.32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWACv-0000000FkMz-41QH; Sat, 03 Feb 2024 07:12:59 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/13] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Sat, 3 Feb 2024 08:11:47 +0100 Message-Id: <20240203071147.862076-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240203071147.862076-1-hch@lst.de> References: <20240203071147.862076-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 05029140009 X-Stat-Signature: m1rkkcy1otgr4ipygc6474dcezaw3a4z X-HE-Tag: 1706944379-962684 X-HE-Meta: U2FsdGVkX1+BKFkCSUKgM7xWmZaaQ0y/uBpwDkVUUuuiLSwSqeNKHgmaRmS2QUEkrROlknzLs7fMALFAog/xD073rMejMKfDf37eJH3JE7ltxGlm4/TKZl2q7fPhpsIM354X1tBN1t9ovtSGtU3t1AyX9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2CZACams0P5IFMCQcLRtTQ0wvAJQxGD4RmYwbYvJT/AbB+msJATMa7t5MNarEZv9UQaLm4rlUcehhDckU3xCuzX2MHZgw/d+Xd/KAv6c9WtghrauzyVA1qePNNOJkKbzElHHcA93v6VW/ZjICNbeWm/YSAperlpoXJB5oN6XBIV5LPrWknCMwRgsAP+ezHrsi/5fiz+3ltGidq1djs5yJ5y3mhW+wl1ZrQvpbLaKyWUm4Le+VZs2NmBtmksSjQUpZxjKxPDwQ== 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: Jan Kara Reviewed-by: Brian Foster --- mm/page-writeback.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 5fe4cdb7dbd61a..53ff2d8219ddb6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2577,13 +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); - mapping_set_error(mapping, ret); - return ret; + struct folio *folio = NULL; + struct blk_plug plug; + int err; + + blk_start_plug(&plug); + while ((folio = writeback_iter(mapping, wbc, folio, &err))) { + err = mapping->a_ops->writepage(&folio->page, wbc); + mapping_set_error(mapping, err); + 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) @@ -2599,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;