From patchwork Mon Dec 18 15:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 180505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1329958dyi; Mon, 18 Dec 2023 07:42:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtlfzyzhQRE2cvVspIflzh08bkw+QEHl4jEIK2XHv8Da9k17COHr72rAMK7gw59eFKUzsU X-Received: by 2002:a17:906:a003:b0:a23:682b:751a with SMTP id p3-20020a170906a00300b00a23682b751amr493107ejy.108.1702914141110; Mon, 18 Dec 2023 07:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702914141; cv=none; d=google.com; s=arc-20160816; b=h0gwjaG/9EYvslHc51Dl0hPk2c/fvXDypWKX2rT7aPry7NL+Tn6uX2PHPPB369OxB0 F/ePCHw3kAa8JhX/bk6wBj9dA+QPW6pedPx3Fh5sIUV0Vh9rBeRXuMxCTyUvtPSgGIeh 8EQfgh/r1pDHu4HwgMYPYRdGbDkHj+gK6dMeMjRWvsZR9YSSeyhLUVEHQLg+DRzSJSWM Vs/tv4IXlP1NL5TqJZc4kQXCOb6na0BR3QrrBW4wdt8JHytHDgjzKD6Tqh5KH7f8sPnb VM4wYr6cKE2ZGeorTp7CjyzVY5VYQqQp4M6w6RpSyYCd9PWO1ePSVferyKNm5gkNKitg M4Mw== 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=KurkZBc/b3Q18ZfxQxDEcSa/TUrlUIiFySdkJrxwQjU=; fh=m0HBXuwgOCKat7wyuY7vstPypqMqxNmINnjBv5+EUjU=; b=Q6eTjgGwh0SaNc8nSsXaf9sqC5XKnFASaaRJKwei6w7JpEk6j4a2E9+AmDBnZeICyw 36TlRDFP2TwQoECIhwNyYeJv0cjxtaiL0HOmtEECjGnnNIaym23JMvKqm4rNAQAc8e1n t3Ozx4CA2KqfCxu0RrRkOGcFuV767kpyF0pVMlBrMgrrtbo3meuiNoPnY4M7DTydTI1Y UbW29XO0s6NRGR30HaLUWsA9y/K+jAyrl34RovjHw5jyEU/kFAf3MP7TCLG3jjUy8skf TOLbTjppSVlCgaDusVqGcUYoGZR1e8oPdZZOCGRYFavLE0Cc+NQaDgKb/ZFG5/5kaEXf WVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=LVqlIw7q; spf=pass (google.com: domain of linux-kernel+bounces-3959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3959-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 m6-20020a1709060d8600b00a235839bab9si924751eji.735.2023.12.18.07.42.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3959-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=LVqlIw7q; spf=pass (google.com: domain of linux-kernel+bounces-3959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3959-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 600391F22BC7 for ; Mon, 18 Dec 2023 15:42:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4285C74097; Mon, 18 Dec 2023 15:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LVqlIw7q" 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 56A1D498A9; Mon, 18 Dec 2023 15:36:48 +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=KurkZBc/b3Q18ZfxQxDEcSa/TUrlUIiFySdkJrxwQjU=; b=LVqlIw7qs07E3gyDPGZmtD0XyP 0J7DxBmpXttZFRG+IwdLRoQ210NJqeMDCPwvx8pcytOPK4WaPF5iALq+Gere9cAAFy5YHYuoayf7o WKwlr5cnMo6YK/xL/Cid/5e4NHsvCFFUVnAZk6rEgRm6ta5km+tzbpG8tZ3u4VQX7YjwvdIvd9La/ UUs/2czN4LRM0MbYNCm8auOK1c94pPR2Eurr2Se1DpfMw6swR2Hs3y1wij2cA5jK2l4wHgZychHBa Linj7FiVDQk01OoYZwI+pB0Q7q0czwR2HmdVCNnS2czPrextgY+XsAC2CLKMbkZM68/VA3sMoQD2r mAGHD9Yw==; 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 1rFFfe-00BEby-2D; Mon, 18 Dec 2023 15:36:43 +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 Subject: [PATCH 16/17] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Mon, 18 Dec 2023 16:35:52 +0100 Message-Id: <20231218153553.807799-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-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: 1785634898180874388 X-GMAIL-MSGID: 1785634898180874388 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 Reviewed-by: Jan Kara --- 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 fbffd30a9cc93f..d3c2c78e0c67ce 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2564,13 +2564,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) @@ -2586,12 +2594,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;