From patchwork Fri Dec 22 15:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503409 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 9A57FC41535 for ; Fri, 22 Dec 2023 15:08:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2654F6B007B; Fri, 22 Dec 2023 10:08:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 129DF6B007D; Fri, 22 Dec 2023 10:08:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBD596B007E; Fri, 22 Dec 2023 10:08:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D17096B007B for ; Fri, 22 Dec 2023 10:08:34 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 85443120F4C for ; Fri, 22 Dec 2023 15:08:34 +0000 (UTC) X-FDA: 81594785748.07.6C9FB12 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id CD9F3140007 for ; Fri, 22 Dec 2023 15:08:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sS1lzdSK; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257711; 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=UHLYB53YtGsTugfyc+sHmLVVrbGg0LS55c68Xz8vbHU=; b=8llMHXARzTsdSPOFqV4FgmUQZBmT8FwN5QhXfx9/DVpMimt7/HC5IVGBhJ1ZnIQr1U8wNd dpy3AB0pTrqViwrtxdiT8/K8Dn/jtfZrqE+9d9Ikq0PvXILTtPwvmE8eFSOZrA8WWrw906 WlaZ+1H89LaZ837egbysAI7Yb9Uc0XQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sS1lzdSK; dmarc=none; spf=none (imf23.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257711; a=rsa-sha256; cv=none; b=SXNxBVVuaaSu3fIavykb9zwWPlqddbVDpwGnwb6sudH0Kf4/pVJxGzN3TBImD0mrwQAny1 CXoppcoLEhs1zSMpOHxfEFTRCI7XBZS6ox+0kPIypwIfXDT4h7XxOc3NJB/2kY8AJwdXRn Tb4g1aHrGjSuXNeBCiFZ9ZJsy6cdsh8= 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=UHLYB53YtGsTugfyc+sHmLVVrbGg0LS55c68Xz8vbHU=; b=sS1lzdSKCtbDDt5pryAreVWTDH SjkKoxC7B15xtfkczw8hl1mfsQbLTllwOTvsAXunotk3Fp2hLQPGqlwbaVRFgsU0ZaAcyw6VQH9k1 kk2oEtaDSk0x88fUWX7NBy3ajJmxXiSLpCr+H/7QvpWjlhwAweh5KmPWDZEljN1iFlOqxQ2VknBah Wlr233mRp7xfWL07mAdOfNycfh9hy4Vmab1nwypZqdomhnN5QFuas6w8rM6D0zdOlQYfkuS1eN4g4 xf7tOIbwqPtd8oS5XwjiPBQoJYrMUK5MnXGVXxw9sfXfr8TzwUqZ5dVcUotykFxtw2mfLOg0vKZON E8ZhJhkw==; 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 1rGh8X-006BLb-2P; Fri, 22 Dec 2023 15:08:30 +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, Jan Kara , Dave Chinner Subject: [PATCH 01/17] writeback: fix done_index when hitting the wbc->nr_to_write Date: Fri, 22 Dec 2023 16:08:11 +0100 Message-Id: <20231222150827.1329938-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CD9F3140007 X-Stat-Signature: j83zq9di3qd7x5mxc8dz1ssux17rb6ue X-Rspam-User: X-HE-Tag: 1703257711-253626 X-HE-Meta: U2FsdGVkX1+DTuqgWSipUuTzDmU4emDgvOYsm0kuM/lGnq7QK0v7TN0QmKZQYWfaCm27RP7b5t+kvVeJKGUgEuMOUHh0XTrtLgGZ1PJZhjLiiSo87DmHDIm8KrKwrtRmdtitvYhpMhgvMm3YZy9Uags9XzLa4/fZYLgOQa0U/oQAvfUOQY2y+8BO9wM6YoLY/egrtt4h83K2DnfVUh5+DXHeZc9l/DuJf4D9KAraDiIqZbTBG8RgTNqkMHf2g/F4HdaVnU24GNug1lcqJjt5TLpUrLBDwbf9v0BH65pkDoE3gZf+ropEFK8P+ziYmQyHvM9nZ4NCN4PPT1zOUm7J1JHNb779njIxCe0UZirJumpPJvS5dwWGB1NXQTyy8Rio7rsqORNK1GFqbD8LaFjsaRfYjfxMVSbjgMyEBUyjAJmZL8SGEWWwbYche1r+hsImguFFVKa0QuzKM1MC21i+VMpGSSpSVJ727xWVqV2R+dUOFkVIvoFrmmOjhF11X7+BFPQfU2/gfZQ9c/I94SMlmv7hY2sBywu4iRLprD6otsBcWdYjKJCuC0Gl92zbhSHpDYFxoQJP6WQjclKzLoiBb7SWhowkaMx8orasP2lAhgN3stYcBoun1i6sfHVi+7TEBkl+bpWQsajzmLnml+CWe/9WnKEx+IRIUprIXV7YDbByLE/4Fz4uSnBX5TXLMqz2GNJzH7Hm0d/qC/TN4vshmJnBSijsbM4wkfZVKi2RfbmIPj5yK2THZorm0bi2K/AlCo+BaO2GPMJjvl2eEEgXcHAzsJsyiVKXXkPcMJ3VjFB7DePiL8sZeJhpewfWcVVc8qcveNdwk13HdPWhqm9KX87Wy0nSmXzu1SUYGatxCVtry05vpR3xyWF83ekYC/EHvNHHBlvnEHAyEW1yOjk5V/4FRn8DrFJ58XPtTji8Tm65sLxaWkNJpntTJ1HappCL0S9MttZbePDO0iRX5XI 5ubnSn5J 9r+vhZJ3pd6UAiLsYfsC4pisZPboE5IHWlcjoyVfAhEllSSRrOH0jVOHK4SC0l9LBTtqqQ6yEcTlK+8LOv8Emx+tDTT5BTv/bmHFXilIpx47j2idNrysfcbv1dxa+MZCd1nOLuyKQIdzPdpClrVxSME2o+eh+rEZH9n9S1EcLiq58ZhKthvaGyVALAFQlGEk3Zu0uWgFJ0Z3J5JY5sZIjkFtLXz+DdZnglo6t3tjXcEVqPD9S9DWN6dIx72yVABkcd32jrh/PabEYI2H3Z2S3ObcKvvRKfjTeCzVGHh1lp08czt453mLM8FIPWyZYTL8KxC798/S1V4M3SW7Ii17Ta1gmdfe75IjZYE1Hy/Rt6XyruNl9JyEwaISsauCe+CBpqZNoNI7vWMlfWL3BpuoGQuGRTR7p9HmtOhaHCPzg8o5EBNNSJg9Yl8iOOjquc4Qs8H6OY7DrYej4DaGGwECyXYEp2O0QesTKT2v9ARgfPSqwzQo= 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: When write_cache_pages finishes writing out a folio, it fails to update done_index to account for the number of pages in the folio just written. That means when range_cyclic writeback is restarted, it will be restarted at this folio instead of after it as it should. Fix that by updating done_index before breaking out of the loop. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index ee2fd6a6af4072..b13ea243edb6b2 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2505,6 +2505,7 @@ int write_cache_pages(struct address_space *mapping, * keep going until we have written all the pages * we tagged for writeback prior to entering this loop. */ + done_index = folio->index + nr; wbc->nr_to_write -= nr; if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) { From patchwork Fri Dec 22 15:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503410 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 67713C41535 for ; Fri, 22 Dec 2023 15:08:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 795F86B007D; Fri, 22 Dec 2023 10:08:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F7136B007E; Fri, 22 Dec 2023 10:08:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56E546B0080; Fri, 22 Dec 2023 10:08:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 433F16B007D for ; Fri, 22 Dec 2023 10:08:35 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 15BEBC085A for ; Fri, 22 Dec 2023 15:08:35 +0000 (UTC) X-FDA: 81594785790.28.850DB16 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 6D41B14002A for ; Fri, 22 Dec 2023 15:08:33 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=eW2Uy2m7; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257713; 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=fN/ppIDjf8llE1R2IP9HkDxKkqwH+tE6Rl+QLZ2/TEU=; b=hyDpvM9VuAP7AEvHOAeySzw1/DiUhZvukzIfrpvlw/jZW2WsrF/M6Q2JTSLBz72i8aUKJ1 uz17bIrWq+fZcEp9wnqVYquSh9oWKN05erp2kfQJ+m5jFAe+8LWrEVFa1ui4b3ywJlCKPl iM6x55Gh++Ig8O4kNK04Dyiv6NamtZc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=eW2Uy2m7; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257713; a=rsa-sha256; cv=none; b=EsPfO9Q9i6wO8uJhrNTx+Ihjl3lNM9oJzjlfXwMtAbdlo/sAzEqjQS9Mjz8CT+dOrHhsSD SAnh1clAnRYW1rw0qym8B3SE3hmRBJnZnt2p/ZyPsp9xZfKR9rBfeETP/pe22kXhxwJw/8 UnNPrTyZ0Z6GfuTrIy2hYUUmKmwmIzk= 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=fN/ppIDjf8llE1R2IP9HkDxKkqwH+tE6Rl+QLZ2/TEU=; b=eW2Uy2m7FBO5xaNthhnztdQcks hrr4l0624Om9pIxbz9CvVT6F8/8GtvMNoXbmwGlCDFF8nGnq5VDQOhY68QwmxCcNbw02AiezjLC+h LciBMuT9iTN3DQKZJHLpSWtmgUBo1N6gBdfQ80vxoMRYMIFbnLv7rZkdvcE13PbK+RLrfJxZ6V/Wm NaEoaC6tJ3nXJN0Gfu7VKwYethnw5imyEeNqEF8c7//UPkIYO6NwJMsmMjN2v5/e76lJMEddiOmLy RQMKELa4SOwk1keLw5zIhtdwJ6WKunryCLuXgV9j0hnVCbu+3sDisXU0HwhYEHJuIKUDxvODk0o+Z CSzgEfwA==; 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 1rGh8a-006BM3-0e; Fri, 22 Dec 2023 15:08:32 +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, Jan Kara , Dave Chinner Subject: [PATCH 02/17] writeback: also update wbc->nr_to_write on writeback failure Date: Fri, 22 Dec 2023 16:08:12 +0100 Message-Id: <20231222150827.1329938-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: 6D41B14002A X-Rspam-User: X-Stat-Signature: 13gd7shao7gocuc3z1ha5dfbxskawwuz X-Rspamd-Server: rspam01 X-HE-Tag: 1703257713-256446 X-HE-Meta: U2FsdGVkX19nHJrJcULa1VzSUhqDo0wz9Aiw1La9ejvfFSZOnXNZqJ8ShXxTBG4YCWUdT78AKaT7PS1sOkCUz6gKzxzDCPxp0ZUKbSxJ72f2TCC+59pIMR53CWaMeHcLkjKuXtButj4Tvk8aQJF1mWo6y0PH8RSW81AZiAXZit04iuPiCTmylzxRKEBS1/zJ4N/3PcAx0t9taxW37sLLQnjZJYldaEb56X7XEUaRbtYRm/ZMMaDnHRNcFe8d+z28Wb0M//S6cws10a2FNvO0KpngUNUnBFUgy6JPnVffORdPQNZGhodaSxZCzncrlPiJ+Bnr8RM61EKwHAHGhTAl6GuxrLo8zFPrGhCaLXy7RQp5Rq/XoZQjgaspIefh/6XBu05OWomINW7hJjCWqJeFTb+9qZWOe+uYCznj8rxv4Qkg5HRqiy3E5skC+AW1ydjZwJogMM0UgCGLrBEyMzbqKGVUMw4KQWe6d2cdLuwBVvaFTEItbBAjRyth30g4Kmf8cmz3igeGwwFCf2p+0ezmC6MrzbVhZ/DGRc88eTElubmK/8Fvv7uUtVq43KrxmHSja9qqU8sP1o8F/Qt+VosOCUEaNVukD46/AHHyf+Af9UnfBHlwXYpo/8+v9X2ic2yTCnQZhlS+z/du0wpuwd6DPEhC0EOxETZ6sGkz7VDyqMlhw0yIQURnTknfKWobMVFCBGRRHAQU0LwPhslnfq3CB87X98r1KpyCCgbIA8lv4q3pgiG8Efoe/VlgmBRrbLnA+Cz06zglm3cLXNQx1V7S5NN7GTyYSchG4VPXxIHX5iCEBRJdSeXY8fd0j6KGqFjb7QWeOzN9wklNLSKCQRp0+e+aF77/N26YP2MCK3l5Dluc1Z9s/gkE10qQZtV41jzvYMBJXQZiBOJ1/LNFi1WUkaJgAYVY7yIdWP403vopRhnyU1nmtuwWQB6dY77fkzBvBhdlzokjKTA99JQErdm AhSRT7mW Vz8T13yKpNa+3Jwm3SfmrbpuaZmTb5UgxlhwikpJcqJS7AHdeatC0dF6/PprBeXWIQucj//XgoNkom0ZrWcr/W7JVKuZyy4MEgU43Qhq7tGAukP5KmSKV26WPEzoIpLfnZ02Y2cqW1IZq09LIQeFO3sOFc1uV05u/lPlGgbIpQIGZFMZ/0R4cnK9s+HYdPv4D0/2y2QcIA961TOxPoqDOQPt1vPPPcPIjOFTZfR661BblyFwzMmWKKLk9yXxDdhwlooeFm3bKb7nBO/g1e+GU94LzYzVNrrPqANhPgPQKx+/Q7+bMOmtrNQWrc2fvKci9ln8lga3DqNKb3B4AMINP6TVYTdtP65Rvyw5RO/BmDLFB9Ip9Plax7+dY6JJkx5xYP72IwUxdb+oHZiu59iavD3HHj1TJmTx8YEt1tOtxBJBzm4aTUY/QaXEnKpuNmR2ECBXDOXIPdVUrTnMlnOYOSQ4xBu/QffkYACmfqXyB70AKDFY= 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: When exiting write_cache_pages early due to a non-integrity write failure, wbc->nr_to_write currently doesn't account for the folio we just failed to write. This doesn't matter because the callers always ingore the value on a failure, but moving the update to common code will allow to simplify the code, so do it. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b13ea243edb6b2..8e312d73475646 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2473,6 +2473,7 @@ int write_cache_pages(struct address_space *mapping, trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); error = writepage(folio, wbc, data); nr = folio_nr_pages(folio); + wbc->nr_to_write -= nr; if (unlikely(error)) { /* * Handle errors according to the type of @@ -2506,7 +2507,6 @@ int write_cache_pages(struct address_space *mapping, * we tagged for writeback prior to entering this loop. */ done_index = folio->index + nr; - wbc->nr_to_write -= nr; if (wbc->nr_to_write <= 0 && wbc->sync_mode == WB_SYNC_NONE) { done = 1; From patchwork Fri Dec 22 15:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503411 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 2FDC5C41535 for ; Fri, 22 Dec 2023 15:08:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28BF16B007E; Fri, 22 Dec 2023 10:08:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 214E06B0080; Fri, 22 Dec 2023 10:08:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03ECB6B0081; Fri, 22 Dec 2023 10:08:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E48866B007E for ; Fri, 22 Dec 2023 10:08:37 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B285F160E76 for ; Fri, 22 Dec 2023 15:08:37 +0000 (UTC) X-FDA: 81594785874.12.1B252E5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id EE0788002B for ; Fri, 22 Dec 2023 15:08:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Z6VUXUaO; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257716; a=rsa-sha256; cv=none; b=KMJyp1fPFlErvLU66E3Cs5oDQecsJJfK7BbsmrD6oLgb9IZKu6S8k0dmgqAC2x8Af42+fb tpXPCj1pysTV6OQQiASeB0RM1HE/INojHJvpY1bzP7aw+zawRdNajElUo7N5oXqRihMfqw wHFksrQzVrf8Aj+Zt+aoeRE3di6iC/w= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Z6VUXUaO; dmarc=none; spf=none (imf02.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257716; 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=aiTqCmsyGk4E7LEDYa2Lc4VptDi32CoIamzlkv7IN4k=; b=prN8jrcpjJI57EdzMF2XC3KN06Q2HtQQ575zajKYa6Hkpyy5grF5b8NtaQUWwYaDo5wzrR F4eN7dxS3rxEem0EA0D32ZD8HzcQAsbLvdn9U7YuTGMAaMoRvBu2kerEaA2Dsn6/wD8G2z HwHnjtiYkubLH74nIW+JckZcpES2P4c= 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=aiTqCmsyGk4E7LEDYa2Lc4VptDi32CoIamzlkv7IN4k=; b=Z6VUXUaOnTXFhPPhvYLJ/CI7r+ 598L/x1qssfMn/59wmI2TR1LAjz4u+kDW5Nm60tNob0N/ESCYSA2gORLrF8dLjo+CB2AUmg9iWjiU vg3Yj1XFCntRF8l5h7YKvZVe5SEmrCIeF9qXoxetiOCRs4Q1Aitg6PbJi19nea7MVIO19Kp5CYZF+ 3Nnj3WXzTHCmBacJmCICSBDReSKIntJmPrV+8G22uCHaMisfcnpBn+5MVwkkeYU9SHRM8Yq+5wxK8 RQjG0VQl7bkgPwdxOLdyOnWEQzTsJ/bRLdG9XcL5S0sXkeQNYuqZwZ3EdiMtKs0PavEur4+WPuOJm HpUGJILg==; 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 1rGh8c-006BMq-2T; Fri, 22 Dec 2023 15:08:35 +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, Jan Kara , Dave Chinner Subject: [PATCH 03/17] writeback: rework the loop termination condition in write_cache_pages Date: Fri, 22 Dec 2023 16:08:13 +0100 Message-Id: <20231222150827.1329938-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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: EE0788002B X-Stat-Signature: fgq58dbcjz5yn87wa5j935makqhe3887 X-HE-Tag: 1703257715-118278 X-HE-Meta: U2FsdGVkX18pIl/dFPQ37jN3ePsl2Oswd1/tNpXrYd73ft98iYTraJXqQScRyd7CEwjZcjMR1LnrlZ7ZqeYdXfjoMy6/809wLaXzXYm0kb4Uprn8up0QVu8TpQTleJz7P8wMej7nKCg1954FghUjaJcqDnpEbJ1WuyPkgKwiJyTV60TqGHgOaO3rZkXFl6dV+zsK538CTcM/BwD47JePyDZU6Wp//uRfWrWM0YrhoEoTWHcosYwv2nR5Jw5fnTinjo+uHyGR9nrZg706FPr3qUSdGtFQmwGl8ZvxXLNiIx8AUb9Auh8l+PKpmcdqhOcdFwKvUeLlCsvuiH2iTJaz2XY/tJd5UbcYhNIFa5N0tegjJ3le9RDV70MFHsiLVlbch7oDtb65k0Pf3pLf2xSU1HDtuAh+c6u+lsv7B9xP9bYEXqHMxytRjUwfjOZ2dlR+PwWz/N+VWikbHHEsvpmElbn2soTqUv7x1wAL9zhgnQCfaulmqdxKXMIUtpje1Bs9kJ8foirfjmPslyA8GF1kp2XmadtmmjEMtBQxP5c2E6e4FieurIkRTZRu2epNpCjpeJL1pCJk4P5ZPAM6oKVUenLBBOkw9uXATkcHkzwaXPW2sRzz0EGYEbr81oa9HEozQiGfzVfWhk25iQgPjryhY1HGTEHdZzVCX/+1VZPpqx2tlBB75Q1vF8EpxNYTnCGot7J7K00HA0qj7m6gj73t2j6eZTr50sIY9+7Wd9sZ24P3v9chBEO+o48OpYDCEMBq2k/4RULQvs27l88Eb4xE11mUoanZwgOJtIOCSoCJmuQzYkZLS8ITYtF/GgyE0/xIF9s+ljvTQPW4g2QG5FHlcyhuPkipiNRnvT4I1VeDlp+zoeuJ938zNoNQ3QG9L4Fxrz61KXFrXAqOx+gJumcnE06I2nap0OJPAgXhymaWOoL/G36qw0T4iL4cP2/rRX5oGsthRSrge4Bf3YPraAv u20FBVqE cSgLlOW2xCLNKy0BpICfIa1eKEOpECTNErQsOrJ+2ca2gwI6V9FkyLpDBPXi/oT5SzrCt8Vj1OnfLPt9FEsiC0NSaG6zr/dHUMWgANfB3Lpon8+SPnAqq4W5T0kfgC2wFjdps0sQxrJYuTgg4TXGaEIDUI0LeNnH3+cMOC7IMRMzQnRm6QBym5lVyxSZzLVt2GPLi9DUG9pmzeV7+e5UudHW2E6zRKLSVaWyqQS9q77l4v4uXcCFTrAZBKUTFqs5fTDdxb0+HaLBdsNTKR4AifJu/I3YDoSEoBo3txsKQDVRxbJ7T3zmKr3+D21iPitDVerOVgvHUGeXD9zFz/mPrE1eUpdg52EzP/F3qRTwTutgjFTfeVqRyrFRjwvNwJa8RSNWc9jAkqTmCqUjtboT5Da4A+q/Rq1ZoYdvoMzziUV1uYt/yTCQ4yiKBsI8qQMFxi9DnyPNCdk+rLTY2atTOuf0TbT0+7P4z+8gmLZbSJeriqSE= 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: Rework the way we deal with the cleanup after the writepage call. First handle the magic AOP_WRITEPAGE_ACTIVATE separately from real error returns to get it out of the way of the actual error handling path. Then merge the code to set ret for integrity vs non-integrity writeback. For non-integrity writeback the loop is terminated on the first error, so ret will never be non-zero. Then use a single block to check for non-integrity writewack to consolidate the cases where it returns for either an error or running off the end of nr_to_write. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 62 +++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 8e312d73475646..7ed6c2bc8dd51c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2474,43 +2474,39 @@ int write_cache_pages(struct address_space *mapping, error = writepage(folio, wbc, data); nr = folio_nr_pages(folio); wbc->nr_to_write -= nr; - if (unlikely(error)) { - /* - * Handle errors according to the type of - * writeback. There's no need to continue for - * background writeback. Just push done_index - * past this page so media errors won't choke - * writeout for the entire file. For integrity - * writeback, we must process the entire dirty - * set regardless of errors because the fs may - * still have state to clear for each page. In - * that case we continue processing and return - * the first error. - */ - if (error == AOP_WRITEPAGE_ACTIVATE) { - folio_unlock(folio); - error = 0; - } else if (wbc->sync_mode != WB_SYNC_ALL) { - ret = error; - done_index = folio->index + nr; - done = 1; - break; - } - if (!ret) - ret = error; + + /* + * Handle the legacy AOP_WRITEPAGE_ACTIVATE magic return + * value. Eventually all instances should just unlock + * the folio themselves and return 0; + */ + if (error == AOP_WRITEPAGE_ACTIVATE) { + folio_unlock(folio); + error = 0; } /* - * We stop writing back only if we are not doing - * integrity sync. In case of integrity sync we have to - * keep going until we have written all the pages - * we tagged for writeback prior to entering this loop. + * For integrity sync we have to keep going until we + * have written all the folios we tagged for writeback + * prior to entering this loop, even if we run past + * wbc->nr_to_write or encounter errors. This is + * because the file system may still have state to clear + * for each folio. We'll eventually return the first + * error encountered. + * + * For background writeback just push done_index past + * this folio so that we can just restart where we left + * off and media errors won't choke writeout for the + * entire file. */ - done_index = folio->index + nr; - if (wbc->nr_to_write <= 0 && - wbc->sync_mode == WB_SYNC_NONE) { - done = 1; - break; + if (error && !ret) + ret = error; + if (wbc->sync_mode == WB_SYNC_NONE) { + if (ret || wbc->nr_to_write <= 0) { + done_index = folio->index + nr; + done = 1; + break; + } } } folio_batch_release(&fbatch); From patchwork Fri Dec 22 15:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503412 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 3BDF7C46CD2 for ; Fri, 22 Dec 2023 15:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC92B6B0080; Fri, 22 Dec 2023 10:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A29706B0081; Fri, 22 Dec 2023 10:08:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CAA26B0082; Fri, 22 Dec 2023 10:08:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 75CCE6B0080 for ; Fri, 22 Dec 2023 10:08:40 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5127EA0EDA for ; Fri, 22 Dec 2023 15:08:40 +0000 (UTC) X-FDA: 81594786000.20.D5A6216 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id 98D52100016 for ; Fri, 22 Dec 2023 15:08:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=none (imf14.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257718; 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=0tDqvYwFSGZxiPUTzlW4HNez1MU15vMHRFJdEDf7Dd0=; b=HSQ+pgmyR4SmZhnGUole0jDZzky7z3M+hdv/kq8HzuQD/+BT14hTFDeqOYonkZ0eB2W+PP ZC/dY+tpPCsx2dQdVOXQLm+gaMJZ53utJpYLJZqKGWpwN4Diq+1nkpXD/1y/nnRlb6ZuO2 dgahBHzg4tCFom4O4aGWfScSyNlUQWA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257718; a=rsa-sha256; cv=none; b=UZUfn3dAubh6KelDB7d7Ba+TzVxL9h7dytdJVbLbAZZgRMYSukcc8mqezOtkgBk9cxI9dT VzSR4Cc3XP3xtZtTdF0g3thmOKWUT1hQzNXST+Hmglbp5TDS0+OtE2n2PN/YDkIbzTsXas Cue9MEi4HfdiLym/jLHmPRIHCEI5+m0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lyhf1Gv6; spf=none (imf14.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=0tDqvYwFSGZxiPUTzlW4HNez1MU15vMHRFJdEDf7Dd0=; b=lyhf1Gv62XTy6SIBb8FrvCwqeh 1RaBZI0ukFpiajsVrAsJrsZE92GjbqPfI6XSdb1FjhFStqbhHLQjcmygA2wH2wRH8g3+05NMl9J+N 42ri8YHKlGerT9Tdd/88EoNNxcMX1xuIID+mZi3Rh1dTDwGk4ls0ipAks+FX5tabN81pWf0lIHPRj NReb01NKF+7sAICLZpkCUU6tt3stIcOSMyEuON9OYEzR6kMjSiPZ2RCiEQU7gotUP29X6VXo8q5pY aZiHY97ygOa2Pd81Mq1Vmwb+9UWfc+APNvoMxS87cC91low9T6nGXFJCO4S6AiYx5ltUy6dTrm+i8 ULWolkew==; 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 1rGh8f-006BNf-1U; Fri, 22 Dec 2023 15:08:37 +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, Jan Kara , Dave Chinner Subject: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Date: Fri, 22 Dec 2023 16:08:14 +0100 Message-Id: <20231222150827.1329938-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: 98D52100016 X-Rspam-User: X-Stat-Signature: jwcxn98q1zmsaedp7wwk9jnioqt4xdf1 X-Rspamd-Server: rspam03 X-HE-Tag: 1703257718-487239 X-HE-Meta: U2FsdGVkX180BoP2a9brSjfkvffqmA/PGYmk5GEjQP5+EzU3KphCNAEeJ9jGb5VcEXlEQhkV8X/4B3lXaRxy68y3ASmpBjqsY2FFz1cWljJvN3+IqxUJwhKx4QQg9a4vkRA1BJXQRXySecXRqvLCjVaYXPPt6PRU7zOoiVswRT9kJu1ahOViiIN7U49eGYHp7wNiuOUs5zUwo0y8XYQd2mnUwFvQHFvBF/xnzOMhD6Nbvj5LaNrh3ADO7AMOxDMyvuPzm6ysONw2DPUjIzN0YTcXcgtvU2io2a4Maw2V/9EK2FGzYk+AqQz8Fzm1t/Gr8XO0j4eaOwV67OflWZFDY+8kn8Rt2dAL0ombEsIeDxItJYno0S49PBzL4bZ/eNkppGanWn/6XsOpe5Y+eN8m+HYlNszUieVi8iuTRp4D2jw0TrYZBPPt7YHxTZWOEIM7MOrqV2pLskczb9yIK3CPUVuU2sKFTIZOdrMlHz0pdLDzSXUWd6UoXvuPPLmySkeoYu2mOvObIAdYqERpukx6Dw0yzwhxGvxn7+n3qI3apKsDG7iYLoW/Ivdu3psDECMeq8cE1q6HaGxMiVO5Nx6fvluzTgF2aw8xk0Xb7SJWJkTimR4qsjp2MBDvmMu3lwXJrr5IbZdusRjUsCd5BPDIx/9rpDOUq3LVMalMoZdA6WVKZc3lOvJet5d/HPxsd5X44Elxfod0jBPSPWpPX0WDTq7Db92WUVuFt6POVb8neYLE/JxZk5vw4By6itlS/22x65vjRt8SGXrtDnWcQFgjqjzCv5I1C60nMnfGRyOmXo93pSQUf1Sf06B0sFOUxS8PxmeLFpmKItRAeRYj0TNLsClGC6c/SsfB1tk1U1K5i09e3wtXmRjBjH/Y6SyD8kBOijFeeBVDQK+V/5fY6YA40ALub9uTo+YMCa8Rby3eq8FnTm77/J0ktlVB4fgV/GUlCYVFyspqvZJZVHWaCUO QJNEsfEN I1rM30EIyrTdESNexg+xFlC3RUFaWr4ps1EBBHPlt4sBMEbS56M0fSyt4mZ1QhVcprgCJl0gKmkiTHDe7vIEEGkW1YAtUnoXOvTUFmRTWVpa2/F8JwixZ8qnD/LoWlh2mU5/SLuE58x/uEVswXfPzlTOj/bKT/5ZbWukcAW1ODOHEX6RCA5BlNzYMRmUmrSBpMgcDFBR8K6DN0SD/1iZ8HBfyWYG9UR7rz+kS03G+HOBPOdNBBdJqufbffnyvftthnnCjHQXHqlJ3XSRZRu0DKVfV0Pxc+sp23g0FOt7Bcp2bvWZshsHTSIeOrFwcCcLcG+fxlIzAydAzQnAGFyKBohMJUYYhEq9DQ+hC77mG+Ajir8tg+vZv+Rsnnxt5DrSddNWVcnf+sexhfFZk5YN4bGtAirpDdaX9sNa5ZuUizR5JnRA4+1IeqKDAlVjuVHSW/10+x659naRBGwJGh9cdd2BrX7Cq7B1xp0zcCAZkDp/fWuw= 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: mapping->writeback_index is only [1] used as the starting point for range_cyclic writeback, so there is no point in updating it for other types of writeback. [1] except for btrfs_defrag_file which does really odd things with mapping->writeback_index. But btrfs doesn't use write_cache_pages at all, so this isn't relevant here. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7ed6c2bc8dd51c..c798c0d6d0abb4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2403,7 +2403,6 @@ int write_cache_pages(struct address_space *mapping, pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; - int range_whole = 0; xa_mark_t tag; folio_batch_init(&fbatch); @@ -2413,8 +2412,6 @@ int write_cache_pages(struct address_space *mapping, } else { index = wbc->range_start >> PAGE_SHIFT; end = wbc->range_end >> PAGE_SHIFT; - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) - range_whole = 1; } if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) { tag_pages_for_writeback(mapping, index, end); @@ -2514,14 +2511,21 @@ int write_cache_pages(struct address_space *mapping, } /* - * If we hit the last page and there is more work to be done: wrap - * back the index back to the start of the file for the next - * time we are called. + * For range cyclic writeback we need to remember where we stopped so + * that we can continue there next time we are called. If we hit the + * last page and there is more work to be done, wrap back to the start + * of the file. + * + * For non-cyclic writeback we always start looking up at the beginning + * of the file if we are called again, which can only happen due to + * -ENOMEM from the file system. */ - if (wbc->range_cyclic && !done) - done_index = 0; - if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) - mapping->writeback_index = done_index; + if (wbc->range_cyclic) { + if (done) + mapping->writeback_index = done_index; + else + mapping->writeback_index = 0; + } return ret; } From patchwork Fri Dec 22 15:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503413 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 EED66C46CD2 for ; Fri, 22 Dec 2023 15:08:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0D9C6B0081; Fri, 22 Dec 2023 10:08:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E95FE6B0082; Fri, 22 Dec 2023 10:08:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9AE96B0083; Fri, 22 Dec 2023 10:08:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B90D96B0081 for ; Fri, 22 Dec 2023 10:08:42 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 91DD0140EC2 for ; Fri, 22 Dec 2023 15:08:42 +0000 (UTC) X-FDA: 81594786084.11.573237C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id EC3601C0031 for ; Fri, 22 Dec 2023 15:08:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=e+k8f0nj; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257721; 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=C2vff2ZtkO5ymT4AwpEFr32HKz+HzpqwK8XI6XGgOh0=; b=vQMN0fsV6HaB/oWqzFopzTt/csEQIsROv1lFgOxvOI++XpLJwBaAX0RcMEgpbISDb8Cayl p7A3cVYiJzPfh+KdB7fURrU9YBG9/BDnglPDEg/Wi65WZrPbT1x2EcNESwa+J5GTlfUjuR O1/wRQazm0Wo4Nw+H7dvTMc3t2dfvLk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=e+k8f0nj; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257721; a=rsa-sha256; cv=none; b=07aC0EkWqddqklSm1WVHvqrL78L0RghdPMdltezYc4dkR/+M0cbEAZhIXTP9vJfES+2z3X T10jFLYk4/s3rR6yyupmQWFAF5tm4dyD9NuE8ZU7eRiaNuWfC4WkEzBlbbrEiYUAtZcbGN 3a0IdTjGpQqBtn1f2+4BUQ0rYTsyrOk= 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=C2vff2ZtkO5ymT4AwpEFr32HKz+HzpqwK8XI6XGgOh0=; b=e+k8f0njZ2ngt8JINzl1za1aVf AqLBYMRDqugK9fjHpoPbpRPF1/TsbUAE7Kfy64CrD2SeSgreU2Iyn580faBV0rYL0PUTKXxMeVfpo HUqRylBgNWtva7q42aOWQT6LUP6a/x9WqISQQrm1NVkRn5poiWf60Mf5wyANQ+squIwufjg/xdk+C TlDPW4CYPw3BK9kXfWumCK++9FtBRxmq2COpbt11zNiEl7ddJCP31czZVJ03312y/1xVlyxQTudaz xntQ4O6Y6XmU1m7AvmTu3f/OaPn8gbwT5rhHxelHYJBethKxbJ/bOJsh2ogp6H8Et73MtdKR6nRK/ Tuqyq/lw==; 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 1rGh8h-006BOe-2U; Fri, 22 Dec 2023 15:08:40 +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, Jan Kara , Dave Chinner Subject: [PATCH 05/17] writeback: remove a duplicate prototype for tag_pages_for_writeback Date: Fri, 22 Dec 2023 16:08:15 +0100 Message-Id: <20231222150827.1329938-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: EC3601C0031 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4ro3gywqaba351utd596u6z7bnt3xhyd X-HE-Tag: 1703257720-474225 X-HE-Meta: U2FsdGVkX18QbWQPsy/C9BFVhOGSDOLao98/MujNABA7kKShB2x2dK0yN7ZqBMcxFdKMG2EYmALzW/mXVLUDLVtfzFrMAdHNho+cyubSCzt4x59yxDi7NHO+JWoGciOLAuBh4jbykJSAbwI+GztnqBMRhEyBwIiyTqMQ4rZjqEhPTqYmWZf+7/ciQNkklMxKbElYvgFRgS+nvjoODqdTLGvGhFo44ngrpAiR9K3O18tK2sALsz1WUWnCs9e6MmrPWFtRLzfDRjPBOmNWYdhYinm6p0zIqOrq1u7gW38qh54xx+eOtDhDqMg4h8x6QgrCYKFDepTIVTCFFqQWtWTnk2rrP005Q5m513aRTkwUFXbsPu5PqEWOH/SQCDodSWgndz5bseHZGvlK6/mk5smHDELaFhplWlb6JysvkJ07qa0nYaOX5I0ChPTVxQdOCIffLv3krkl5RO3IBCoJ4cJZoc9SaB1h8tAkKOJwvNZWwjJhgB2lvNO1CxSE3FPIu2L3EI7FGGAFWxYC/kDEWl/1regwAg7GMH8kalI9QT2fPpkj6fB6oMSfx/oxCaac7uFvNOKs65ISKAr7DDxIuOXqsXlKDJJ9DHqTMqv9ZVvc9PFMyrbI6yh5u3f9dndy74O5IRiT4CGN1Ca0qECoUI2R7tsj2OJAL5zEiCGAncj2cUUX8KRetwvJj1bM6XohM1y+kGNPfss5W2lu1T4Bf7ZpD0QpyLv+Rmt1J/9EZ0pnTBjmCWOJWN8NskItlvGVoj8pIEb5yVWe8knDDSy1NfFNYNlezO4RrrLcn4X191Esh2REndQY5ne054+AOBS4d2OOilY+vPg0b9fzhPrf/SShGG8egvsDQHyHx84YnD40lA7xhslHZFeu+CxvSZqwjc5CxrWUcpVNPCZLETu3LKZAsEsp8/BXsafji9Bo5u4+FfToMGz6ioBiMX4ydRgqRyqq7RYFza+6ZfaJ6s6h2AP 4Tcc5efe vayRvR482WPPUV8aKo3O2Kukpo06phwmwie0sHDVdhECwiay4NHaRBiWfpCeF/w27ms42v47zjPEHGf6iBtsFswa/xilgBmoYN2dGZMJ/pePbVyctZSBsYYnex5GvxC5cTYk85R4rNYdIfOEBcDs1AJayuhY9sRHphz7XeBNnfN4Yzzh0a8InxhFuh62NpcXCgwuq6OgKXtd58fb61AsldaURzQ== 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)" Signed-off-by: Christoph Hellwig [hch: split from a larger patch] Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/writeback.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 083387c00f0c8b..833ec38fc3e0c9 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -364,8 +364,6 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb); typedef int (*writepage_t)(struct folio *folio, struct writeback_control *wbc, void *data); -void tag_pages_for_writeback(struct address_space *mapping, - pgoff_t start, pgoff_t end); int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data); From patchwork Fri Dec 22 15:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503414 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 ACB77C46CD2 for ; Fri, 22 Dec 2023 15:08:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98F226B0082; Fri, 22 Dec 2023 10:08:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 918256B0083; Fri, 22 Dec 2023 10:08:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B9EB6B0085; Fri, 22 Dec 2023 10:08:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5E6EF6B0082 for ; Fri, 22 Dec 2023 10:08:45 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 38DA71A0EB2 for ; Fri, 22 Dec 2023 15:08:45 +0000 (UTC) X-FDA: 81594786210.24.BEF522A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id 5BE06120002 for ; Fri, 22 Dec 2023 15:08:43 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=IUhhnEiE; dmarc=none; spf=none (imf29.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257723; 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=/YruVy693sIGMqSVhVr/4+JF9RoXWgnIrtLSdSPK4mw=; b=Hty44tIKCDQ2LvmSaMaGufFIIB48lM5cs9fsCZTwWOeVlDNjbYXu2arUrQ+zqoo+YnLmvr GG3J1M5fKMt5Pmeyzf6U75bCue3v68UQy7i9GrWOaGyxreFpItozetfgryyb+LmzF56IEZ HE7T8Gbo4urMQiH/c5nzoOGMifbBmAs= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=IUhhnEiE; dmarc=none; spf=none (imf29.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257723; a=rsa-sha256; cv=none; b=6dIwwttKBXDDkPo6va1TXvfvDs0Ky2pL9OvMxVvZvruQsMPCV1DPT07W/3pbI+l3nZltaG Z1N0Y5XKwNeaNQxeEzyBiYcjCSm2p+HxWoXbdODhCh56lEjTwL6IlJlyR6weIZNsQXiU+y LLr5yLPatAK3Nt+ZimpdLpWiDh7+nhs= 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=/YruVy693sIGMqSVhVr/4+JF9RoXWgnIrtLSdSPK4mw=; b=IUhhnEiESKEpLJdHRKcnKDOIrR X/YC3xSsenqLCvV2hqbEjMjE89Dggeuq/l0/DFlCqq2/Dv9lihc3A4g65Is18xfqqudV8B8C6VTg8 98zB4odPXmtfjhGlT9Qr5bZE5v6hPJC3SONm67/k3Xp57dGsKfSil1ishKDCXwqnoavb2P7c8sUfr xpVag96xhLM5Gv7QXvrXSKHI2r/WRkoMO8M3woP4O5IILeOj3HNKE56jPhc81gRlYy/HbeVTNijyj iI71h+qfhB9lepfDz1Iwo3wR6OeeSGbmlaG8fi6gRgnQVU6rZW669WmymrBZG0afHVD/S/0WwrTLO MR/NZ56Q==; 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 1rGh8k-006BPW-0l; Fri, 22 Dec 2023 15:08:42 +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, Jan Kara , Dave Chinner Subject: [PATCH 06/17] writeback: Factor out writeback_finish() Date: Fri, 22 Dec 2023 16:08:16 +0100 Message-Id: <20231222150827.1329938-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: 5BE06120002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ebcgreszkchjhorhg8fjbn6jkp3a8uzu X-HE-Tag: 1703257723-566541 X-HE-Meta: U2FsdGVkX18QEjKjiZMLup2UcVihGyMEq3TTaCUHXHq+e8iOqefkkV9RFQ8Qek8La0YPQBnfpac5QeUiSzMzir+sNrRVxbqozpIoIHeE2AtVFhKvtCUPxjGNLL5adCGksDRW05yC9qe9xCfvBAP8pXlgLW05nuEoSE8dnNP25jLy1f7pEW6YinfwXSdGkMrEm7X9iegy7kbCDwBkfuSKiJR17Z3BR29X6Z4p1FMehsHv+M3SL6HVYKqz/LLwUEglIb18QuFCiPC5m94zdB1AJMWkH/jamjV4sTMJ71Ty1kVaGNAI3cwtWdfVpb38v8nL1m18apKUl4wVBIga+w/RbKlAjIl9WbvGQuqWAcqGKR6L+0ZEwRvOhqyimPZe6edBSaLlIsny1c5P9beiuTl9rYERx681KJkfS/GUqni5346HbqD42qPPSDJ862k66jqFghwsW9eGromzVxZbvXUpJrVP1Fgp/PIK/F+aV+bG/LyfSmgKwYqoCrJMuzmhLPFBHaqNiG2SLUNAoOTbiNC8dgZePyFHHKrlZ3nuUmpYctwj8GLQQNjj1iPgHj62Wg/Il+rCKfvfUIsabmo9DdVnQ0MsVmu4pJxj0ZJX6Z9LisKZOAmcpkFZbriIhtFuxOgECpYXJ0MudtVC1B0zgwgxLnVeew11Vw++a72Y2FcKB0XQHPuQG3bBwXsMl47fZUhiLaZKBmS/UJodeVsszPySW4bS2UqEemL0w9g5+VO0DdAIz9WngSiurM6tD5Ilrr5zHAxaLBwZLDZpo+W5aTQCHtL1L+HYs4D41kaSeZ+cm/3FiUYxxZp4rAexHD+liZgbnjIsQsppn5ao8+a+2JLi+RwmapSvuh2xRghkKHhtwP20Ym36nQBbNQK+7he+s1Z0WJjZJvU0AQ9OkY7bbNB71LBVFmNq+fjtW2/92G8SY8w00dxk5Oigkh4oB+k7ei44SMmZN25jlqjKtbOmxPY 11T+eWmq NslztNn57XR1DcQ03Zvo/VAODsMpcI+mbkPEZGCY+e9VwueUKmladZdZ+M3fXZ+kbpQcc3s0G7XlD7L3Q9orT2RJNdJcx0IcEM7c2b9fj7j/U2ZccHH+DhvppU0UUdV1OWg12xZuPlN78wylo90d+0xc3z55Df8m8oZp8KjrHcdYu2aOdJbge/LaZLGLHF62deFDce8rBCzz75ZbHRBisib4KMqgQ1tI1snrnk5IfjZ5MKnzlmYf9R87p/fwl/wO/zxgnKY6UThyp+vCp0fn2lD58TD4QvXaeXYdVFt/2nNwHW3yvZYVI5J2tvBCA633bmYsmU6iXZ1Edj1rGjnFJBGmh/2TMO7oZ2MbtwfnVjQXqhsdTqyCa9qf9miDUWoX7f/7xOEhTsm2eHB0BlfbAmKkEM1umWkSGvwmiDU2EQuCwLFM3zDm3VGrOknJTFHFnnmnldaCgxaJTV0yQx5/lTRTDsurxNwruoIK92rHC95k0jvLDR1vVC5LXtxi3KUI7vqbHrfDhqFAtNBnWLt21JD6aXZd8x9JBN/fvNrZFJRa7ofbhEzUZo+O1XZ6rVSAhYHfP 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)" Instead of having a 'done' variable that controls the nested loops, have a writeback_finish() that can be returned directly. This involves keeping more things in writeback_control, but it's just moving stuff allocated on the stack to being allocated slightly earlier on the stack. Signed-off-by: Matthew Wilcox (Oracle) [hch: heavily rebased, reordered and commented struct writeback_control] Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/writeback.h | 6 +++ mm/page-writeback.c | 79 ++++++++++++++++++++------------------- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 833ec38fc3e0c9..390f2dd03cf27e 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -11,6 +11,7 @@ #include #include #include +#include struct bio; @@ -40,6 +41,7 @@ enum writeback_sync_modes { * in a manner such that unspecified fields are set to zero. */ struct writeback_control { + /* public fields that can be set and/or consumed by the caller: */ long nr_to_write; /* Write this many pages, and decrement this for each page written */ long pages_skipped; /* Pages which were not written */ @@ -77,6 +79,10 @@ struct writeback_control { */ struct swap_iocb **swap_plug; + /* internal fields used by the ->writepages implementation: */ + struct folio_batch fbatch; + int err; + #ifdef CONFIG_CGROUP_WRITEBACK struct bdi_writeback *wb; /* wb this writeback is issued under */ struct inode *inode; /* inode being written out */ diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c798c0d6d0abb4..564d5faf562ba7 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2360,6 +2360,29 @@ void tag_pages_for_writeback(struct address_space *mapping, } EXPORT_SYMBOL(tag_pages_for_writeback); +static void writeback_finish(struct address_space *mapping, + struct writeback_control *wbc, pgoff_t done_index) +{ + folio_batch_release(&wbc->fbatch); + + /* + * For range cyclic writeback we need to remember where we stopped so + * that we can continue there next time we are called. If we hit the + * last page and there is more work to be done, wrap back to the start + * of the file. + * + * For non-cyclic writeback we always start looking up at the beginning + * of the file if we are called again, which can only happen due to + * -ENOMEM from the file system. + */ + if (wbc->range_cyclic) { + if (wbc->err || wbc->nr_to_write <= 0) + mapping->writeback_index = done_index; + else + mapping->writeback_index = 0; + } +} + /** * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write @@ -2395,17 +2418,12 @@ int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data) { - int ret = 0; - int done = 0; int error; - struct folio_batch fbatch; int nr_folios; pgoff_t index; pgoff_t end; /* Inclusive */ - pgoff_t done_index; xa_mark_t tag; - folio_batch_init(&fbatch); if (wbc->range_cyclic) { index = mapping->writeback_index; /* prev offset */ end = -1; @@ -2419,22 +2437,23 @@ int write_cache_pages(struct address_space *mapping, } else { tag = PAGECACHE_TAG_DIRTY; } - done_index = index; - while (!done && (index <= end)) { + + folio_batch_init(&wbc->fbatch); + wbc->err = 0; + + while (index <= end) { int i; nr_folios = filemap_get_folios_tag(mapping, &index, end, - tag, &fbatch); + tag, &wbc->fbatch); if (nr_folios == 0) break; for (i = 0; i < nr_folios; i++) { - struct folio *folio = fbatch.folios[i]; + struct folio *folio = wbc->fbatch.folios[i]; unsigned long nr; - done_index = folio->index; - folio_lock(folio); /* @@ -2481,6 +2500,9 @@ int write_cache_pages(struct address_space *mapping, folio_unlock(folio); error = 0; } + + if (error && !wbc->err) + wbc->err = error; /* * For integrity sync we have to keep going until we @@ -2496,38 +2518,19 @@ int write_cache_pages(struct address_space *mapping, * off and media errors won't choke writeout for the * entire file. */ - if (error && !ret) - ret = error; - if (wbc->sync_mode == WB_SYNC_NONE) { - if (ret || wbc->nr_to_write <= 0) { - done_index = folio->index + nr; - done = 1; - break; - } + if (wbc->sync_mode == WB_SYNC_NONE && + (wbc->err || wbc->nr_to_write <= 0)) { + writeback_finish(mapping, wbc, + folio->index + nr); + return error; } } - folio_batch_release(&fbatch); + folio_batch_release(&wbc->fbatch); cond_resched(); } - /* - * For range cyclic writeback we need to remember where we stopped so - * that we can continue there next time we are called. If we hit the - * last page and there is more work to be done, wrap back to the start - * of the file. - * - * For non-cyclic writeback we always start looking up at the beginning - * of the file if we are called again, which can only happen due to - * -ENOMEM from the file system. - */ - if (wbc->range_cyclic) { - if (done) - mapping->writeback_index = done_index; - else - mapping->writeback_index = 0; - } - - return ret; + writeback_finish(mapping, wbc, 0); + return 0; } EXPORT_SYMBOL(write_cache_pages); From patchwork Fri Dec 22 15:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503415 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 6AEA2C41535 for ; Fri, 22 Dec 2023 15:08:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C35C6B0087; Fri, 22 Dec 2023 10:08:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D6976B0088; Fri, 22 Dec 2023 10:08:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1030D6B0089; Fri, 22 Dec 2023 10:08:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EE99E6B0087 for ; Fri, 22 Dec 2023 10:08:47 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B925380F35 for ; Fri, 22 Dec 2023 15:08:47 +0000 (UTC) X-FDA: 81594786294.15.6CF017F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id CB989A0027 for ; Fri, 22 Dec 2023 15:08:45 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=A1L3KGi7; spf=none (imf25.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257725; 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=dcSwdTVvCQUQwEHV9ZU6DKJi2JGMjLPwvaIvkNqY5Tg=; b=IMBPFfqceCjW+opw4oYSg7qBaFxHWVvpI9Hvj/V6mJJutks+VYYrj9Z8GBgkEeMsgzFL7g 4c1SdRH5gtbTegEsR/OsmVhjkONwwOsFgcMCEekVKotbhlbVqLaGOQhenuASmnomUMLirM 5NguW5YcrRKc8cgyHSaQDK48YydRvQ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257725; a=rsa-sha256; cv=none; b=zvCHlhylNTi41FEIFe8Udk3trjTovH3eTv5zC6+4Smd+gEUuEQt4drNIjThzOOVRzHftvX zFnJTrkbCGhIRxezplv7dfBoa/RBcI3I8nya6Pedogy4Op7Zn8O/F4qNY6kA4iIAYJZ8SD FyQrTrQRRBMJVllfVyv+qvlzeF5DS24= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=A1L3KGi7; spf=none (imf25.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=dcSwdTVvCQUQwEHV9ZU6DKJi2JGMjLPwvaIvkNqY5Tg=; b=A1L3KGi7p22WmVHYwn8JAqK2do OXUFMCP8LJGy0Us0BB+qtD7uRWeU14L7juYdVzyoo741jIvkCVavCFPr7vn49oJnwBeb31GwyhyCL XMkYwmZAir6Q8gmHFK6Gky8PEmPyGgyC/KQTwjJI/mv6W+LjQtY/VI5pXzlj9BZdnNVpCESlp38Vu jDKhsTX0+/J0c5ijdwDmuwZyFecpwZm4RDeHS0BP2noVcUDK4cFWRWT1GMfPdyriBSS6BSTLFTFv6 PXWgGoOYcEAcl640qINBEZZbXhmFnZy7yHZ5tKGTOCGoGVoGeI9mHWUXUgs3+Q2npwJgqbpQmtJd7 K5IukuVA==; 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 1rGh8m-006BQI-21; Fri, 22 Dec 2023 15:08:44 +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, Jan Kara , Dave Chinner Subject: [PATCH 07/17] writeback: Factor writeback_get_batch() out of write_cache_pages() Date: Fri, 22 Dec 2023 16:08:17 +0100 Message-Id: <20231222150827.1329938-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: CB989A0027 X-Rspam-User: X-Stat-Signature: o9kcobyzce3qzitmqtsa7sbwye9i1i55 X-Rspamd-Server: rspam03 X-HE-Tag: 1703257725-535370 X-HE-Meta: U2FsdGVkX1916r0hmPEyKGh3R68vXRDX0VBaND7zxNj3Cfynn50Ni608Suf2gJEC2diPKC6wAdHKUTeNtIUwq8tVF6c8OINZLAws4iV4g+8mba8AbU0zVi/XC5qSkHfCBrj+suC/Bzsiuy2HenC96w/dDJkhp6A8poMYfG2kSO7F8IRCO+gjFcR1tzKQN4r4GzPGM2Ezv0AvMXYUk9RKvYNP/nw6Mmx1l3+ySx870wMHjnOnuEB1GWgOymJArFhACAmIdXa8KT/A49g/ZWlB3gB6qI1z5XxFpXjqlqy1gBErUo5AmAzhrcw+fB6lxPsvxxaL2xjsG9BJqjRi3U2Nnp0GA7DOSgaulk15fZlHa1tT90WcnEExSX3X1Jb2pnsemhJWVYA5/wATIEOoUBzVXIIRCJ7FIjvEcTRe4X+ZymmBZ4hTh4OFEAhjGjjmnU4nne1La+60B0i7UGUP7NJcsZFuacKl4FAwShAe/5ktXf8dUlx5ulNXWcu8cuF3336+GvCg7l/DqlGDwWTwNh8I71SetwpY/yAYvIGgORCKMUHtxRkdwcbr2DI/rSNbGhSHxipr99MTfh9c+3SmFDbLPbVMpL4arR278oDs8FqULLDSrXPtjWjSMO2QsdPWWEc/PvcYCxqPQVAJ9jEDG4UxZM5LxHeujbbrVRjf0oWu8jkzySHYMkfRdVLsMsP1Og9NpSTbds+7XStfX37j3e9VBOQAxfV82X9It6EMiMGiKWxgTUt0Bu+U4EC7f/wIlJ1Pu5xdUwAmks2+Zhaj8MYXs3eLtCTOhuHk4+DfSO9IegzFcx/SDCgizN0SsyQzibbJmFFAd/zWRhIb920VRqGumkpF/8IB6UrlrGgMBCGp6rIWRZmVTmrjkgiJp+WCCEUh71nyDy8L6R7Gt78fw9L2C8aQB2nxBHrMXEGUJyx23SKri2itkj7gcOIVlnV+D3MYP+lTKupgMzVW1UhOZHu 1KMETXIj EPzXALk6/CndjHU0UqzbC3Yvu/Jv4Qf1VWajEz0y3ixhPEIVNVe7+YybEZW8zRwV0PGmhlzsigI3kWNZdK+pEF9LNcwWf89cx3sN6Rrqrv9cFQj8cw2mm7jtuOKNff5Z+6wDCDhqgOVxuGmTU3kRoKIwy+0qKRYT2tvgAlm8lcAr+quQPcxRg9wL+hKI15mkv0jGNT3eTOncW+sgOOXFygKeRz/e5dE01YbxY5o5pw7rIleruGZ3FHOY3fBGzwxCRKPwk8PFJP/MaeU/+/mXT31tlvnargRXnYlAlxF+BghS77Mum6Q4aGsy7Nr9ZbHC3+8PqlMYEi2VuRsoazq8OcfnrGy/ycU1dA+QeNnrl4Jb9G8Ffn8zg3UR7Yr6XMVbaff3fWfv+JOSEMd8gaQJNnid1wNvhC1IuA7dvj64ZZ1sreNcrHX+7a48KNt3t+NogU7L3BpNVeZ5Ter12S+Llb/VjeRT1dN55WCOtWH1K+/Py3JgbWwpj7CUgo9qJ8E/8YFWwrm7FtLUzypBGeUjpXSL9omNpCh8hxo4J0b8B4XrT6uj94GoiX294AA== 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)" This simple helper will be the basis of the writeback iterator. To make this work, we need to remember the current index and end positions in writeback_control. Signed-off-by: Matthew Wilcox (Oracle) [hch: heavily rebased, add helpers to get the tag and end index, don't keep the end index in struct writeback_control] Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/writeback.h | 1 + mm/page-writeback.c | 49 +++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 390f2dd03cf27e..195393981ccb5c 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -81,6 +81,7 @@ struct writeback_control { /* internal fields used by the ->writepages implementation: */ struct folio_batch fbatch; + pgoff_t index; int err; #ifdef CONFIG_CGROUP_WRITEBACK diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 564d5faf562ba7..798e5264dc0353 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2383,6 +2383,29 @@ static void writeback_finish(struct address_space *mapping, } } +static xa_mark_t wbc_to_tag(struct writeback_control *wbc) +{ + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + return PAGECACHE_TAG_TOWRITE; + return PAGECACHE_TAG_DIRTY; +} + +static pgoff_t wbc_end(struct writeback_control *wbc) +{ + if (wbc->range_cyclic) + return -1; + return wbc->range_end >> PAGE_SHIFT; +} + +static void writeback_get_batch(struct address_space *mapping, + struct writeback_control *wbc) +{ + folio_batch_release(&wbc->fbatch); + cond_resched(); + filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), + wbc_to_tag(wbc), &wbc->fbatch); +} + /** * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write @@ -2419,38 +2442,30 @@ int write_cache_pages(struct address_space *mapping, void *data) { int error; - int nr_folios; - pgoff_t index; pgoff_t end; /* Inclusive */ - xa_mark_t tag; if (wbc->range_cyclic) { - index = mapping->writeback_index; /* prev offset */ + wbc->index = mapping->writeback_index; /* prev offset */ end = -1; } else { - index = wbc->range_start >> PAGE_SHIFT; + wbc->index = wbc->range_start >> PAGE_SHIFT; end = wbc->range_end >> PAGE_SHIFT; } - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) { - tag_pages_for_writeback(mapping, index, end); - tag = PAGECACHE_TAG_TOWRITE; - } else { - tag = PAGECACHE_TAG_DIRTY; - } + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag_pages_for_writeback(mapping, wbc->index, end); folio_batch_init(&wbc->fbatch); wbc->err = 0; - while (index <= end) { + while (wbc->index <= end) { int i; - nr_folios = filemap_get_folios_tag(mapping, &index, end, - tag, &wbc->fbatch); + writeback_get_batch(mapping, wbc); - if (nr_folios == 0) + if (wbc->fbatch.nr == 0) break; - for (i = 0; i < nr_folios; i++) { + for (i = 0; i < wbc->fbatch.nr; i++) { struct folio *folio = wbc->fbatch.folios[i]; unsigned long nr; @@ -2525,8 +2540,6 @@ int write_cache_pages(struct address_space *mapping, return error; } } - folio_batch_release(&wbc->fbatch); - cond_resched(); } writeback_finish(mapping, wbc, 0); From patchwork Fri Dec 22 15:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503416 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 ED46CC46CD2 for ; Fri, 22 Dec 2023 15:08:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 487228D0001; Fri, 22 Dec 2023 10:08:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E75E6B0089; Fri, 22 Dec 2023 10:08:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23C178D0001; Fri, 22 Dec 2023 10:08:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 08D1C6B0088 for ; Fri, 22 Dec 2023 10:08:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C54CA40E7D for ; Fri, 22 Dec 2023 15:08:50 +0000 (UTC) X-FDA: 81594786420.21.06074C4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id 19EF84002B for ; Fri, 22 Dec 2023 15:08:48 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wfmB6gnW; dmarc=none; spf=none (imf12.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257729; a=rsa-sha256; cv=none; b=0Fe5C2NAZEj74RCBws3btcRxhjITyMSES+BRtn6ARHdQr2pFvOU+9RH9Tnj4FwxQ4h4GrZ nafB6EJ67By+GLdNs98lPuA/APVltj09o6ikuHmF71D5lEuEDKHXEFScntBwjQgU5KJPcY yNKp0pt5AYf3DLDZ8nJyFnbFpIoUr18= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wfmB6gnW; dmarc=none; spf=none (imf12.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257729; 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=BwSwsSrvBcosA4alobfWiefPc9fIbR5mK3Ls0770Y3s=; b=aqM+McFgzQEB6nFZADLaUJi44SNaveutVueRrYXb9yHVhxBNwqJbg4Sib1ZNMp5Wlf9q77 gIMZWVLapEHb+mnn/b9Y66MVx9AxKMIIyC5uGgUWKw1sLeX+2thX4RLIYFmfzFw9Bv8lXG z2zgCzHrrLJfQ+JtjpbUXsuyw3wWpps= 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=BwSwsSrvBcosA4alobfWiefPc9fIbR5mK3Ls0770Y3s=; b=wfmB6gnWpnCr0AsGy1pjmk2FRv 9RZSI3vxFS6RBs4R1tZQlsDjGMbS5AgfaIQyY8ZfRUa4Z0Obe+NYQYoO8e7R/4Gt2MiyF4eHZhRpa 04GcAhvmm7iS/h1QLGYOxhyxxFto7ZTNAYSq8hoonSrTIW3QjmzBVy9hvaw9kQzam+c+YWh/OsC7/ vN8H5b3iW7d1DEOYaDwwWMp75w/Qoi7X7UiegVtM3tVbW7TPNFsyHfpA2nIdBmnDd7s88Npe2D92p 0alD3lK0uoAVqQynOao5x+eGhNarLIbFcKcxno0TpTXOOEO9PCYfs8kBEYY8lzUkrY//dXLo6d4qB F8spWMTw==; 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 1rGh8p-006BRN-0o; Fri, 22 Dec 2023 15:08:47 +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, Jan Kara , Dave Chinner Subject: [PATCH 08/17] writeback: Factor folio_prepare_writeback() out of write_cache_pages() Date: Fri, 22 Dec 2023 16:08:18 +0100 Message-Id: <20231222150827.1329938-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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: 19EF84002B X-Stat-Signature: 5t9f4orzjkihbdeno85s6o7gsdos9jh1 X-HE-Tag: 1703257728-731237 X-HE-Meta: U2FsdGVkX18US6FnMLxZO8UgOybKBkvhxe51qcOGt+fwCMa338pK1gdMnUBBL9dx33lqn1ViSDdB/uOj/gOz50cmejETrSvfnPomCqGe/Ph9LVEzNvG2OYkgmIXv16hUT3uDlfDyTuEURFMZK2u8YC1POlgTdP5+244haAurgfihG0WQNRuQDQvduP/+Gmw3VOuR3mwr/NdZmvyrTxe5qHzBgiH4qIvu2YWFxHWxI6yUrjhHm6M4QglNibQHIMOFlAPYERmSsjpcuP5CbLGqy5ftMK89Zy9s3jyhroT7eZtEAJD1bTym11YUp/IZbJHOJEf3LrkrRMp1hg3TVozhzuTwIEa6f/mbIk3/wPU9p5YRvx/ASOfeqnbL677RFZTldrc1zjJ/gDQpRYRj9JQ2yP1taIHrc9Rk54hES0AqPjx12ehZ7Glt3gr5FhK/J+oI23WqCeoJqltWT2JrgoX0uSvNQNCLTFVzrqWWKkH2IemPQ1Zgk3vqjOFOxFMs9YWsYkQ1gcOmJdS7mxKlbza9V8z/cEaCXYGy737Hr3bVwnFKp4lTmQCVD7YJi9+ZkqOh92hAYnFJfVdQAuf+O7zNTW7X/Eo0s+GMLi9oSMlgSkEyYjhqCL5SCARewPKWuqG8Asgn3JDKMV9Ci7B3sDcf88TqzA43CeQ/TRFI+Ka78YwBbxysn8t5gcyL/3G1jDZeOGKwCQt71QaKSfWT8Js32tKcNzMYTqdt8+i8ctvTXgPOCMh0xryKm3HDQKeCkxvkLznY45YdrZKytJjYCLCJxtM3Als/QPNV79wOpb86dVAeaRZT3WdTf6HoJcQ6QXoz61J+pxktR3JlL46w0O+E+jsgR1F6MpxzZpIegBOVHPwgoVzBamUgqfvPaKjwGtzkBW9BDZoFzazGpo7WYKQYuOSiv1cUIVBGBgz12669/3yChOJmZtSpMJ88IjkgnsbzHm5v0oWsGO9NxFeCa7f oUdR86s8 VNDUPSb4ZlQX23JRvuPF49FLj946i1aU0fvv52EvEbe2Pl3Bpc4hPBYfhLaxzLWbsuoIqpPXZ8H1AmfSkrt/eu0JIo76AtVm5A/Ptu+w7x/5HbQpcQQojS0qgkU8zbkUhSJ5lPVBflR69pg/h36BgN0tmIbZSmKzlxUnas6ys3ftQaZruwEiwphTOi2r7aFE2A0oGcSaWO7BZl6h0XQFQtFNwRoYQRCgqnOhWxVkk5Mabc47GVHL+iLHOTRFIJI7+PyuiycSuslpSae6O25qMpZCT5EAJWZo06E79bpRmzP/j68FSWxL23aY7Izjsajm7X1YwjKdaupKfkbEhTi/pGJN48dVbhTAD/I/pKXFLIszLPs6SQFuYZ7BgkDG17pHo9DNSr2+qulXzxb0Ffq5upc4vYIp+Abr2oKh62H80PrmemeFXTmlq8Aslc6RTWz/iGZCIQHr8aSeKlG+0f2osoaymwiOnKN9ccJWowon6pPU9I6cJaNRn4HNsWRj7sgVR2IUJYtdbn5rB6MT1orbWdKfTeHyNcDwrjIjo 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)" Reduce write_cache_pages() by about 30 lines; much of it is commentary, but it all bundles nicely into an obvious function. Signed-off-by: Matthew Wilcox (Oracle) [hch: rename should_writeback_folio to folio_prepare_writeback based on a comment from Jan Kara] Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 61 +++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 798e5264dc0353..fe508548482217 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2397,6 +2397,38 @@ static pgoff_t wbc_end(struct writeback_control *wbc) return wbc->range_end >> PAGE_SHIFT; } +static bool folio_prepare_writeback(struct address_space *mapping, + struct writeback_control *wbc, struct folio *folio) +{ + /* + * Folio truncated or invalidated. We can freely skip it then, + * even for data integrity operations: the folio has disappeared + * concurrently, so there could be no real expectation of this + * data integrity operation even if there is now a new, dirty + * folio at the same pagecache index. + */ + if (unlikely(folio->mapping != mapping)) + return false; + + /* + * Did somebody else write it for us? + */ + if (!folio_test_dirty(folio)) + return false; + + if (folio_test_writeback(folio)) { + if (wbc->sync_mode == WB_SYNC_NONE) + return false; + folio_wait_writeback(folio); + } + BUG_ON(folio_test_writeback(folio)); + + if (!folio_clear_dirty_for_io(folio)) + return false; + + return true; +} + static void writeback_get_batch(struct address_space *mapping, struct writeback_control *wbc) { @@ -2470,38 +2502,13 @@ int write_cache_pages(struct address_space *mapping, unsigned long nr; folio_lock(folio); - - /* - * Page truncated or invalidated. We can freely skip it - * then, even for data integrity operations: the page - * has disappeared concurrently, so there could be no - * real expectation of this data integrity operation - * even if there is now a new, dirty page at the same - * pagecache address. - */ - if (unlikely(folio->mapping != mapping)) { -continue_unlock: + if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio); continue; } - if (!folio_test_dirty(folio)) { - /* someone wrote it for us */ - goto continue_unlock; - } - - if (folio_test_writeback(folio)) { - if (wbc->sync_mode != WB_SYNC_NONE) - folio_wait_writeback(folio); - else - goto continue_unlock; - } - - BUG_ON(folio_test_writeback(folio)); - if (!folio_clear_dirty_for_io(folio)) - goto continue_unlock; - trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); + error = writepage(folio, wbc, data); nr = folio_nr_pages(folio); wbc->nr_to_write -= nr; From patchwork Fri Dec 22 15:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503417 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 B4795C41535 for ; Fri, 22 Dec 2023 15:08:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7D88D0002; Fri, 22 Dec 2023 10:08:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D38D36B008C; Fri, 22 Dec 2023 10:08:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B894F8D0002; Fri, 22 Dec 2023 10:08:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A0AFE6B008A for ; Fri, 22 Dec 2023 10:08:52 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 750DEA0EE7 for ; Fri, 22 Dec 2023 15:08:52 +0000 (UTC) X-FDA: 81594786504.24.7EBA403 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id DCFC840028 for ; Fri, 22 Dec 2023 15:08:50 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=yIAvYy07; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257730; a=rsa-sha256; cv=none; b=cg86AE7TPNl8QLvBHrlbbeBiGVsDWf7UsEj3mVY1iYu5idWUH2ZcGmyCHKx06KBfCSu6gq MAwAvAa47ZYPxlRNq6DLiHGa2jkdqQXsJLshrnhLoD/qNRcyG/g1cltn+cPhsamcAsabOr Qz1VmkyM93Crs4tIUxYYKHRTwDdw0OI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=yIAvYy07; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257730; 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=3uxekAKYtWjU4xunWw9AHOgXL8ikM7hINi+MFUVXD1Q=; b=QKSE5v0lD35KN1gfjBGVTzaVKc1KmbyBYcnvDgDjPSycppzIVsuMtmGoR980Q8jEyVYOqB qwPsuoOXagtGlgY+XIT4yC5dObYh5qwLaEbpxKFZZ6TDVrt4MdRUstePzZtR2BtmmJCE+o GlSsp8qLXkb1NuQ15kVzu2k0zBMe/es= 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=3uxekAKYtWjU4xunWw9AHOgXL8ikM7hINi+MFUVXD1Q=; b=yIAvYy07YYVywxCYNd4RPpUC2z hov+bjdw7XI7TCb4f222lmJzvS4zTCCXlwyPjJvhMKKBCYuLTj719RJP03bEqb7Ny/AEXGYoBrHcJ bQlB9PsdksaKg3Kudutgim4vY/WWFKu+9i5EiMoYzhnkQ2fMUEncbFuxCNqzsW6Qo2DuXMnVs1neU 4eh+YkvnDEvwvL3fOe1ac3QeobScCtYlB/jENSX9n2lKGLzBwJBD4XxjurornDUhLw7t0P15+/sNC Hl3HtLu61rDDl8jjubtzUWofoOftxS277w6sKdRzINQQXfSfWcYjG92SuUr1GMB27Gab9/JW6O5bL q6JhGxDQ==; 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 1rGh8r-006BSh-23; Fri, 22 Dec 2023 15:08:50 +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, Jan Kara , Dave Chinner Subject: [PATCH 09/17] writeback: Simplify the loops in write_cache_pages() Date: Fri, 22 Dec 2023 16:08:19 +0100 Message-Id: <20231222150827.1329938-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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: DCFC840028 X-Stat-Signature: 96ifqspg6hzkkai67o9s4u5gfj5wnhe3 X-HE-Tag: 1703257730-683046 X-HE-Meta: U2FsdGVkX1/AskXJ/qLnwrqpnGYIXRHIB5j1rZZ7ybNkKkH0d0cqAf3dfJsiZdSPtIE+WQmllVwYVc3tbCrWCGngF3BvvlnOTNNUpYPag3DUZNI2XcYO2gV+JexbKRTc0b/pe5xHQrQo77jIQnoqkjLBDTWT/WZk6gySnhL3kCGFAVZb2A1RiSujCIzNgTW5JkOUbK8+Bo+fE4Lm4K/K1oHv1v1OadFLweznPL5I3rfbV9XCLoPveUxNyiad9JwFm3bqtWRrEUo/eJwm+pNlGApne1u5WkOX1pvH/39Z+QtUwnO1kfSL/+8i6oGMeKG5NS3ds0jrw78hZXpBzZdlWsOaUWIY4HhFzkjCS9gqPfXs1JvFKc83yf8cSurX6IcVYAOvHF7VSagqOioZeH4j2rGISt/ZbgmdoX/PEcD1olMcdoXwv/TW6aL7N4otfTyGP1QNIaXFXyx+IKpbR2iVBIzdkFrMqh9eudkdAnRU0BBUfk2/HcGsFUUyADZTZjD/9Kwlo4MihY28j1U5oEtz5Uwndb5KzXSyZc/vN3dihV/VOEYpstteJ3V/qVxPTBLg9YKbhar7aDVE7ms2W2q9rQ8vBpysyEmajlu6y9V1izxyLqrr/x02Ky/v/XdmmFnWwb8bChWye1rSJKZloFxFp3ZW6ykjW9zJR153xJkTusBo6XyGP6no8fe2bykj+rftVhmcxQUhTjwlNmt4oCZtEprbTvSNgSGU/Kb3HFAGTL3wO+YkJBSQ293yW9pNVXDbPPD44xKEy9AXoY8y6FmprmQXcCvG4a/iEVD1zdtnFyiyRITf4OqYuFOiPIcRO4hyGLPbRW7XP89GV7wsXC3LFIfTcnGhgJE5WncFG68B/3ayigv07QHMSbaOxTNjHX+nkdVzU4K7et+lgDdxcmaPsDzkas3TQjj/9e0XfFiFN+ve4pyiDeIm9wVDYAeSXW/oqknIQBiR7Y0RkZGJw4q VLYjFcvf IMdIg8kR4bRnPzhW0bu4I99L1ZAUpTb+hx6elK96D73jkcmjEArhO5qkB1NCcKCTz3anFvoOHRszQ9ebTXvA2K2oDNBDbBdoicbPOoNr9QROhJyi4A+rfTxs+9fagfgWRtsoRWqAl1lkhVDD4QgdhifrkOcLuSWfuPn3YbHx1kYvZlOlqzI55dg/l/hJuItT1D5W7KuoSiewii4gr3Bi25rRHJA== 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)" Collapse the two nested loops into one. This is needed as a step towards turning this into an iterator. Note that this drops the "index <= end" check in the previous outer loop and just relies on filemap_get_folios_tag() to return 0 entries when index > end. This actually has a subtle implication when end == -1 because then the returned index will be -1 as well and thus if there is page present on index -1, we could be looping indefinitely. But as the comment in filemap_get_folios_tag documents this as already broken anyway we should not worry about it here either. The fix for that would probably a change to the filemap_get_folios_tag() calling convention. Signed-off-by: Matthew Wilcox (Oracle) [hch: updated the commit log based on feedback from Jan Kara] Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 94 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index fe508548482217..d62bc3498ed975 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2475,6 +2475,7 @@ int write_cache_pages(struct address_space *mapping, { int error; pgoff_t end; /* Inclusive */ + int i = 0; if (wbc->range_cyclic) { wbc->index = mapping->writeback_index; /* prev offset */ @@ -2489,63 +2490,60 @@ int write_cache_pages(struct address_space *mapping, folio_batch_init(&wbc->fbatch); wbc->err = 0; - while (wbc->index <= end) { - int i; - - writeback_get_batch(mapping, wbc); + for (;;) { + struct folio *folio; + unsigned long nr; + if (i == wbc->fbatch.nr) { + writeback_get_batch(mapping, wbc); + i = 0; + } if (wbc->fbatch.nr == 0) break; - for (i = 0; i < wbc->fbatch.nr; i++) { - struct folio *folio = wbc->fbatch.folios[i]; - unsigned long nr; + folio = wbc->fbatch.folios[i++]; - folio_lock(folio); - if (!folio_prepare_writeback(mapping, wbc, folio)) { - folio_unlock(folio); - continue; - } + folio_lock(folio); + if (!folio_prepare_writeback(mapping, wbc, folio)) { + folio_unlock(folio); + continue; + } - trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); + trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = writepage(folio, wbc, data); - nr = folio_nr_pages(folio); - wbc->nr_to_write -= nr; + error = writepage(folio, wbc, data); + nr = folio_nr_pages(folio); + wbc->nr_to_write -= nr; - /* - * Handle the legacy AOP_WRITEPAGE_ACTIVATE magic return - * value. Eventually all instances should just unlock - * the folio themselves and return 0; - */ - if (error == AOP_WRITEPAGE_ACTIVATE) { - folio_unlock(folio); - error = 0; - } - - if (error && !wbc->err) - wbc->err = error; + /* + * Handle the legacy AOP_WRITEPAGE_ACTIVATE magic return value. + * Eventually all instances should just unlock the folio + * themselves and return 0; + */ + if (error == AOP_WRITEPAGE_ACTIVATE) { + folio_unlock(folio); + error = 0; + } - /* - * For integrity sync we have to keep going until we - * have written all the folios we tagged for writeback - * prior to entering this loop, even if we run past - * wbc->nr_to_write or encounter errors. This is - * because the file system may still have state to clear - * for each folio. We'll eventually return the first - * error encountered. - * - * For background writeback just push done_index past - * this folio so that we can just restart where we left - * off and media errors won't choke writeout for the - * entire file. - */ - if (wbc->sync_mode == WB_SYNC_NONE && - (wbc->err || wbc->nr_to_write <= 0)) { - writeback_finish(mapping, wbc, - folio->index + nr); - return error; - } + if (error && !wbc->err) + wbc->err = error; + + /* + * For integrity sync we have to keep going until we have + * written all the folios we tagged for writeback prior to + * entering this loop, even if we run past wbc->nr_to_write or + * encounter errors. This is because the file system may still + * have state to clear for each folio. We'll eventually return + * the first error encountered. + * + * For background writeback just push done_index past this folio + * so that we can just restart where we left off and media + * errors won't choke writeout for the entire file. + */ + if (wbc->sync_mode == WB_SYNC_NONE && + (wbc->err || wbc->nr_to_write <= 0)) { + writeback_finish(mapping, wbc, folio->index + nr); + return error; } } From patchwork Fri Dec 22 15:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503418 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 54417C46CD2 for ; Fri, 22 Dec 2023 15:09:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3C116B008A; Fri, 22 Dec 2023 10:08:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4E3D8D0003; Fri, 22 Dec 2023 10:08:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEFAD6B0092; Fri, 22 Dec 2023 10:08:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9AF406B008A for ; Fri, 22 Dec 2023 10:08:55 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 690D780F57 for ; Fri, 22 Dec 2023 15:08:55 +0000 (UTC) X-FDA: 81594786630.10.DEE524A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP id 947CC20032 for ; Fri, 22 Dec 2023 15:08:53 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=JaAkdqZm; dmarc=none; spf=none (imf13.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257733; 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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; b=yWnym8D/EgnNB+RZw6bg1MURzJKj57LPWnOWfPYn01qNDNgEd+d7oM01TdVarj6yWQjW9m acnMxv0ooihUpJMzsiWckvDZ0+iGWORuzBi7cO6tgSA2JhsBmHszvnjPrrguB9qjfuXh2E aJz0Dp6mi8XfumT+10AigmPTJOVR1tM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=JaAkdqZm; dmarc=none; spf=none (imf13.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257733; a=rsa-sha256; cv=none; b=2GWeGdaoHcscZaKoKLyVHwyh3MJogXS4VsH3hJJK6zJBOgL9SVW5eL0sfYo3mQdhQpdx1v swr4GuBuubtOkW2jy8EhaeKfXjTEIepYRi1+tzeHJuhsNw1+URknq0NhNEcV5por1yL1jo /N1RlbzhlUG/NaHKWOc04PCmTaEaIAw= 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=dVreMySeIHkVOAtpz+bbvTB1WjeCUE+T6e0OUt9+4gE=; b=JaAkdqZmOduEeNKqFX4Ku2J7NE ZUlndRMyXJVHVpS3YBp+6lZQe4Hb/Oea/LNWPgl4QZ3Yd8ECfM3p5l6Uct6A8zEfAoOe+Z0jwyHJ7 0fm91BwTHShgOIQMcILm75blc7XQRH49G/JVXgOxWXo0dVFsqXpRBaEdyrPs0quk5x729W9gXmb98 e255UWRmLzkFgEPdttgBQuUTeEySgAg3MR6Ea+qCXmLfCd4NzBC6vD2F7y56dqROKEg04RYOnnN0N lEHwOMZeqBxD5fPkSLKirvNRdxdMaUp/A77YEni/edJFRZ5TA6D0gHH4uUlkwB64Jons6MuMIPqUz RJn1Yl1w==; 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 1rGh8u-006BUd-1I; Fri, 22 Dec 2023 15:08:52 +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, Jan Kara , Dave Chinner Subject: [PATCH 10/17] pagevec: Add ability to iterate a queue Date: Fri, 22 Dec 2023 16:08:20 +0100 Message-Id: <20231222150827.1329938-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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: rspam12 X-Rspamd-Queue-Id: 947CC20032 X-Stat-Signature: 3zxieucnj5uroajx61jr1chcgztx5gzr X-HE-Tag: 1703257733-270527 X-HE-Meta: U2FsdGVkX18YPYrmej4WxM1NCwunwAxgXQEmg65FDX7xl0NymD7DLgWbR1EBYJZs0u53APgw8KMOkmzxIRx5VIc/LV/fPRWFNTDj0EcD+jV/+wFGYgBwnPWHmTGweby/N7eoT3nElgGZDlwF3xd0Cn6dZb2+0TkgG5uYUQAo9WUYV28T+Z/toRIsYUkhYZrFVKgRsjAK3QzdS8urVCMo/qJPCNhFaCEFUq08jR9iW6KqGP3Mi9Xore/9TeilCTepft/uXmb20xqzKbbQ8pd36NKfxNNSUrYkcNKOxEsfXzaJ9wTglDQvhYMHNPU/GNQEmSfWbvZyPy2LpWgfJoKUmTIH2TZmCD5ZkQEwOJ9tl3GZ1Nnf5/J9uAkwMcVxCiUvK6mxlFypd+Hrw9PqiQWCuN0gPNls1K4dzE30IF0JAtaSQrYITyfJv3eJB7b2j1u5AQoLMpPifPerZQcsyUZq3h850IfZooLouFuZ/UvctXpRWPaZDaSo7L8fS22yh2ceAGRZKi7r2Asv+pQt3xxaGKlc3/4rwj7CfioMS39AoOkZn+jDcPr3O80d+wdYTfqxUGqYNH7o2svtPdZaMntddqTf5hPLGGWfgEFDYaqgbA00ga0YKtYLf/6qwO+3wNomP0hgMR8uoCqkBg/hsTCeWn8m+fJY5DJeOxYJCTJH+ZXWTf97Cg6FhzA5rw+g5RAnx7LeC6x01oziTvk0kZfaNbaP+nGWcNysZKXWp/y4fgmVoshDg2D+NDDt25BSCIOFusGVr7D58GsxR11h51w9kPNvZggd0rMwqEz4HSeAJlPchu84KX41Te4cNlKMEOnAa1bYCtbXIZVb+kWBqq20L3nZQGnQbgqVQED2OKmTDUDl7LkH3FW/yA2u355BTh1r5Rz5i8dYLAM6VWb2DcQ0R3g4BT+JfnMOlBcrl+AGDRA4Fs8ulQVuxtUtCmtJH1gslvnwbczVMobXRYMpPKS OTxw6zcg kVO/k2c57F4PKDKGtr7BNJTNXm5by1eJOPws9ZUMmLw2I1uX9ppCKV76KKSFShSvCU0zQpjIiy843aiAS7tLGBDZeN4jPvucw4MQWVLK/PKPt4fAYbE0lox8EMKskDTcSm4I+ORaGWH7bcDbyGqxZJ2nl2kwljGGAwNdxWSC2FCNOrN4PJWgkvMiZFgpFCS6kiIE7TeX8+m0U+TCOh0ispLELFKGCsRbMKzShMlI22g9f99FA5OGeOQkfRGW35iotVmcjtRwoOGKucmIrzUV9v5ihFeuOQC/8VXG4EJRmsVg1R2PysaMOFAYJolLD75qeEyAdzN/C459hnAX2fsW6uJSi5mlhEJGK5k8MSANIa0fCUGNGp0LX3KjwjAxz9GnbX711kPjsFbBWBArIdr+pLx583/R29gb9sX/FxNVn6kAWe4n2Jqk6VSUY98RNZBlM+x26p8ngsnwyUKh60O+eOrzFeYJRIrm+j1klTLS6/4/4vJ6fru4+VjjDFA== 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)" Add a loop counter inside the folio_batch to let us iterate from 0-nr instead of decrementing nr and treating the batch as a stack. It would generate some very weird and suboptimal I/O patterns for page writeback to iterate over the batch as a stack. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/pagevec.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 87cc678adc850b..fcc06c300a72c3 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -27,6 +27,7 @@ struct folio; */ struct folio_batch { unsigned char nr; + unsigned char i; bool percpu_pvec_drained; struct folio *folios[PAGEVEC_SIZE]; }; @@ -40,12 +41,14 @@ struct folio_batch { static inline void folio_batch_init(struct folio_batch *fbatch) { fbatch->nr = 0; + fbatch->i = 0; fbatch->percpu_pvec_drained = false; } static inline void folio_batch_reinit(struct folio_batch *fbatch) { fbatch->nr = 0; + fbatch->i = 0; } static inline unsigned int folio_batch_count(struct folio_batch *fbatch) @@ -75,6 +78,21 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, return folio_batch_space(fbatch); } +/** + * folio_batch_next - Return the next folio to process. + * @fbatch: The folio batch being processed. + * + * Use this function to implement a queue of folios. + * + * Return: The next folio in the queue, or NULL if the queue is empty. + */ +static inline struct folio *folio_batch_next(struct folio_batch *fbatch) +{ + if (fbatch->i == fbatch->nr) + return NULL; + return fbatch->folios[fbatch->i++]; +} + void __folio_batch_release(struct folio_batch *pvec); static inline void folio_batch_release(struct folio_batch *fbatch) From patchwork Fri Dec 22 15:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503419 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 75554C46CD2 for ; Fri, 22 Dec 2023 15:09:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 303508D0005; Fri, 22 Dec 2023 10:08:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 23A708D0003; Fri, 22 Dec 2023 10:08:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0662E8D0005; Fri, 22 Dec 2023 10:08:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E68168D0003 for ; Fri, 22 Dec 2023 10:08:57 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BF1701A0CDE for ; Fri, 22 Dec 2023 15:08:57 +0000 (UTC) X-FDA: 81594786714.03.E5A6F33 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E3C540002 for ; Fri, 22 Dec 2023 15:08:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257736; 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=o5H/XSwme7xEQtHV3m+ZJ3LCmsROSQ4hprrOJy3ayZQ=; b=Oouxwt15MstFPPq7ew3kemxWtxKwaxTwTwt+/UQ6glZXh6X6kf+3GNEaFHUSh+qK/IqLvo VrbTgoIhh6yOhWuiCShDLAsn7iSRCWjKKL4jYsmoilL3r09obXKCP7tCy5+VhobH8IQ3GX 48cJST7dNtxiIR8ui/JwQJZuta3+WVg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1fWeY1tU; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257736; a=rsa-sha256; cv=none; b=JJiZL8uv4gb+1ss4h/VNLfkFGovpVI+4rk86DTjyrn9zf2xpxpTZWhFAijdgvTUEtHT+s0 lIOjpGYnCugg28TW015U88HPlXZGF9WQQBR7Wt3q2YB7NrYqdSV9RO1IE8vhOrSIQPNGJY YUFLEutDwU7wjUeLvZxQ9ELJz4mimVs= 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=o5H/XSwme7xEQtHV3m+ZJ3LCmsROSQ4hprrOJy3ayZQ=; b=1fWeY1tUuYOLXS4fYxt9eNpkZL uPDqWxlQRvE8go0ce8UcYudxrGF1l7Hsi2GJtUTlfsjpr+mucLE+tfcAIVoKgfxQNTLFBiMF7r/DY p038ichTWr69GTwEoBsSaNQuiXLmrhkToyxTmt+UC6O7wN0TyO8qBzkZeaUvRE0kPxYvKDXxGxOYW qHtxgdaRB9TK1g1hTe9EdhIoxKGVVqmmdo87DBp/9uLtiOOZj6aPO9zZLjWLCNCMR4p2Qcq3bJU/Y QrtkzDepUlCDu+3TMC/L214GlcREtVp+DAjwQOMC012XRtoSbmzTX27ToGjrv8hTtpiMxBwlg65sf 8wjZTjvw==; 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 1rGh8w-006BVk-2h; Fri, 22 Dec 2023 15:08:55 +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, Jan Kara , Dave Chinner Subject: [PATCH 11/17] writeback: Use the folio_batch queue iterator Date: Fri, 22 Dec 2023 16:08:21 +0100 Message-Id: <20231222150827.1329938-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1E3C540002 X-Stat-Signature: itc1d6c4ngdban7h5s9ynhk31qsnp48e X-Rspam-User: X-HE-Tag: 1703257735-46327 X-HE-Meta: U2FsdGVkX1/QTua2N86wDl0tg9um+oId6+N4c6pfUQmLvq6N7ju+bc5oqLJ3EyH83o1OnPDDJv5KT5wRW1lG59JZ2Q+XDNd7Yqz/ZLXiWdrp/rE/LhMbgzgw3aC+BGzwWA//YszZhtIbifAW0zRh8N6YDG8qZezhTLbjg1h1ipNt2+rQhWQRBtYBguFCdSFWnT7putHH6pQfXHpW/f+zHshJfnlFf0tzE6f1S/fvQMIdw27R8OaoehryXA3HdktxrCy58cSezAyOO8F/Cxfdp0fy4ipZXNYWrgLwtd9wcw6AlAIOqkzyQRs0Fi0IEGFC+vMiMqxricFRsaDvqq7x1PNLVaS592KmNV2mmIorriDi9vpyx9qwwr1gl42d0rAoLlKTMIgzFRDlv1P4nD2+gsJ8m6Zg7TzPbBUKpu1N1tHDLRZQO5jEOoTEbk2QcLntmEcWmgvEQUAliD3YkHqIfr0Xf8QGU9G2Z06dXbYJTgWtseFNBKwK5ONv5XoIzEJkjEkrBhaNqfGNrNwv1hDYRNHOvYw7sG+TIfQz7qv/MYioGIy9aTk/jW7CE3nsJZEGaoicVsrpyfP+AHAHbHNisrKeJIiL5ibCNc/1YmgDx9M+jlO2rzlCcEf2wAT1lGOb86BtVapofDtWkZUTIQXZerbL1RiJU/N2xuthZxOcOa8iNRDGgh62a6R3IQ0zO7ZxjuNPR45U8Twi9N1TqBFC7UQ6U3pKbcj25+jaQFQC14IkvJDqI8/cv2BdAzmaJsL5mf8lGZi1qA/fLeuuFU98wtBZ3vRYxaG0fblQhmolPGAES9Ekk7d4FE1enAfvb90skyHMGsNzJQ27hoImUvmaeHMoxhRlmHiLaQsXJCpJuAFpjDL0Bl1kPmS9RAmEOaH+ByiyRktItgsLcfkjrLJiTD79v914VRv2MX0SbAl6ihImtv54AwGtdH8CD41Cplo77tZQqVAF7WBXhUWbkT2 qAK86I8U 4aPH3XcDglsBykqcnEnVTM8wgBIsiXRhy005dUHeOdJxKPBb19HUYyBtgAr38fNI5UkbztNtahSGT9o3c2yY2+uDpLUaFcBPmJNo03gP7dnHlLiq6JHZvDLSPplwWpT9qSnGOGyUH2ydQLmLPr/6n6wJK1GXn6+AKMx8Nkm4mi5Qprku+Kl1a9zHheHChPDWt1pplozGuWMqjDEhT5GNANHGCn7G6jsZ7V4WvEeJBP61wVoh+P2fm8loMw44teN1Nj5sGfkTf/1TqUCPJRkmzFI95z/mYIoqx17TiLAlyCIQLMj5Myye2Ush3tgCNvswxyjpRpFmXA+F28AmS1gzzz0/brek/mn9J8I8znYk2yECh9ZYx6C9cKtxa+ds89l4Ws5DihszAY+g2YmCjLYi3uEcXycR1OCRhjvZl1Xo1WQHPJDvWu7+TCxUEMX2k2C6b/bHm+3jyV5z4CuktEaFWT+9fgGCKCwoW/itesV2wAyzvK2ZIwGO71yUgWN9BXmPWawG75f/SjurT09hCO27IO5Ewqle7gu3t1wNa 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)" Instead of keeping our own local iterator variable, use the one just added to folio_batch. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d62bc3498ed975..47457895891221 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2429,13 +2429,21 @@ static bool folio_prepare_writeback(struct address_space *mapping, return true; } -static void writeback_get_batch(struct address_space *mapping, +static struct folio *writeback_get_folio(struct address_space *mapping, struct writeback_control *wbc) { - folio_batch_release(&wbc->fbatch); - cond_resched(); - filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), - wbc_to_tag(wbc), &wbc->fbatch); + struct folio *folio; + + folio = folio_batch_next(&wbc->fbatch); + if (!folio) { + folio_batch_release(&wbc->fbatch); + cond_resched(); + filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), + wbc_to_tag(wbc), &wbc->fbatch); + folio = folio_batch_next(&wbc->fbatch); + } + + return folio; } /** @@ -2475,7 +2483,6 @@ int write_cache_pages(struct address_space *mapping, { int error; pgoff_t end; /* Inclusive */ - int i = 0; if (wbc->range_cyclic) { wbc->index = mapping->writeback_index; /* prev offset */ @@ -2491,18 +2498,12 @@ int write_cache_pages(struct address_space *mapping, wbc->err = 0; for (;;) { - struct folio *folio; + struct folio *folio = writeback_get_folio(mapping, wbc); unsigned long nr; - if (i == wbc->fbatch.nr) { - writeback_get_batch(mapping, wbc); - i = 0; - } - if (wbc->fbatch.nr == 0) + if (!folio) break; - folio = wbc->fbatch.folios[i++]; - folio_lock(folio); if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio); From patchwork Fri Dec 22 15:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503420 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 34872C46CD2 for ; Fri, 22 Dec 2023 15:09:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DD5A8D0006; Fri, 22 Dec 2023 10:09:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9685F8D0003; Fri, 22 Dec 2023 10:09:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71CBE8D0006; Fri, 22 Dec 2023 10:09:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 611D48D0003 for ; Fri, 22 Dec 2023 10:09:00 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 436A81A0E9E for ; Fri, 22 Dec 2023 15:09:00 +0000 (UTC) X-FDA: 81594786840.26.12E85D9 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 7FE41140012 for ; Fri, 22 Dec 2023 15:08:58 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=yfQSDflm; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257738; 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=uhQwu0XzlF9g6tYMy5v46u1+umuzBvOukQsb3rulW5U=; b=wFEU/+xS3/5inJB0irGcAFhmzYmnr838SixN/IhUWgjW1GJFaCjm4org6dcTRKsF7SbwyL 2nB/P1lnngRL51M1bosEbghYipdNi3MA0CXGq7wNo7dscVqSigwW+vDGu6eiUBIwvcA5q2 L+fXsdlpG/0IJGvquZQ6ShNVT6hHkmc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=yfQSDflm; dmarc=none; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257738; a=rsa-sha256; cv=none; b=X8DmA5U5ZmxJu7waTyIAjChrz4ysdDCbax/6aKGmzwKTqXdwDAzkX9/1zn8+GkaKm4BIWI z5IZSThwgidenWKwE5AQRmZS5voZqe8DLPg4ZXz/m1oGnUuEcDCkA81jNW2LFz0YXCRZIo EZgRHoSJ96P2PYzoxyy4LkxLWyq+dqU= 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=uhQwu0XzlF9g6tYMy5v46u1+umuzBvOukQsb3rulW5U=; b=yfQSDflmOsFoQUBv7S0oxf31Lt bA8UjbacePhce939zrO4Ir44tqLbrgyX1i5WWUPFn1Dh+11PMGev7lVY8wnZureYjbZsYuESrU/5W 7r7TRMZJi1BVUw35tzYKJsGhRRphnMJlwuQRlfFG7hoKMPvs2RHHddSnKmZ5Zo6xy79keEUFELCWb di7aVlxzJVcxNMi/KVCgAn/kv4q2J3SRszZOCJqDD9t8X6NkbjyqzvwY30OmTwG+hrdVwHprkayFJ byFe+UZ+5u414GPfeJPQCofOizDxVA0C4ZgEqEEGUVbFOp5tujEidQTo2hVAYbvVDVsV6qignOnCn L7ZBVhGw==; 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 1rGh8z-006BXA-0y; Fri, 22 Dec 2023 15:08:57 +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, Jan Kara , Dave Chinner Subject: [PATCH 12/17] writeback: Factor writeback_iter_init() out of write_cache_pages() Date: Fri, 22 Dec 2023 16:08:22 +0100 Message-Id: <20231222150827.1329938-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7FE41140012 X-Stat-Signature: k8918x6t31rw739xbcrd4eqs4fh3fw74 X-Rspam-User: X-HE-Tag: 1703257738-966271 X-HE-Meta: U2FsdGVkX1+dgAeWmfzSiMccsCsdzIqaD/ajr2yRZVyBMeu/3l5GeURep5rDD2y0f8nj6dpW7OQQ4uy03aNYL1NQiB7FEpzPN7mOLYBbLUUQIN3KqQK6Yz3ywIa0F1J+R0dGqnvynm16UhRCwdPEEvewHlfMorqT1krRWpJ4Mld1iDyy+S38teuJRWCYbX0we2QSBixATc2Jfwh934ILWQXwDOQHsYtr/cAWDC52NxVkEjpNB3Xkvn2be5XvH4hplv1u368XAyVgeR3NMhvuZsOZsrqfWLwmWSDjbZ27IznHaG0JSvF2grXqB6vaS+xTfPcnPBF7LKxChRX9gv5qzLhIrCqOh1D4qnxoSf9k4BFZ4Ai5EvVZWfvAseml7r+TwfO9yzk6pHX+YHdRTXjnbjwJMOOqVAX7OylOEn3ht4teo2W7XHmbQwr7Bs7Q9ZlopuwEZL3g0+JDHguaN3ZRhgCId8EwlWnD0DcQLEb8KoYds8AKLaHyJHwC+MpYFoMbTeOUONM0rgArNwThDqaJ3m2TOn8pHlHxaGeCdFklFQX5cbbBeankvgLlJc+0PX1uTe7QbYZnFbAheBGXH8l5x2b5pIGbAw7+AAcy711LbEg0oSz7z5R/rw9XAkEOcrJvGQgHt6D5LXsd5DtkUUyfzPvLw8Rhd/nTNsHBFI+pH0DklST39+qvgtGfLZfaJZrZZglsqWrRJredie7u3FP68eYzO2dUs2XFLTALX2Zs7U7kDBLjzjybIvVB1VZxwNSLk0umvJOin/JdZS42IY8oIMiVWpo5u1+05tFa3PcmdGV6Q2TqkN4Qh7JGjqO3sPF+usXGkS6G4HlPiyYKNKqJScR3zQS5X80s+oXB8vk9OGistYNFwYN8QMU3Oud6lAn7k6yOhc8kmCSY1qsdjQ68u1jXJPyvNokEcvKJFo9Bh2Gwtqe3/8dddVajSC5zdkpD6eRCrjqYKZNAlnXYu4T hqq96o1u av9aItfYfQmrQ8tShKSg5YeBkKRRJQMoO1t6lxl21YZsxGYrOO9Y1TubCKgErhqqEhFlWTeCkdc74blxf/g2p6h5w/TJ+7RypVGN7NqSkwtDqbZaJfok1Tuvj/3co3nnwz6h1ivEOTk16Z+BTgxRKbWWPoJsLpxJ+xrUPunALmAzCJiqZLSNNPYvah9WDYJ9Q1gDSI4QEX7h7paJC84LOV4mnFcsUEoiYTvX6L50KfjatDtpHdvHvfZlKee9bMbUAaXCMl1wUaWnfn1wiLes/AVGJbFez3rYcZ0vwdV4EuP9SDlNEuY6MXMijv2Pr4Qr2b+Cp+enTqJX6F93nyZRFKcJmSkmfO9H2+rW9Rb45UMQJos/P1VJYvyMxyHNbYtAYtQSmh5zWhtB+LCqAKiF3P/UNl7bILFAt5gnd7jOcq/9zgxTB1b8Zl8Q2Mh0CkAansKxNxWkuwKWGIoWxetRxWz1c7nVH5VImxP+3V2ZFdG7hDbOeqMfKNKISQLIIT3xf+SLjJbiGEpU6g2aDVkklAuBasxWJq2A4U53J 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)" Make it return the first folio in the batch so that we can use it in a typical for() pattern. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 47457895891221..f85145f330bb36 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2446,6 +2446,22 @@ static struct folio *writeback_get_folio(struct address_space *mapping, return folio; } +static struct folio *writeback_iter_init(struct address_space *mapping, + struct writeback_control *wbc) +{ + if (wbc->range_cyclic) + wbc->index = mapping->writeback_index; /* prev offset */ + else + wbc->index = wbc->range_start >> PAGE_SHIFT; + + if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) + tag_pages_for_writeback(mapping, wbc->index, wbc_end(wbc)); + + wbc->err = 0; + folio_batch_init(&wbc->fbatch); + return writeback_get_folio(mapping, wbc); +} + /** * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write @@ -2481,29 +2497,14 @@ int write_cache_pages(struct address_space *mapping, struct writeback_control *wbc, writepage_t writepage, void *data) { + struct folio *folio; int error; - pgoff_t end; /* Inclusive */ - if (wbc->range_cyclic) { - wbc->index = mapping->writeback_index; /* prev offset */ - end = -1; - } else { - wbc->index = wbc->range_start >> PAGE_SHIFT; - end = wbc->range_end >> PAGE_SHIFT; - } - if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) - tag_pages_for_writeback(mapping, wbc->index, end); - - folio_batch_init(&wbc->fbatch); - wbc->err = 0; - - for (;;) { - struct folio *folio = writeback_get_folio(mapping, wbc); + for (folio = writeback_iter_init(mapping, wbc); + folio; + folio = writeback_get_folio(mapping, wbc)) { unsigned long nr; - if (!folio) - break; - folio_lock(folio); if (!folio_prepare_writeback(mapping, wbc, folio)) { folio_unlock(folio); From patchwork Fri Dec 22 15:08:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503421 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 2E3C9C41535 for ; Fri, 22 Dec 2023 15:09:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FC968D0007; Fri, 22 Dec 2023 10:09:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45C7D8D0003; Fri, 22 Dec 2023 10:09:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D6F78D0007; Fri, 22 Dec 2023 10:09:03 -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 1E0B98D0003 for ; Fri, 22 Dec 2023 10:09:03 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D87B6A0EDA for ; Fri, 22 Dec 2023 15:09:02 +0000 (UTC) X-FDA: 81594786924.15.DDB27B2 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id 111581C0030 for ; Fri, 22 Dec 2023 15:09:00 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fsTEpZhG; spf=none (imf20.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257741; 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=nwSb0aQ6WVWAqtAF+HdyJ3HlPU1688MOnHDS98Pt7+A=; b=SHudDDpyUhT86lgOV11EO+tiqhVP/t4PiuSYPUhDbJ9G9LKqKcqLZrEMfZoAGyPTTgIJQu 1HBuga32oqJG3tzSv47mE9affnTHGeVQc2e3L5xCciqIh1ojCPaHxfABX+SYBFFzfmaAO4 4Ubj9ARFB85n5oI0g7lsH7sip2pyJUc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257741; a=rsa-sha256; cv=none; b=k8RIsebGQVLoWafvBGGWN0VPdA4XJk3wGMnaCcR8CzrBQ3TEcAlXJHK1snIp2R8N2M5zeS VzLitrD6uSZUcYNiSVS8zhOi+2V7x/LMwP34+QoA6Yrvo2Yf5uQmhBdd3z3qsYVwj7V7Ic oHJ8oPPz/jnxhTcVS2O328ygw0zeM+U= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fsTEpZhG; spf=none (imf20.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=nwSb0aQ6WVWAqtAF+HdyJ3HlPU1688MOnHDS98Pt7+A=; b=fsTEpZhGkE4khH8MXT4PtBYhdo ZQgp/dXeIGwyn7s3VuOqu6GmTRUxeSslau35ljaEbUfRgqA0ZEAH8JVNUJqryffLuZ1tiX++MxAHy Nq+T9gs+7AeBOpWiNijbKLhyOEzHiXCvYJyQBKAzyR6Jx96R9RLRtpKuVe/PAuijSu2MSVEHhsx60 po2QLtX1ruHagJovmBJr49HjCGb76ply2cGzBN7tNen/Y7LvzOWkGILqJzTcP2VcgfasfyxRa/YLB CMyztaZTGjFje4ZGqnH7q15JeaxPgTH5DZcug+qDAWvVZPH+wM4/3FoVMrbM3vDe1Jt7WqAsXg8ta 7O6j3/7A==; 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 1rGh91-006BYP-2j; Fri, 22 Dec 2023 15:09:00 +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, Jan Kara , Dave Chinner Subject: [PATCH 13/17] writeback: Move the folio_prepare_writeback loop out of write_cache_pages() Date: Fri, 22 Dec 2023 16:08:23 +0100 Message-Id: <20231222150827.1329938-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Stat-Signature: 53zpjeyaeo39eztt1pjx15cr1d8q6m6e X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 111581C0030 X-Rspam-User: X-HE-Tag: 1703257740-661106 X-HE-Meta: U2FsdGVkX18pKxll+CYcCYYaQD34y6lhjXjORrlgKVUYn1Aa2yjFBnkVyO4eHjWnuu2JmpKN3keGBq3b4dm8EHMJhEccvxGo5YlsWqVOXnnsa5SXG2qcavpdDwKxWyk8k6ciEgoxuNOf64X0Zi8mYJCkiSyU9yCT05lFEzDDe8e5PIn26sFvK8v1yifJbi3eiWw+KFkPbUc45xoqcn7JAod7ayeQF77Cglm4D199yIpmzZrz0LxSpj94txD/AgB/4848Nhe5jsduFe4n0e49b645+cnHe9ySiEf37F0mZW6FkCUGfVov8Q1Yh0KBa0f2HmOYlMh9CsT2JlqwCD5P8fQCIbtc+YrCoLdza1PbKXzY8bTLoX/HqxGyZi23OZGvm2Ju+j+WbTkKEZW6ZCMK5FHrHcT9tKgnxnWugyfCM3qVIRNGQwlwK69LgeULdkrxXutyio2A3zswtQ5ybgYtFqNY1DoZKqelWOcpTk8suLWoIRMHNJmnPljEyl+zMEDazSlTkC35gXy4WMAewzTLrg2Nzre+QIX/2pU9tS4OHcQUq0tQ2TUFf8Fs6q3iX/U7sP4lv/WddZs+FlHYprPdlUKZqZFErq+rH6ZHPqeQeD6UONIXQN/spBhyeMvL265c0e3FWkdJ5rzhOSmgK3gYjJV4/q1yQj73bh6PvNo1n3TMJbIwOSNlHkCLESzoy8psDB7PLG+V9meuzuHUebVSvSmGcROZOOf9GPY7Fd9qCDZbPja35WbCUBPIb3W6poBW3XbaAAwWniynhPTw87NLH8Rt7waHS8cJZxZ9OJCtj8z4G0hKPxP/bFj1YB79Al193NQcGlhbIhAla8MUe/+4Ldtuf8UzWHPIiDdBkwAiS5Te+MUyInxWz3FC1vYMPeL/gD+o7CAqwF1GRQ+tpembHH934cJIhW7O5WozDj3ubbYJ8zCV5Km5bFD/CCAMAMNTAuEfkOQX94uNNnNZNZS Fi1Ajkvo vkvpGQb1o26nEX548gQAJRC6oJp+83FheuQM4eHUnGaEkTWEpiJRfjXjkw1s+i8xiXcTb9Hqpzg+ttpdtkZUZvZpZrFWdxvpdFxsviaxYxAZ9vhcrmfXHLsjGcOJuBrNuGPYb81qKTrNjdLZWqG8/iQEX+fb1oh1uXGyR1tLBLXbZ5GzoDgtMLZFPIS8/qpiUniEXDKGC4o+TkCXNuhOuu6mPh9s39Ik/PPQiVTZzbXXvAiYGVMysdmCKmj6aRsi7C87NxK4OwR342eBGqJ1hyrSmISA3f3cK4LROYxSNlSjvrXYFBdq/uJFB36oFhMZ/mF263Fx0NFKI9XEIU0W91XnGdXM9mG8mMfAVBDh7YYH6OOS6mWYF0z81185XqK7QJfpFLtSbqzbORWL+zOxkk9VB+scqWFy5kaO11hfTPfuCWdClUF+STjwz5UaBjADfrV1E6U1afQnPcjPEQeqt54hwPcW4/BMHW59m0upjTXSpfKh708WeCXG+AQ6mGqdmkYIQdARF9prgtZPvvcJTpgLzoC1ykynrdX0d 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)" Move the loop for should-we-write-this-folio to writeback_get_folio. Signed-off-by: Matthew Wilcox (Oracle) [hch: folded the loop into the existing helper instead of a separate one as suggested by Jan Kara] Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f85145f330bb36..b6048c14748fdb 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2434,6 +2434,7 @@ static struct folio *writeback_get_folio(struct address_space *mapping, { struct folio *folio; +retry: folio = folio_batch_next(&wbc->fbatch); if (!folio) { folio_batch_release(&wbc->fbatch); @@ -2441,8 +2442,17 @@ static struct folio *writeback_get_folio(struct address_space *mapping, filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), wbc_to_tag(wbc), &wbc->fbatch); folio = folio_batch_next(&wbc->fbatch); + if (!folio) + return NULL; } + folio_lock(folio); + if (unlikely(!folio_prepare_writeback(mapping, wbc, folio))) { + folio_unlock(folio); + goto retry; + } + + trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); return folio; } @@ -2505,14 +2515,6 @@ int write_cache_pages(struct address_space *mapping, folio = writeback_get_folio(mapping, wbc)) { unsigned long nr; - folio_lock(folio); - if (!folio_prepare_writeback(mapping, wbc, folio)) { - folio_unlock(folio); - continue; - } - - trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); - error = writepage(folio, wbc, data); nr = folio_nr_pages(folio); wbc->nr_to_write -= nr; From patchwork Fri Dec 22 15:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503422 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 4ADFFC41535 for ; Fri, 22 Dec 2023 15:09:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EB4B8D0008; Fri, 22 Dec 2023 10:09:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34FE68D0003; Fri, 22 Dec 2023 10:09:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179518D0008; Fri, 22 Dec 2023 10:09:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 014DD8D0003 for ; Fri, 22 Dec 2023 10:09:05 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8F396A0EF8 for ; Fri, 22 Dec 2023 15:09:05 +0000 (UTC) X-FDA: 81594787050.04.91AEDF5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 74E07C000D for ; Fri, 22 Dec 2023 15:09:03 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AWYiSCNJ; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257743; 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=Tv6lrDU8r6rlJypjv3siMvmCkcJEVy83R0f8GQdaFQU=; b=bxd5TJJHCxI2vKZ4MPT20NhhMHUOGezYHNVKIP4LIntS77vPydJoAahf0Xxa+XVhGMjmCz 4q9yr5jkIrPNT/RcWKaDxhJSXopr8avQFYaLYuGbTTtLZ7BG4S+LrImkvtQs8jp+2UT+mX 9cfm3OMtJ61HOBfqs9UvovVRhq5tLjE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AWYiSCNJ; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257743; a=rsa-sha256; cv=none; b=QbTNWt3PXkQqfFadmbQEOWyu7MSGsMwmvqERF9O8V3/NWTcahZ7j2B1KmgyNPpGaS6sf21 kNKIhcwbpEudKizMKpLAj76/8LSKOjydyWZvG+CVcPXxiiNUP2mrGZl96oBkO9WniX+SUB 3uAwDu5yCJMHd65/6KZA8Agvx9KK9q8= 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=Tv6lrDU8r6rlJypjv3siMvmCkcJEVy83R0f8GQdaFQU=; b=AWYiSCNJg8Yta3tpcjdQxGvw8L EvtMV1WeGwuWEB3TDrAffKN606PP/uIZLFU9/YNjCbAsUCYX8zUs8FeKkHub/niKeumC6GIoUiMHL V5wS03sfVZpFQd3R6vLLzbnYXMdQ5flWog5xsVIBG7V1iQqbWzO6skZlSrvW99SHHaEq1syx4w6Zp pOE4tEWlS0mGLIzJM2aqnc2cQvrATlEUfezMuN3fXjE7sR4E1+AxcuS8zLKxfCDXjzD+2Va6AJVN2 M/Tr2UDGLXa9y5PiBU3MybJUd+9vUnG/JxzdSmwqBzjTnEyr7h1SKZh6iYs8RGLha4KiO2za/uX8E 6DqydyuQ==; 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 1rGh94-006BZF-0b; Fri, 22 Dec 2023 15:09:02 +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, Jan Kara , Dave Chinner Subject: [PATCH 14/17] writeback: Factor writeback_iter_next() out of write_cache_pages() Date: Fri, 22 Dec 2023 16:08:24 +0100 Message-Id: <20231222150827.1329938-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: 74E07C000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: tawuniferjt55efgxizxzqnd4wny8iem X-HE-Tag: 1703257743-631877 X-HE-Meta: U2FsdGVkX19B1e10ZWV5KubceV4aU3SN2fqeO73Q/751xzjkoxCSBKQJmlq7XAjIdMgy2Yc84d0WGLtLOdz9Av6b2AnMCsdkiwv/NSnO+tivJIK7T7CWQqoM8CfxyeDogTpRG5SSybpF9aceM6vE9HT/RU0iShFRCSQMyy6O/w004zySjalIu4rOxP3Z1Ci5FQGZVzzCGwNE/ZZh6sI80zGrJ359CXU2y+qF6pJsRjd+d3w9hoew/fUSUPYscgi+rsN7Y/LZSG6Xx2mKuPmWgCfcuLmOpIP1DGNg9Nkba3IVF5cr89HhVhLOlWoVWcEd+0xXzNX4pliDPij+xirUH1O8mS1o4IKOJ1/94ArzZaSAGg9XgvLKaPRUVyHmZr65FTH5JlPMf1fz0TD3Cu4E6BbsSWyAGh0+PKnVtt35bpNSzLBFLkn74w692y2Et7oqX147YVQwXRWncjBpqRRO66iOzv/2BfbCyMDkoAniImtIMRRYWJ0OTc92q3FaRjLo9oteeuvLQIE0vBaMykA/6dLWRAfHClW6OECGx/qucG7I0Y3QTa5w0aNH9wEkW8qfs8POCO1CyAcrK1ZN3w7+vFHGVvrfxW4/mlUn5P0UDx79LmtAcfkFB/sU+0jtMp9zyK5H31PuTWPSt1oDWVqYLtupj5nI8Wx9JasgETPMYxLgZlfONSknUZdf63qJNJMnohdiaepz+Leq9uo8Q5QAL3BhSzOl1P8y/zBug69UcwRb9WjviJRzTEoNxesBN/CsImv2/ZtK3flem0gAUJK/W1Hj0q/oq+It7aZnROaibzqfztwVBoOss6VVzxQU/7E/IPiMCYi346gg0S9mruYiDUKKbK5IVPVvYZl9YnYV73k3b2L+gvJO3oIZHiOYW1aLSbbc1romiTvA8vA7qddly2MC+5qONjykOt5PXAqOIStY6crGCI6fm0nYN9H0mkEftgpFfO4cjj+A2FsyfOT OGawg455 68tACCElZs9WwaTex/bFbSD2H8/OxmrW8l0s1gqAcqKzx02un4cun0Z976QmgS5q1Je7t4GM3R/tzLSicTcup9EL1tUsrux/qbHkGV4IPbLIaQ4NVe8i/ol5/0HY3Gcf5+yYc4hqCn0cNDPVteC3g585fgdzTGcavL6PP+d9VH0uz+DivxB5NksbJanMnYzxkimyeJD0CqmEdhySn3pUnLNB5KaRNnqmimVIZ2oCUDcA35m+kPu+d/bdmYMHI2OL7ZdCb74dbfiNIq8umzE9hgZoqLuKOzQX+3frg0jJuJT7Ayslccb0XxRtzTC9aMOX1Lcxf0yQ/ST2Jf178uRGeb5gLZLOd0gKR7xSnEGkc58XCRMoB70z2iQCxWHY1tpTwgZjOBF6L3jIoKashRjOpdvt1yghkjY8ZUmqdMDpm/0mUtzwRq9i8kSLzhgXPK5mdd25v/04RxIuM3NRiZhQK8O/4Hoyho+Y1o0+N8a76bKuf00Ou/Sge+aQL1vWygsPc0OljGqnhdEfZ/g09wwjPegUHar6RtgnSQm5k 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)" Pull the post-processing of the writepage_t callback into a separate function. That means changing writeback_get_next() to call writeback_finish() when we naturally run out of folios. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 85 ++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b6048c14748fdb..a041cc563762ae 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2442,8 +2442,10 @@ static struct folio *writeback_get_folio(struct address_space *mapping, filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), wbc_to_tag(wbc), &wbc->fbatch); folio = folio_batch_next(&wbc->fbatch); - if (!folio) + if (!folio) { + writeback_finish(mapping, wbc, 0); return NULL; + } } folio_lock(folio); @@ -2472,6 +2474,46 @@ static struct folio *writeback_iter_init(struct address_space *mapping, return writeback_get_folio(mapping, wbc); } +static struct folio *writeback_iter_next(struct address_space *mapping, + struct writeback_control *wbc, struct folio *folio, int error) +{ + unsigned long nr = folio_nr_pages(folio); + + wbc->nr_to_write -= nr; + + /* + * Handle the legacy AOP_WRITEPAGE_ACTIVATE magic return value. + * Eventually all instances should just unlock the folio themselves and + * return 0; + */ + if (error == AOP_WRITEPAGE_ACTIVATE) { + folio_unlock(folio); + error = 0; + } + + if (error && !wbc->err) + wbc->err = error; + + /* + * For integrity sync we have to keep going until we have written all + * the folios we tagged for writeback prior to entering the writeback + * loop, even if we run past wbc->nr_to_write or encounter errors. + * This is because the file system may still have state to clear for + * each folio. We'll eventually return the first error encountered. + * + * For background writeback just push done_index past this folio so that + * we can just restart where we left off and media errors won't choke + * writeout for the entire file. + */ + if (wbc->sync_mode == WB_SYNC_NONE && + (wbc->err || wbc->nr_to_write <= 0)) { + writeback_finish(mapping, wbc, folio->index + nr); + return NULL; + } + + return writeback_get_folio(mapping, wbc); +} + /** * write_cache_pages - walk the list of dirty pages of the given address space and write all of them. * @mapping: address space structure to write @@ -2512,47 +2554,10 @@ int write_cache_pages(struct address_space *mapping, for (folio = writeback_iter_init(mapping, wbc); folio; - folio = writeback_get_folio(mapping, wbc)) { - unsigned long nr; - + folio = writeback_iter_next(mapping, wbc, folio, error)) error = writepage(folio, wbc, data); - nr = folio_nr_pages(folio); - wbc->nr_to_write -= nr; - - /* - * Handle the legacy AOP_WRITEPAGE_ACTIVATE magic return value. - * Eventually all instances should just unlock the folio - * themselves and return 0; - */ - if (error == AOP_WRITEPAGE_ACTIVATE) { - folio_unlock(folio); - error = 0; - } - - if (error && !wbc->err) - wbc->err = error; - /* - * For integrity sync we have to keep going until we have - * written all the folios we tagged for writeback prior to - * entering this loop, even if we run past wbc->nr_to_write or - * encounter errors. This is because the file system may still - * have state to clear for each folio. We'll eventually return - * the first error encountered. - * - * For background writeback just push done_index past this folio - * so that we can just restart where we left off and media - * errors won't choke writeout for the entire file. - */ - if (wbc->sync_mode == WB_SYNC_NONE && - (wbc->err || wbc->nr_to_write <= 0)) { - writeback_finish(mapping, wbc, folio->index + nr); - return error; - } - } - - writeback_finish(mapping, wbc, 0); - return 0; + return wbc->err; } EXPORT_SYMBOL(write_cache_pages); From patchwork Fri Dec 22 15:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503423 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 96050C41535 for ; Fri, 22 Dec 2023 15:09:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08FF78D0009; Fri, 22 Dec 2023 10:09:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F32448D0003; Fri, 22 Dec 2023 10:09:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5EC48D0009; Fri, 22 Dec 2023 10:09:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C6B078D0003 for ; Fri, 22 Dec 2023 10:09:07 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 95FA4120998 for ; Fri, 22 Dec 2023 15:09:07 +0000 (UTC) X-FDA: 81594787134.06.416CAA0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id B544440019 for ; Fri, 22 Dec 2023 15:09:05 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QcpTyTJu; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257745; 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=Cpsd8l7OUn8C5bZQLGYGz9qCV/TqxduSbkyPfu2Mjvk=; b=I3gvaURniukuUV92pby/zsVlHM542T3uov18uefedYniDBi5CFTIZa93F7fRrVIlGLYz47 Rkabh+1QXawDRJq7B7tZNv42hrDMB63hKD0YTLHucA/2i/0swQIiNCQC5fpjD4Mx0WvwMG 56C8+KNoax/4f38lGgMceVeV86p22e4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QcpTyTJu; spf=none (imf17.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257745; a=rsa-sha256; cv=none; b=rul4/UI2D3CDxanu2zWICJ3rO79ZNWz352zkQi16Wl6vMqY6DUFZTy0wHXqy1BMpAxGL8S byiZLZWldu9Y6WU56nWuLCH6CFafB2s0R1difyswy4C7bXQoPQRGWcKjYx6ucm0G5AZcyz P+lmQI34tFbMP/keuXX/efcOI8+Zxzk= 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=Cpsd8l7OUn8C5bZQLGYGz9qCV/TqxduSbkyPfu2Mjvk=; b=QcpTyTJuJ95zy8zQxfBVMOoGDn sw2GJk7mt4gkoe22EcMVpN5zoyxcTZ73p+PdkX60CZgHZeUAuIUr2oVe8FRVmI8/vAcpKnpluXuEu TUUZxssJV21oSRM3MQ9FjEgkhDo2BKBvRLib0rucgP+qyhWCD0t6FBI8QvgXSiu3rZjMwYBrflf0M uoIruyUMiuNMWZXyPdg5PqtA3L2CzyA4EIAD0M+B5pGflz0iEsiuxw8YZ2tO6wp2UnPyPwLrtqOIi L2C1oIjxnOjwUKsQO/pO4H+bWqA1WGkCM7vItyfaVkeb+MtDYyqFpiRj3tcKyxP2vT3yQKv8ByTNA uje57PSw==; 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 1rGh96-006Bb2-1Z; Fri, 22 Dec 2023 15:09:04 +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, Jan Kara , Dave Chinner Subject: [PATCH 15/17] writeback: Add for_each_writeback_folio() Date: Fri, 22 Dec 2023 16:08:25 +0100 Message-Id: <20231222150827.1329938-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: B544440019 X-Rspam-User: X-Stat-Signature: oe5j3tnpdscgyhu94wfdfcz3haq38ja9 X-Rspamd-Server: rspam01 X-HE-Tag: 1703257745-554477 X-HE-Meta: U2FsdGVkX1/oYwS5O9TjhRqbBf42npixtOgASB+v6RpXJSMGtmtBiQB1y8BVf1UK4Z9eAB69gwExMYYPd/FxncILctyzrieb6CV1FPBMP4PKBGYB4nGqRkj2GFP1W1oNz4BKHvlPgQJTyGG3uspaYe5f4BWfnG0+PsKypmKsLGzOUKgVEMYqcN7waPuAVMVN/RpjJjJ+CPZtapFI7ieohiD/7v5j+QpUi1ndSx94+PS5DWznEfhziHtXE8oIXBhK27dNZw8rvx43tOOf2nNMBwwnT7V2eQjvtsXGgUWmMLFWde4bQPfqzxzC4OQi/nUOZWZs054URC+YQkKNpdX9ePXddFtOt/zsCr37Gm25aj6FKVO9plsXtD1a+aAz+s6U/gKwihjkRsAkhfvuxW1gPK+JQSsivFs5G/xZyL6aVENueMahbhSXh15n/NG6z5gixqcDZTcRhk1Zpi7O7wkFDjyv4JRHeYoEeNGPYwWIbdrX5O/JrNCJuaCG2xAG+oQA201/o1XdJU8h0rS7zienv7lRSEBFnyhSlbbX8iHRTUjKYsR+xbJowLxp+mBjVp15Q+hov2ttj3H5DtqQb8hh4w8jisrwBi1F3ZJnKjJ91CbiCTsl3MWSVAweq2MMZ4UsCp1eXEX+FVu0LH+IXqHvvGQQclJJ5lRe4vt67jwvKEPIsAtAd2n6y/hQhb3Ql6WW01K/qTF7zbEY3c5w5zBbZC255MDE3roWXFmMkFkCpo9MDStOkjhzrSz0wyf+2iFcO+ZRUs2oajiKND81g7NMLmDyXderGEGrewwf/UmlFbkxYxoW4fvBSP6bDtNKWdeaPM/XFJmClQycq1ObI3dEOg48K/Yvija3RkizHu8NW6R/Yjrs9K3UY8lZc4NgvPdDW1PjHeqHKJcgQRYnVjLgRgWW4pTKZLkqRzSm67+VBIw9j4h31+GkYxf9O93ztg4C9gwnofdquCQtbwJsZyv 6/TzmQWL L5YwIbKYVsuGv6hbVCMWr6RTWmejr2wo0hOL3cQSgEkwPbB++PVCpYwQy8K0iNUZTChfhkctsayADLuP97imAS3cTmKcLcyE9EuEqlSEuM1x9z78qeSBa5slFyjow7xDJMv5EQpv8OhLvL3XCXSFQO/v182AK2BOsEvBl+1sdSZsXPZ4eERstJ2y/evccauW1ncxuwMKQiHJjd8MoqPfcx0uuHh0/v3iC2utUpDF+RNMrtU7YKYP/Rxi8VEjUbN0UeneqfdXct3Z5sTKbHK/aTszKmwABL4scCxl+E39Oe9DPfab2HU6i62p5lTis/kU59QXJtjwOBIUyvVcIUU2L5HAeiNYD7SURfhhpkyph7mowzIFiwIX186BZPOYSQAYtLJCR1xwMWJmfYNFARP2cHkB8g5yiJlCWEg9vdpJDPaA3L4+Upnbd28KliK9WpRueJ2wh0TNx/m2D/B2bNz69KlJ2jgGyZb4Q7LhSSc0lv3YBZQzdwypUOGtTr5mokM954ikIhycemGXZOK0Wp/osfSEUTIrWDrA/U99S 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)" Wrap up the iterator with a nice bit of syntactic sugar. Now the caller doesn't need to know about wbc->err and can just return error, not knowing that the iterator took care of storing errors correctly. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Acked-by: Dave Chinner --- include/linux/writeback.h | 10 ++++++++++ mm/page-writeback.c | 8 +++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 195393981ccb5c..1c1a543070c17b 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -368,6 +368,16 @@ int balance_dirty_pages_ratelimited_flags(struct address_space *mapping, bool wb_over_bg_thresh(struct bdi_writeback *wb); +struct folio *writeback_iter_init(struct address_space *mapping, + struct writeback_control *wbc); +struct folio *writeback_iter_next(struct address_space *mapping, + struct writeback_control *wbc, struct folio *folio, int error); + +#define for_each_writeback_folio(mapping, wbc, folio, error) \ + for (folio = writeback_iter_init(mapping, wbc); \ + folio || ((error = wbc->err), false); \ + folio = writeback_iter_next(mapping, wbc, folio, error)) + typedef int (*writepage_t)(struct folio *folio, struct writeback_control *wbc, void *data); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index a041cc563762ae..5c33a4a527b3fa 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2458,7 +2458,7 @@ static struct folio *writeback_get_folio(struct address_space *mapping, return folio; } -static struct folio *writeback_iter_init(struct address_space *mapping, +struct folio *writeback_iter_init(struct address_space *mapping, struct writeback_control *wbc) { if (wbc->range_cyclic) @@ -2474,7 +2474,7 @@ static struct folio *writeback_iter_init(struct address_space *mapping, return writeback_get_folio(mapping, wbc); } -static struct folio *writeback_iter_next(struct address_space *mapping, +struct folio *writeback_iter_next(struct address_space *mapping, struct writeback_control *wbc, struct folio *folio, int error) { unsigned long nr = folio_nr_pages(folio); @@ -2552,9 +2552,7 @@ int write_cache_pages(struct address_space *mapping, struct folio *folio; int error; - for (folio = writeback_iter_init(mapping, wbc); - folio; - folio = writeback_iter_next(mapping, wbc, folio, error)) + for_each_writeback_folio(mapping, wbc, folio, error) error = writepage(folio, wbc, data); return wbc->err; From patchwork Fri Dec 22 15:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503424 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 8116DC41535 for ; Fri, 22 Dec 2023 15:09:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34DCF8D000A; Fri, 22 Dec 2023 10:09:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D6AC8D0003; Fri, 22 Dec 2023 10:09:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 179FC8D000A; Fri, 22 Dec 2023 10:09:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 01FC08D0003 for ; Fri, 22 Dec 2023 10:09:10 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CF25440980 for ; Fri, 22 Dec 2023 15:09:09 +0000 (UTC) X-FDA: 81594787218.02.3F2AB6B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 2393F14002A for ; Fri, 22 Dec 2023 15:09:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fr1wzmpg; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257748; a=rsa-sha256; cv=none; b=vZeb2p8XHtD+kNs7sJFAPZiwbLXeFnZXpECNJyYln6uB0FzZjlMS2T/lJ4j87nVXwBYP1r llp88zHvvHVyZIXpD2pfvOpNyvL5E44ZujacEPG/450eOac5ACI8BisyEf+doJHeyi0gct /+5qi4hBdiGHPInH+q1B46O+wgBwGhY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=fr1wzmpg; spf=none (imf26.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703257748; 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=lixDX8ZESJjee4RWhykT/1y+dKD2DSRjw7efEsZauMY=; b=zmjD5ZgDxly0KijjI4UNGrtkLsBjP94av7lQGBVYqGYCS7CJ3DDvBz33RQd1Yyn3ZUE0NO Rhh0vH9RO4Or3led3lA5OltnCPkqZFugJ5B//e7VlCx3DYKIoAQpl1SuHfJuLC587quvuD JxyJTZgPwiuDJg7IgfrPLyogHyn1nDk= 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=lixDX8ZESJjee4RWhykT/1y+dKD2DSRjw7efEsZauMY=; b=fr1wzmpg3g1yRFa0Y9DqGv06Wk cfDoK78nyVATk2W00QiKsY/vi82udAF0M2pyy+Ay93XVwZPJE4qz+MVWOhvOnuXDUpB2cDR0YviWU pEa0p7C4tjXfPes+OGICWcueTOsQ06AIm0+bbjDoBE1CB0mmoXrZbVxR+vklmsbA8hsDQKSvi1pEy 26uOQbqYl11Ollia+yPhtCKAS7dsKtR+F/IMr9+yAhj597hdQxeg68obkW8aguZaJl/ZMU2OFxJjc N10rjpNyBKRSURZsWSof2IhpBNqPx+qHoW6tbAa3Vig8tLlTZDipLRaHFw1jenO2m6NAKArNjk9Ba 8eg37u/A==; 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 1rGh98-006Bcf-2W; Fri, 22 Dec 2023 15:09:07 +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, Jan Kara , Dave Chinner Subject: [PATCH 16/17] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Fri, 22 Dec 2023 16:08:26 +0100 Message-Id: <20231222150827.1329938-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2393F14002A X-Stat-Signature: 646in3wu336riq3tsobt37q8kpj5igst X-Rspam-User: X-HE-Tag: 1703257747-863537 X-HE-Meta: U2FsdGVkX1/4c0jLv4XaqsL2+zyI0lxLXqXUlY5wHpdkLTKZOzaGry+sK+1K8r9/rSk75LHaWfOy/6Ni+e74A8rHNKboqAN4W3/8v4Jh/q72S19RO1f1NFja1bNfwt3y1tafjbr1YYN3DHVVM8Zzn39ROqt8DyWEBuHbyH7edniL+JxecNDBv1oSodk5y8znVsdDIuLaNKw7xHiwasm4gGn/fLhmPSdcFLeZ2fCt3xKx6CFgKQOcw8uxX4wwB2lOWLfQKtRoIm+nDXgt8trgpRpHc8s5KB4otVFo0LZEYomOH4DpjQnjJnOaRFdlKsr5ViDXfz/Ksu5gDywaNYONKu17TA0Z0mKC+1V2oyRQXuIupn/m5kT9oHtv7Rt+xoY8G/KUkbWXtJINEjoIiAGGN/4B7HbESdcX486HFfL7qxyuIUI1woPgfz5Rqa90upfKl7fRrOT04yvIUqyIA1r9gRQyKGE74Mvhzu2y/iLiJROFAIWJqZpvPbcPXguKhMDOxpRxLSsW6pmvrEAWSXrIIYz4akkaynDBNRjfXlHU0ebRi0lsu1hq2AhYuQ6wsAwF054Fcb5L777M+MSxpyH0ZNCp8q5hULXhMFqTBSU5DLnAsLFPsCWlfMisbegfvWqjIRSqJyB116yYpdl5fEvkYA3LNqgsFar4PfYFb5cGtdjbZdzDNqiuo1ViiPmuftOWTIgtCLQcyOucMQbGaJoKPqccNjHDiiX1SsIQo0RWhrQdqgY7xtnoT27A+PyTz90q6TgX1f3VVhVYrbMBKtQOOeG9RX+B24yG+Epld1Ds7hnBPBOthmwTgdz9bECDSNJRqT4BAQpmuVqvViL09SbPhiKsVX5LowsW6/JToSdxYtE2uKnBgZsKDOgIb6wfQk0v6T8U5eUf7kb0CYGfIfSh2JPWWXn90l+DO6TiXbC/2/oXSRnLqS+7jbdsh1A20I2hHzS2zkQIkNYjnau0sSL B/+AqrXT 4GRX0Bu8+mR0NjGTxndBrC5rIfkaYJdI2334ZMkL0nPX+IKJRyHi2DB2egew0JFHn8yWOIli+Bps29w1mWzs9H3z0X95oHjzIZIwrweaQvmD0NGo8h1GXnlRm1ljDAIkqDGuV7Ku4Ll+3XtsK81hLYx0iznRemB6wlnHHN/PPcQABbgVo2R0+ZhNqGCM1c3VtLIz/gBDaet2wSnW5Vjwo0jeCy0KnQ3SlUPmyk/KN2Vqkqi99wNmWKqE8F8Py+LMSzjs/8irWwFpGkCkHWn1eU/HFIPa1poe2fH/ae+/fymMBfNES0xj5sV8bReC94X/sqeopzVW+K1a3rEQmAe3BB4BqxkGo7L6iB3kEkXgfieFhBOI8BDNx4BtbWkvWIc6zDRfWz9/i5O6QsuNIVdaSdAGI5i0UWmQZd9l/DvVwGELz46Jm0wQIoXzEJQ7b/nO6nKura9aNsKFrysy0jUwSlHQbpdRqdm01r/XMYX+tbsF2LCdBZSi8BAuLOUSJN8RYDvj0ZWe35Q4IDZLN505AAhk5uFFGSrDGc+jX 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 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 Acked-by: Dave Chinner --- 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 5c33a4a527b3fa..1ff444d5e4317a 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2559,13 +2559,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) @@ -2581,12 +2589,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; From patchwork Fri Dec 22 15:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13503425 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 50A2FC46CD2 for ; Fri, 22 Dec 2023 15:09:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C511D8D000B; Fri, 22 Dec 2023 10:09:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B65DE8D0003; Fri, 22 Dec 2023 10:09:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91A6D8D000B; Fri, 22 Dec 2023 10:09:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 810278D0003 for ; Fri, 22 Dec 2023 10:09:12 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5845D160E88 for ; Fri, 22 Dec 2023 15:09:12 +0000 (UTC) X-FDA: 81594787344.24.A0AF759 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id B3689140022 for ; Fri, 22 Dec 2023 15:09:10 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=EwhMMlXL; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+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=1703257750; 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=vSRtoBhWiymkrUriREDGEOquZtVYvqi7wp6gqOzPpq0=; b=lEwu2tjiJxWY9Um8eInYX+AYMntRVboHSVDGPORp+CY4vaKgRkLKh157KKJQmXrm7MR/XL cJ3a9Pg7UhxUmPUGsZPaDsqdYsDAM8dr6f64jyqckVcb8rYspYdj+zHe/v0/nxsTGyDon3 awPB2/VXKvl8v+kNhhkxJKIQhu+Dqhs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=EwhMMlXL; dmarc=none; spf=none (imf09.hostedemail.com: domain of BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+af923ccb694ecd533eae+7425+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703257750; a=rsa-sha256; cv=none; b=AodNSPgJcy874ExmwhHsu7YoOowYSLwmuZTfjblUd9p8yW6vxmo4DuN/4fDTbgKjHSXj43 F7iItc5+ySiB10Nqd0tSkY+5jFjp4Z/o/+oU7F6PNURsXE4cjzOdiBAMclCg6G9gbYnjGy PM/UmEy0fxW1JYj6gX3GKaRYSx8XndU= 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=vSRtoBhWiymkrUriREDGEOquZtVYvqi7wp6gqOzPpq0=; b=EwhMMlXLFZbb/tlh1Ap0vPdrcR QeXKb5dVMvla5R8BdZFAmfwJTIijr0Gqh4grvfBE2kVQ74iY2pchwGk1U6PBfvQLlseP3Joxij14M f6DDtw8jvufT1eQ0dD6EnwdEEfmngoOSFwXb3tcNOHge1rxqDek23e1IBIgaxlzAOjCOrrDyZ1Pm9 6bpZHxF0yNGAKL1BWEHRC7Ee16sHdUCn73JAe5XO5P7gvg/24bmDnR1HUJ/8m8hxdxp+ALaoGDdjh CrJ0gy89UfK4aZ28Lih1VvI2b3nUn8Yje//rK3yG35lU++vIYwhUFSmTiW8uFt5D70kn6sI9l1clv MGfNkVlA==; 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 1rGh9B-006Bdj-10; Fri, 22 Dec 2023 15:09:09 +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, Dave Chinner , Jan Kara Subject: [PATCH 17/17] writeback: update the kerneldoc comment for tag_pages_for_writeback Date: Fri, 22 Dec 2023 16:08:27 +0100 Message-Id: <20231222150827.1329938-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231222150827.1329938-1-hch@lst.de> References: <20231222150827.1329938-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-Rspamd-Queue-Id: B3689140022 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bkg6usxo4u71py5jiritybn78qm33h8p X-HE-Tag: 1703257750-77579 X-HE-Meta: U2FsdGVkX1/Wu3y+vCp9lLiHZWD0BKvzRXqBGDNeP9Z8cWPXy2xvxQ/M4aotyMgOTWcfQh7w5sHfTwjmqz5lbP7Fc78ptRKWSxiRAgXQBtD+D7ur/tpAFr1x2excISU8eHA1MPNdxeylfxaxFfMxzHGtY1VMLwFW3C2S/AOt9u9Icu70GnJAJ+G/fbezrFqH1Y2bmne1LVJjbbnFyxsg9IlitZetZRlaVdfqqevRDaUO5ow2tUFHLOYBZX8VwuzxTmdT670N4PvUqytjyT564Fb+eCz6Vn6TvQx6E/zf/6De3lFo+eki/RBOJPL7ZjsQwmorDQhIPW7E3Z/AlTu2wFz6FESINl9juMHMogdhTOWvX41EYR4RiAM8r8r53sEeh3HQCWmbMuJjjvfBPHVdRSBcmNZ+vQg1bKRLrx9BtvDfnDEqTtHucz+dnwbnISW/PKrCJ2ICglVtTja7hvCPCUSB5DzNM3MH2VAOWkwqhRq69ClqNnUmXREn4RqW5O8Ovf1daFOFJi6XAfMAsmxjK93u00EAPJmOqGdlz7gRWMEhNPwZnBGpzNXFQxpmzyQ+9Gqov9X20rvx9+g/yFY/FLb+BE/ljFl1T1rRufW35JZjCku43KLZDshSEj5bFFyfBIfotDF09jmI/r6E6N77Ajc1MXRNjMQW29Km4DqnPoe6iqO/ss/bja98e5kGhV3rGiZyAT7pf5zPRQXx/1KRcQB4a2Diw1OYycLzByjIHz8JWql++a7XMAl5DKN1C+LlwC8R09x5F0PC8sagnSYHAvwnv7n+yJuHiiRfpo7kaSgBb/nnRAXejS1NFNDpyjQj3cLnUmCe6NSCruYjO49uSd7xX6suhczKh18MxcYQXUvibSBIigIpW2jN72jem/kDwBgN7UA8y6j0IIL395QtWdsXlt4xHS1GepDQ4yb3CIVJQU5E8UQGKUssMIC+tGGTeAwAcNM7GJJElOxttJa dctAeLlM azR3SK3EuxcaLSUeQocvCsMpSQAufKj63BdsC5LI7lLetHeF+SHY2HKjEqjWbJ8s0Dc0aDeDUJjOGD/nOE6EQTjtjHcL5NacWg7GQAe2AjDe0+1BKOHrXaYWPkerY/FHM+RRZl4Y2HyomtIMxlS9Q9X56mEu6uin5WoajAScDHRSyNpmItOkSaFnpXY2+yeUwWwv6HSkWpVROHVqpyWGmO3fHWA== 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: Don't refer to write_cache_pages, which now is just a wrapper for the writeback iterator. Signed-off-by: Christoph Hellwig Acked-by: Dave Chinner Reviewed-by: Jan Kara --- mm/page-writeback.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 1ff444d5e4317a..0546741856d70d 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2325,18 +2325,18 @@ void __init page_writeback_init(void) } /** - * tag_pages_for_writeback - tag pages to be written by write_cache_pages + * tag_pages_for_writeback - tag pages to be written by writeback * @mapping: address space structure to write * @start: starting page index * @end: ending page index (inclusive) * * This function scans the page range from @start to @end (inclusive) and tags - * all pages that have DIRTY tag set with a special TOWRITE tag. The idea is - * that write_cache_pages (or whoever calls this function) will then use - * TOWRITE tag to identify pages eligible for writeback. This mechanism is - * used to avoid livelocking of writeback by a process steadily creating new - * dirty pages in the file (thus it is important for this function to be quick - * so that it can tag pages faster than a dirtying process can create them). + * all pages that have DIRTY tag set with a special TOWRITE tag. The caller + * can then use the TOWRITE tag to identify pages eligible for writeback. + * This mechanism is used to avoid livelocking of writeback by a process + * steadily creating new dirty pages in the file (thus it is important for this + * function to be quick so that it can tag pages faster than a dirtying process + * can create them). */ void tag_pages_for_writeback(struct address_space *mapping, pgoff_t start, pgoff_t end)