Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp301292rdb; Wed, 14 Feb 2024 23:51:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWubeXnrEi5gt4mKvspVksBGgx2pugmO99D24Bq8LYU82wL7oC9GvsHgQWtr4aWwQqWY+pM7P78IZx9qn8EUQ7xTCpY8JjKBl0FTTClVQ== X-Google-Smtp-Source: AGHT+IEIUc7felQMs6b0cjkBbI4k2UJ7dWE46k+ngHf7FfPzCjfiTkoUzOV1mfVI+5lAlytynZ/j X-Received: by 2002:a92:d189:0:b0:363:7985:eee3 with SMTP id z9-20020a92d189000000b003637985eee3mr946962ilz.24.1707983474384; Wed, 14 Feb 2024 23:51:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707983474; cv=pass; d=google.com; s=arc-20160816; b=fHxfWWzhN9GWfJPM5zrlbkJVenvYZ+6QUgzOKOZCuzp3dGzeqZ1YJOYyMXRrRmhsp0 D/KMefJhr1M/jSlfs7KT5juLcKGFo7HTeFSEXuQDaNbHolF+rp/7W+KOq+ZLRRAmj+SZ 4vXGthy/iI8Eg9l8qHm03K1XxA0pk6Kkp8w+rJHNUvS+90MMHBz22PqBYrsSJR2V/0Gf P7KaRaXH1oYs2IliokQE+pcqjGpf2BrpGwn0BL+J5bWnX0A/hoI9wdR+u/q4+HH1clVC oVDLLSk+txfepuU5BtMTOZ4jzSoPXks1VGTH5gWcgC+8nPeUprB9Ejhbj1d7pZogo5Hw 8Aew== 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=qyeWxkzxkEHhHoHK3zWehsRuRg4lFsIMJWfUKexFKxM=; fh=vEFzzLZgXRudP0t6D5y8lFkfuIJnQcm/zENoo1M8pvs=; b=PjeuYJst12CY6lwbBbQqHYfc3weNcAYDyrQ9z1LTDqhQ67NJ5xvv++AUuCC4jdPPzd wjgnK8zC0vv0SW3OjBz1DY3zuMDQmJ9/50mAmWWFmup5TlFV01CKdKwMKmA/G4kDc9Ps cCWcpEJ1vkrQB+SLMfabNIt6uVnr/kKeg979/55ml+Pltd2LpHI2vrG3S3R+yqUO0td2 DGhgjVyNXRzLOSBRBAfaQHNSSmIDBDdIBU9b3nfCSxwkr+L/qLwzY2P3l3n/2vnXgYBw eJRG3cnh6GBVEREtWqBCuGkfCci/p2Ok2olzQPdejc/pWlH1fZ6WWoBmvQM6brcqvEmf DlZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="UwOda/+U"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-66337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66337-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k5-20020a635a45000000b005dc916d9df0si692622pgm.85.2024.02.14.23.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 23:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="UwOda/+U"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-66337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66337-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3EEDAB297DA for ; Thu, 15 Feb 2024 06:41:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06B6F1C68A; Thu, 15 Feb 2024 06:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="UwOda/+U" 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 D0A041BC43; Thu, 15 Feb 2024 06:37:33 +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=1707979058; cv=none; b=Qo2HzhyxJjS/C2PBrKgqm9UY6Rqo0+70GUS7KcE850viLYnHijwyJtrjNWm2QFjldAqthyy+S5/D2mtNd2KYWCyLQET2GcAnAn5glUCm+xdz77r4b8xuK+AN623GKO3k3IiLOERMsHZdb9xf4Z88nAO3dnKPWj6K6nHZmo/7zag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707979058; c=relaxed/simple; bh=Res0BRtB7D7IhwdD11hr1SLaLO8wh9o+5oCaykenzqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dMVwyEMNU8Y0eV54dfvjUaghWfS8StsU8TgohaviLuXeFCPh2CdfkJ2CMTUkWNt7zrKnHrgcMb43h7sCfa434zL5T8QOveoAd8tyCej8in4jwLe/tzU3CQiMQ8jjrEISwbGe+uYype52DSxnqU0HncmnrTxGPSK+JaKQutmnJoQ= 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=UwOda/+U; 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=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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; -- 2.39.2