From patchwork Thu Dec 14 13:25:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 178736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8541744dys; Thu, 14 Dec 2023 05:26:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IE84NJIL/b90zAaBmvuTOJLXdeZbx27glTLBwLT8PX5Bx7XawJ2VtkMoP9glem3tKfIFIJn X-Received: by 2002:a05:6a21:170f:b0:190:af10:3ede with SMTP id nv15-20020a056a21170f00b00190af103edemr11839694pzb.36.1702560407349; Thu, 14 Dec 2023 05:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702560407; cv=none; d=google.com; s=arc-20160816; b=iZNXGq42HpAo3KG+8MVCbm3mI0rpkkY0KgQr24YX94M7sOFYbHjWDrERAYzgKu/qgk LB6EHBetbq040HfRrwn77Ql5kqoWfCsqlWs+b5zGcLJTqLl+1ABkbq4EWb52rS7KYy8C qV0poNnZpLTVG637FkQt6Sddp0EZy9U5pT9Yiiq5zUSFdYUgSh7mQuilEbpbcsmWfRcm 1ZNRsqhkI3nZPlKnLnYMHV0OE77l59lpCvRt3576bZDOm4M70MnxfMVjf6QdHx4Exrdg EWm1XRkMU0smIKn/xwShyXMUMUVM4KoJxrfa9tAww6b44udinQQXcnCjGbbqmfzjx/d2 oKhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fSSCwYEFU0GoMDegAuKi55gdXGuKeNZB2TyfoMX/Y+w=; fh=s6qbYcpKmY0AEsK/gKDpT3qiaGyyaU+hQ5h16uVwDEk=; b=SCPXKUrBfG6JYmnk3878Q1Cv1eHN6IHG42VJbOwbSGGqTu5NV5Ibf2xjWk0mZC9YP/ G8FCW/9phVrKvryPyF+rcFNa2dCbvLBv/mZejSaEs8s+6omeb9fW4krOHluvVtkSBjRC 1CR6BApssgwTLNgviuAqBqQsNFocTWi9RN53RFJLm4aaxLe4l/h8ioMpxLbJQiwt++iz ewYn1m0md9JYWvNwf6CnhUS1r8N8y2i+4rXD0P/dVh27hkfKH6EMpdpV951wNeMKp//s 0rhqn1F79ooXzKz+c7KLY4u3AjkoI/l6bX+m0dGTc11xq2IgW3I+6RkidvZsr11L9e+B nrBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=WeEvgWpq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id bf15-20020a656d0f000000b005c699b49da1si11316829pgb.873.2023.12.14.05.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:26:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=WeEvgWpq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 9D35B832CBFB; Thu, 14 Dec 2023 05:26:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573303AbjLNN0e (ORCPT + 99 others); Thu, 14 Dec 2023 08:26:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573347AbjLNN0b (ORCPT ); Thu, 14 Dec 2023 08:26:31 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB69134; Thu, 14 Dec 2023 05:26:31 -0800 (PST) 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=fSSCwYEFU0GoMDegAuKi55gdXGuKeNZB2TyfoMX/Y+w=; b=WeEvgWpqJWmJsBWQKrtwqaDcsx DdhfJGsb6lyX8JGqp2wBtNE8ntogWBaKjs0SOJvYsf4t1u1vtiknCwTL2Y5ngFQF0kHZAg2e/Wj3C /lKhI+vk7w1OAoB1r0oIpvJFGTE706ExEjmuIYhCM55Nj8hvhRQUA9mnbsQwwHBsnj+d7VdCtZaiz AY81oAYmK7szPOgEXKqDSPEWg+V3BHzPv5gMAzb2bezV/TCEPLMlfxFWEyiAH64GqL7CY0PY56S8R 8G4fBDbKysnieizxi5pWpxe++ocMLt+32i5pQpsFojwROwJzzgv1IQ/wHyjc0ZdcJzzDcdle2JPLh 7WwhmenQ==; Received: from [88.128.88.27] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rDljT-000NGp-0B; Thu, 14 Dec 2023 13:26:31 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , David Howells Subject: [PATCH 11/11] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Thu, 14 Dec 2023 14:25:44 +0100 Message-Id: <20231214132544.376574-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231214132544.376574-1-hch@lst.de> References: <20231214132544.376574-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-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Dec 2023 05:26:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785263981765488939 X-GMAIL-MSGID: 1785263981765488939 From: "Matthew Wilcox (Oracle)" Use the new for_each_writeback_folio() directly instead of indirecting through a callback. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig --- mm/page-writeback.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index e4a1444502ccd4..338021bdd136b9 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2558,13 +2558,21 @@ 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 blk_plug plug; + struct folio *folio; + int err; + + blk_start_plug(&plug); + for_each_writeback_folio(mapping, wbc, folio, err) { + err = mapping->a_ops->writepage(&folio->page, wbc); + mapping_set_error(mapping, err); + } + blk_finish_plug(&plug); + + return err; } int do_writepages(struct address_space *mapping, struct writeback_control *wbc) @@ -2580,12 +2588,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;