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: 196218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp927224dyc; Sat, 3 Feb 2024 01:19:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhBardEmsPjKI8OSERKjDAv7L3v2nokBxuE89uEWdKLXogBWVeYiBhhQL5JUEoSIajmnxH X-Received: by 2002:aa7:8298:0:b0:6db:cdfd:af6 with SMTP id s24-20020aa78298000000b006dbcdfd0af6mr9678045pfm.31.1706951990090; Sat, 03 Feb 2024 01:19:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706951990; cv=pass; d=google.com; s=arc-20160816; b=zAwNZmkgUeLMQq2xQQXOmff9ktCDvEFYFFPuzvUry9SF97ptsfDMjlrQqak20K7oF1 58KQRJCLqaHaHZKylJwWy/OXV55JfYEhhSjDinWDvuv6pAYznpGtmsmE7PlN3aE5v9u9 KW3oy9H9kAxT8Tlv5u3hJFjMuUZzVoEeeA3ojWav9lgmEJ8U9liRUKtFkTL02o4M1042 pb+Pmp+soeoGQhBZqsh5MugVcPTCdXUGybS7FcaaorYgemOR88jf6Xv58PhNsBFB4ZKi BVgMJfAJUUQCHy/M+du4q2kxXwEbsmsvNasLZWZGXsH/fBTvVxNtE4uN2iQ06vVxQ2ok OAvQ== ARC-Message-Signature: i=2; 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=aBLx8GrPTTpnrFrYwat6koWXvCPglp7/mI2LOOfVaJQ=; fh=aHHlzGX7hJOH06qLZuYGi9mzwCV+luBTFYe9Oa2XCU0=; b=ML65kcxREoYrehk5xE94oldTBvjkWXkDuXUlvvf3H6GloQ5+P0ojod/XXAALHs6B8U 6ESP2AAQn9lbz73nCkELNuZJ5ZEJc9/pFnc4ernJQDDidq9Ldj39nEhlD5gufXCgk5gZ MCSjPE4Rx3a7+TTvCetGwcInkh/gqBwi655bCoDwZ0xKglYzjaLcvDz+sGdBM50hyN+7 +j8ONrFVDiBUL9a46vmhEKrc3bpNtE7pZqOSKGhoNIBzUf2LTvtDnAjNr5k9jVi/Fjxs SLuWRACYPlmhzoRhyM5dwNWccwgikRMz0BE9gPi9d6z6c3uBl0IrAlWGQihMpWJLXMLJ BXIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FDgMugVo; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50962-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCX3J8p/2Yx/C4EuJOXIZQzJv+A9ONNvnNS81KdMVTidDfxxSC3GwGN6JQ0lJ6JhGQufSZPtTd5YbNtR1Z56KYE2PUTVJA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t23-20020a656097000000b005d8b8c4cc37si2828088pgu.295.2024.02.03.01.19.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 01:19:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FDgMugVo; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50962-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 52CF628C209 for ; Sat, 3 Feb 2024 07:16:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F06D958122; Sat, 3 Feb 2024 07:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FDgMugVo" 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 F12DB57312; Sat, 3 Feb 2024 07:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706944383; cv=none; b=r5Oyem+7ZgE1WWROLkNvCGkgY4dZucBYmiRCsY4LIa5QoHf5zW/Y8wWEPAF59CKTlyTx80goUK7AaM7pQ8R/Ct/SvwZIZPQtwSUy8BkdKJ/hcsg5hO2c+LWq9+DyTD3snoB1Gw35yKgs50Ywaw5l+JmdxpAeaFU9dD8y+p33jRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706944383; c=relaxed/simple; bh=tYS0fAOiFIhd5iBGGom3yizrN/cdEhJ6ynoZIQ4dwCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GszER4YpHFfc30E+kaH4bydwNtrmHGRKiNv8irYRfiAWJMamf/4gqbgu7HuaIZAcPqqdvk8seGpCXf9sMJGGFvG2I5oxyL5XGmcv5oxotL+zwbpdZyMPK5CUTu/nra9sgmMyXmtlCFq/3AqlT4SRV3Z4G+lC0JVaHqr4RYYbtYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=FDgMugVo; arc=none smtp.client-ip=198.137.202.133 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=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> 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: 1789868889953121459 X-GMAIL-MSGID: 1789868889953121459 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;