From patchwork Mon Dec 18 15:35:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497155 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 EDE05C46CD2 for ; Mon, 18 Dec 2023 15:36:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F92D8D0001; Mon, 18 Dec 2023 10:36:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A90D8D0009; Mon, 18 Dec 2023 10:36:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1993D8D0001; Mon, 18 Dec 2023 10:36:01 -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 06E048D0009 for ; Mon, 18 Dec 2023 10:36:01 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CCCE012071C for ; Mon, 18 Dec 2023 15:36:00 +0000 (UTC) X-FDA: 81580339680.24.40D0D58 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 7323D4000C for ; Mon, 18 Dec 2023 15:35:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="ef/z6OGi"; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913758; 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=fOpePqIlVODGcmo3HFeeBH3g3RORLTSl2mjzxWXksuo=; b=qvc1SFXeu8yZakZ2JTPsJfDl5hRFFGOwQDRHE/MYYIBpktIflVi8D0B3CfsJN9RHHhfV76 WtAPQrLKG+cKFYR3RTrNW+adkwRpcED6p9Vo1FySwVb+KDZvc7brsARHjdDRjRLZTo8+5r REUcs5xf/TyD1eCejsWyguqL8gmWcIc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="ef/z6OGi"; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913758; a=rsa-sha256; cv=none; b=JJp/zVYhYUIRGz6o5H9jIfaj5uUaaJOqWMFV2bIB+BukDJTHjLPf6wn3APZDWTXJK7Dw26 MoFsuKhmop3F5H8Vs2cBLifx8dfzfjpI13a36OeZRvP02fycz6GEO332r7f6QEQRESzlBd sZIqbAzyJhvqlPRxbeyGVQ4olzuYxAQ= 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=fOpePqIlVODGcmo3HFeeBH3g3RORLTSl2mjzxWXksuo=; b=ef/z6OGiym6VMWNndQHzrgSssf EBETFKYXoYJJtNq1C9mH3HuQTgUYIICMzdd+RJk8f+bqPeZKgzvB9r5denj/kjl/6Rx1laQB+QPKl DO3ufG2jER5Chm9x/qyjOt395t6P9gk68QkXovUQH5R59J5O3aMBsHkdqZnw8EXlo+8WSOXh2CyCo mGbZti/G13+GR2IhJD4QsOC5HvnTbrBUPuDxuY/KTbu8mGypWYmtg04XB2h+fqEHuLSDGv7gKBIqB miSSHI1Dm4Q6uZ/1EpT8SkEKNlarqS5kEziIicr0rCyU/RxykqvJqeHnylZgKnTxUOQqQ9FAasDJQ 4J/FaIDg==; 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 1rFFev-00BEH0-0h; Mon, 18 Dec 2023 15:35: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 Subject: [PATCH 01/17] writeback: fix done_index when hitting the wbc->nr_to_write Date: Mon, 18 Dec 2023 16:35:37 +0100 Message-Id: <20231218153553.807799-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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-Stat-Signature: 49gdjnh9bbafeawgmhpw54cu7f3ecqej X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7323D4000C X-HE-Tag: 1702913758-498268 X-HE-Meta: U2FsdGVkX191sKgDBksVTnyfU0ymSchtme1F04S9L1Ntfo+J21kEoAZXZOZEdkYiU8qgatvt9/tdc6S2LMXacMzUtnkhSFaskHaybzb+URQ1iK9/wdurFbe2fkrUKZrgftwEJcl81Bn6c39WiR3E2oAdmFe9iqXHSNJNVv6xYnyGM+AfS4QB9DqP8L5BgPSfYoj1tnGwLtnyD5UOJV23FVjZf7qNnLNHkkYuJQP4oxGj175Bw+lpruGD7FAYIOgZlflMdYWTlVSU8K8tYu/xkmZV1BEZlqvrGWzU3Ch/qhenT5Yt4mL6DDtelcszhomNVm93znOK9kVtoZVkuqIK7D6Se3KC0g51hDiVnEWTuRGoKbm3lab7xs3EzOi5tZlHiw6NPjePKtDhoOOYF3fcfmUDxYcixxYw8z8bBZM5M1MMV1HWDTMK71RJ6S+1x5017RXcBoCQn9NkvkCMvrKAOhdc9lNJgYfevdAyz0Nlb2gVUM8XVMlHzBr/CXxLfpkI3P0m1SiqmSE7H7y+iT88y3ZoyeBaplrbh5MofrMJp++PfYwwW0I4RT6pf/3TKLvCrs5DbXjFL376hQiqeUfeXN6/5YdShUOXCVjyZbOrbapvvFLvkagwlchBS1XyX9CJx+iVrZZ1TH7TzvXMdOgfiXp3RzamipcoYyk40gYEb7ynjMV1VI68g5p5AodPfDoNXObBsMTWuyWpbTWjG2mMrlp/8meVx3/67prgs1d8bFw7U+FOsXQQ+ZcwCIDlhDXua/xsGBiH/dkZz47mzgiu61s9BIg/0WsluSoQ3PHBOUeDuoeA2lhjCgRMSvsY1mBjwjh2FPRF41Bgvi5RpAAh5b5QO3BLodui2DV6CjXzpbTR+PrZDo4Of9mZ/i/3agijiT9tw+kdjDGvTXx9A26+HggmXnpSKwnw5IcTuK9G4MhFL+LW/2bfvqb83NsF++jchTu9AWb+VUxF4B1L1KX NqgPnrCm kel/cPfPec55o6WSq0z5Smb3EQDytVnNozRTtO//x7cYb95xsqnUjNakNkxQmdUqigOxrfkjUvM2nO8CWFzSXbLMPzI4Vn2ftKNBizGeRkBic+ASqVbmGxf9gFXClrpgUkp8RJOHVGQ3L7z2Xf6Bq4zDQYK5LsooNWj73LTTTAgh+wuGlZmA9f49lfaZZRXCnxr+89IBEB1VqU5VZQUpl+ASfOtK8fVNFq7sYnRF5/dkhdD8iMCLc2hcG+qA7hidv7XZ7wlujPBXavaCxwDI5oxMDMHxHTIEHlcfFaHg5O5DaUNj76SXBHydcARE0oqS/BcMHm+hvb7kiA+1BVfofMdJI23Zlike34mzFlnCe2l3GTObonhxtQIVOFQmWzKLDUoTQMAORydU++RhYNNBvKKTxt5ByE7Mstr/o4OJc9flJpO/7asKLEutgSrnWuOd6dkSvgK4ZO9K1UqYWhRfOH+h/WAGPdzgtXcvkyIR2V/rOdaM= 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_inde 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 --- 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 Mon Dec 18 15:35:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497156 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 469DDC46CD2 for ; Mon, 18 Dec 2023 15:36:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56CE46B0085; Mon, 18 Dec 2023 10:36:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 458836B008C; Mon, 18 Dec 2023 10:36:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 236996B0095; Mon, 18 Dec 2023 10:36:04 -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 1424D6B0085 for ; Mon, 18 Dec 2023 10:36:04 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 98566140224 for ; Mon, 18 Dec 2023 15:36:03 +0000 (UTC) X-FDA: 81580339806.17.BCA348C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id E8F2040018 for ; Mon, 18 Dec 2023 15:36:01 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3ZpRbR4d; spf=none (imf04.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913762; 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=7163FLdiULRyCtlx5MbrRVNBpAWhlO7V2EZv7W3gfys=; b=fb6q5MG3YLjATD56uWNN5UcIMV4z6CdDi2sJaozzIInna4pMPAYUCKEV982XzO8csn5TvC BbgK4Io9rW1DlTiboouS9zbZ1zWpWx9H3EpswqCvQPTKhnMiWxF/E5ebmRLK2WOE1Pl+4j IMmCTr2lfMsL2pVbkaI8Xn1uC03DcLo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3ZpRbR4d; spf=none (imf04.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913762; a=rsa-sha256; cv=none; b=pZKRx5cR4Cw0ENuWj9oda+ueKyKXQ3FOIPGFQeypn+dI1u7JqIhNyHPJajt7d7JcdXU1Zz 39dXJX7eCzqvTULDuA9SWwpT2Z5r9jkWVoe2Suakr4qZm8uOEq9enGtv1rmnUoc01BFavZ 5E44Pij/tQZ+1sm+iPJ/IbGLrws+OAI= 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=7163FLdiULRyCtlx5MbrRVNBpAWhlO7V2EZv7W3gfys=; b=3ZpRbR4dzIQW6XHwppDqZ0VacY /+zRsMPUMvnF7Sy5qNbH115aR7DDOQvaHRu710B91NeXzplfp3qTlgw7xfv0KrcyWORdshwnkkTmA wBgJWLmbwKN5wKEgBZ0dNa1dWgFi/CFzWBohlP/g028rqSTZvYH+R18Xwim7yG1K7ATbdoWKJVTTk eYplI3MAGnKoB0nLg8K150hBAhpd9H2ehkExYxakdZNWBLN5nTWldq39fKlzTGSPHfUsFl47/nG4W Kb5D26H9trc75XVfWUbmdH/gddMp2u//JG6HZRNz6kFm7Mt3YMVvl1fA/LFDPemXhHP/apthEfVde SioTXypQ==; 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 1rFFex-00BEI3-2w; Mon, 18 Dec 2023 15:36: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 Subject: [PATCH 02/17] writeback: also update wbc->nr_to_write on writeback failure Date: Mon, 18 Dec 2023 16:35:38 +0100 Message-Id: <20231218153553.807799-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: E8F2040018 X-Rspam-User: X-Stat-Signature: epd9enxp44asdc6wia5czgjz1ungbzyq X-Rspamd-Server: rspam01 X-HE-Tag: 1702913761-795583 X-HE-Meta: U2FsdGVkX18E4Y1ysAG2+NR77jQbdqXyrqT1YBC30f+ODR9OZXW1dtz4qkIiFXtIBcUgipm9xnGwtbiEWkNmphvFd+Eq40gXjW+bezA68bpuoc/Mh/TPA+v7f/RnaP5MrpMwziVdJfG+c1Fn/uDCMfehP4gEOcotFpXjmsAtt+ghgLpo72Y4vCwhwBCgWIE7SUHI1TY+cwOFmJAV2MeB0xLLosz0/RG8s+viWmjUqXVhepOC71byYmc92RniKlVLal49nuv0KdOPNxiy7thmkMKU8KZu9NYRxA30hkzsounRKgf6T5JcVsoeh12ZfOtDFlg289CIp54xoI+34ZRa1NXL9tkE4qkM1mAGoqxqa0QARKW2W03zXkvmQhYHVZ3hpBKqEHSmXxcX9xau+gpSTAtNTf9fu2mVomtm7IlV3ReCKCx7aat7ldyUvsABLJY3Cov6UfVayr3ZtU76KUckypnQ1tXU9qgTMef7kvXUKW/aOIuxhtJvA2AiW+aUb3CH/16UslQDwp/UyLjmiBUKJVt2b1HZN/iZYnTA0u1qKkqIv3zFHyfD/QYeh4iOqX4QSKGW3UbSt/XSMxlzVHG1uU5EXarYircAKKyg9yLflt9ArBj/07d/8NVtEU78vKaxhJPokB9QcEhS2DGjojCy2U+0ib8grCNd0zuh7N6fse5uJR0lhfgZUU4Nx0zIkGIbAcFHz2CuhqiuN7KY6yGCHBZ/qHqbUJb9+NjiOcxMsZ1NryyAoOUNa+mU8ov+942UPOamEMNKnEEb4ALSTqOUFX4ijDlBok79a4OtKmiS1vSM0gRjzwj2LP8z7pbUHeioWV46hG7j6BDpcYxGwodIX4gTTbyLgXEFqSVZLirWS2BNwPFZIEYVfKG/B/lvGjzNoU3HmUKiw7ruzdr8us2dJu7WJRxPfntxuJJ5DG5lh1OwImoLYwHGx73ovN/WlO4AYqqRTQUne3h296gzRwS mSBppCbk alyFrBi+FfVCMPFHE3SBH3+TwftyUZEVUV8Ta0U23YqMpgGwcCkLPgCMnQAONcD9nWLFhYJnHUQqy8CjWnLNpQAwJP7ImsRw2Y5emNxUq0gl6SxTgkrvq0yPR+NDjGp7wHeySWSCXmngghS20PGb7Coq0kK9kqrK+VCUip9dx23aR3JbJVzbPZILHcHEynK+X574kknaQq4Rf2CTLJcOX8XChUe85GNYrkyjIzKVSoXc6aa+lsa2iu0lo0wjBUDME6Y5wgxnYozuOtaAIBQaitt7B5QsLLCPMpTxospaH0YC9/dSTln6laF/Ug1yD9BOtCxo9HjjvWWQAB0vzqHZ90uXzIjeGilzQ8Q+ySW9utvJrOWHA4/gv4PdRbYrtJ/N/muRgZX20hNU/tnATibaTScsDSLoS4oXdYcT3gNw2om8Y6wxEOUGFWY2PAovbs6tfaoQ4auSQTjF+ilI= 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 simply the code, so do it. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- 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 Mon Dec 18 15:35:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497157 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 D5D23C35274 for ; Mon, 18 Dec 2023 15:36:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 658828D000A; Mon, 18 Dec 2023 10:36:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6053C8D0009; Mon, 18 Dec 2023 10:36:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45A448D000A; Mon, 18 Dec 2023 10:36:07 -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 2BA5F8D0009 for ; Mon, 18 Dec 2023 10:36:07 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0BCF61A0139 for ; Mon, 18 Dec 2023 15:36:07 +0000 (UTC) X-FDA: 81580339974.14.F21C0B2 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id B26AC40019 for ; Mon, 18 Dec 2023 15:36:04 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wv7lyBIR; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913764; a=rsa-sha256; cv=none; b=thmSkkjexpxnYu7rsicit2sE0rsPQthEGu/OvPYeZ22Mz5NwC94/zFBLr9hfca0fseHec7 Sn0Jnwe0IR8PKtYZ0BC92UXEPjKxNTSUsp+6SqgDAd1RZj2cNFudB4LJxkNC9UxIRIYkFc pnUo876iZB+ICKQUqGXKjpcd6+gW5Bg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wv7lyBIR; dmarc=none; spf=none (imf01.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913764; 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=SkcRys0g0eAUf8/FxArC7DdEKspx8sFQujh+FCrTtN4=; b=aZcwNs239qIXwJrbua1JgdcPAEkOHyMIPH5yPVq1OHREOoNqYw8XPhcscNL09xq70Pv1Q2 I7YqGotnBhw3XQcSb8vVrSDVrtHiU03UoQN0N2pzB+teb1s0/YvErMfQp2ixMeAHHpGOg8 P1JFMwUC4vmatkcjc5UEVJc9KEqBdec= 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=SkcRys0g0eAUf8/FxArC7DdEKspx8sFQujh+FCrTtN4=; b=wv7lyBIRNIQLwC91K/1xIPUpmW 14UXm/U10zKWL8yi3CuNad4Wvj16dy3mlQm0OVgg9NbwoDwc9qHaPbHXu2UjDhtjk2lWCXoBQfv5y YEpJvvDmZco1oWzVjD3D1Bgi4x8XaNM+D43GKOOpJzTHkDmAlPg/KuQswq8wrsi4bfjwuTjO/hdvm dUdZUwx4kWJO8dxO3K/HNOHsO1nztgCOjXKRGJ3UzIgnl6x1j4KIzYPFncrhFFqH64N2gYSfK/F7I wirO6bPgiOsKjEkwmyDnPYkuODr8U12dz5uP43SplWoRAOxukXhfL16C6CpPgTpzEr6QuMYcez9D6 2LhabeBQ==; 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 1rFFf1-00BEIj-0m; Mon, 18 Dec 2023 15:36:03 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/17] writeback: rework the loop termination condition in write_cache_pages Date: Mon, 18 Dec 2023 16:35:39 +0100 Message-Id: <20231218153553.807799-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: B26AC40019 X-Stat-Signature: sft9x66sq6mrcm39ruumsx7kmamhzqag X-HE-Tag: 1702913764-294854 X-HE-Meta: U2FsdGVkX1/CbNusdsNh5LB05go+MjQzU/qgm8wtZDZQZABX7/Au77kEfyPo+C9CqVuR1eWIftA4h9aY95LLa6s5uIVuAwP+bBV9Qv7N9S/oXdSbRW3CYBcF7r6RT+G9lQuAJokYKMA0DvQjFHOW1soddKvQRNR/QTh5BVivyOvLW5oqrmtwVdiS1pM4jMNI4u/SpNPWzGFH+d8qcVdBiNPuwhcTOBeHVNBTlPVrmMUB0TaJeEj3Rvo9ak9dktA8YxayXsjgMwwh/saQCAOY0nqQkzhKSdg7WKO+HXqvqdL5JH0uNVymtfYOFGtz2gqpofBVoOhX9F73BV/Mj8vcozl+MXbIJZFzgxSNIsFC/xA3xpwt4fOZ+9hXgzuuP+VA2njNsalVgmpwR1cHbFN09sPc7N7px0lKDFXAartH4gNTUisCZmd/Zry9ygESa8wCkm6dWAuS/ZA4KD9M9sHhJHLQ2R7WSBbURSVT+EMWWgsaokhS5/Q3lPYYnpzjOP1vyEnS3vdMlOkCbUK0b7XxRZe4hndGg+cfaqqbIscaTLc5pXGLzr/S+RXVD17TbhitXbYnM0jcrrk/Y6aNZjb/0eBwDKEGd0b+bggThooLFmeg0qVTvMCpxfS5gGj+TP5aoZhXM41IS/NQczU6+x0whqglPqd8edCQNt6VL9M+IE8gparQLxpgODdlWL8IkyDDAAbnuN0K+dxV8dw3ez2+QyII2hGky+2U+S/wxXtM05LhP5HJPmlTu58jodxAAqe24llyZGsnHfa3+sA3gVHqQJDm1M8uUa1rOpWBOArhqX0r+cUvQud+HXnh4qrVWQ1+jBNqcObqw44ilxWPgizSNHFTyC3epaLcxwAgnPph1xZATR98+Yo4zFkNrII3YRHUJnczbJCyoL5Of4LQ+0O+3ZoAA1SPiK1AP5uWh1tGybDyrp1jW3O77dFUTdTzPkozfE2WWtISOtl/f/pBxCI mg0Q4DyQ H88T+16nYe+u1uDzBCxMgcCHeFt/gYJoayCrAGrhNP3P/SA/2kdU/l0BtnA4ZljmmmjIiIvgvlKW6W8N2dBk2ubYoA42KzRC2w+RosigEXPjXD568UUcQ3diMIqHABABTqJ6Jh7PkPj6VHFQKHeg102VpBzDPCKfReMfsMTBBYd8f8MepLc+I0GTOvQYtn4SU8M+o2twPnjfBjXPx7HaJvysU1ZM+rLbWiC2HvLaC/XSluYeaWR83CFI22blCcvTXYJRetsFYyoy6O9PH4L5CT++jpaxAWja5GooB2/l7CKJx4kdU2uru9/e9Cwvv/iDgLWH2QR4f/Rh4/Uyou7YQxSAjDNLsGZ2N+SrJGgrXfzlfx3zPA5mENwL4v1lxEWG+G+2K83eVi90DYRs39sI9ZJlp4CU222M35/7YZv6JMYULOQBYmvDPGPSEvpLTDnyZ9eG/8kmXGP4WEQM= 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 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. 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 --- 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 Mon Dec 18 15:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497158 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 BE5B4C35274 for ; Mon, 18 Dec 2023 15:36:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56B388D000B; Mon, 18 Dec 2023 10:36:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CE698D0009; Mon, 18 Dec 2023 10:36:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31FD98D000B; Mon, 18 Dec 2023 10:36:09 -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 16F998D0009 for ; Mon, 18 Dec 2023 10:36:09 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D2BBF1607E8 for ; Mon, 18 Dec 2023 15:36:08 +0000 (UTC) X-FDA: 81580340016.20.CB04570 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 1D97F40022 for ; Mon, 18 Dec 2023 15:36:06 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913767; 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=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; b=3Az88BrcUVe2aLowr7uxjjoQ3V5taL2GgBTP4GTQzUjXLosLC8PMSK8Aps5cEOy2VSarOF 3T7eaTg+xnHRj04dVBBrrEV4aFMdnyxrpfj9rI/IXrsP0LxcXvqX7yLlM1AWc7fbirq6ux tnKar7yTlO+dFa1TfG4YP9hakRw9q9A= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=none (imf27.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913767; a=rsa-sha256; cv=none; b=d4QcR2qP4aubqsrrqJWhSHiz8SM2SSws7DJHlPYlAHZZHaEE1pT65hLjc05phpNoPs3ixy G5N59fzmUTQe7E1WR+3kr33OToXDFgXASJnPlHBTKrGxPI0bih/mGLt2FohgKr4n0IEPeF Blf8efeRx2b35KUkKrHa9EHXxewFA8w= 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=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; b=VdO2027fZSQ6+ARV1T/HY1vjUJ qO+GRQF4owYZjioIiUVuSwZTEQ/cN/nrg5ibAjNHnyq/cr4zSGzlcM3y2Q1UMgHoJjGN5t8V1EETI Dpwa6PCMko3S+HiZS52aj4OQNyFjw58ZygjiHjXBfLsvnE/Xaz+CYmUQUEyXNr1g8ps8aTfa+ueqv L5OSfZ0qwYzFm6wuHHBT8kMKqm3isVDi4DjtWHI7vcv8A1rqKaok+5uIIQfDRfIgfvKrprHGmV/PM XheCITb/c+GkDmqgc2t1vJgBr7RoVG3iJpGyIdSONPMKpgv5v6LKHArfqGzB8I/iBFTcGlAch4WA7 2FJMcPyw==; 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 1rFFf3-00BEKx-2M; Mon, 18 Dec 2023 15:36:06 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Date: Mon, 18 Dec 2023 16:35:40 +0100 Message-Id: <20231218153553.807799-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 1D97F40022 X-Rspam-User: X-Stat-Signature: ssob8ahjyi89pk1agy9dzzfth36bjwd8 X-Rspamd-Server: rspam01 X-HE-Tag: 1702913766-627296 X-HE-Meta: U2FsdGVkX19i7ePG6LL6kCYfD4KltEVWBobckGaQNPiKXP9nX1Z8QNohrWACHPBESWWqJEAgurk+Ng9g4gYTgq4dpqte+IucNQozlJBsmRft1ub2A9UBeXJe3DQOx0D5AvGHcM4SIcxUTYYIyfF1zu/XIEl7NQdcBWR96i1BrVn0bCd1qRIfnZSEykhkIc0GyVztZ2zd0tEHk0rkXAkaWOsDn3dvTrI3af5m1cmjxAAXsaXYNLHnjUUDN+6a2clIhTG3xcQF5BrKfMTmdJ2+nwclVG1U8QCZQx70ruvf0kzkTVeFHrB5T5m2e3rbRn3n6EpPLYddhFlQ0MsFVoXo0xehQvbxpU2I1jg0PtYHcCpSfH7Cal9UhO0uymuig6HMv43iN7utKROUJzsVGjqnxR4zFwsRpcGKVxszNCTToqXQeQjHldvOHerh2JqFzaOam2fkyZxSArpMeaYkwUOGxN/o0XB2SEdglZi++7uMJJxBQaUa+A58JAWaTSMFF7XpwdVa7Pz8krK5UdO7DTU38kBG902EDvpqM0jljOexyecWLsjva2U5mQ1oWwZwpFQ3C0WZ7pkf/5xGFyExXuTPSMTksXnP26PPb7Lxsq9Lpq5g0wrRZsJuUkGlWOWRUB0oce8H3OYU7QS/dNus0WeVKoqphjjCg3ReBTJtYX3t1Is99ILNEtgobshcFuozew7eKG1oytDyemvNL8BT1DFTwnyJl1kd/gqT8GvSQ0CcLlMSth7hF/LB1Zf/mA9fhG7YEfqhESzH9hvPHNhbWfL20L1xLQzjKPXFl/0u9YjQAr36DLUDFpfr8ePqC7HFRRyYPwrO5ZZnOQlB+zn4jm/zhgZxKyK97Zpn/52mnFQ1Dn5MLF5kAOK7YPdT2iwRkSGueVV/jMc9gkUfrwZfymaQBS9rszupihWDAAQbWEnDLlOJpJG91MW8l8XOFmliiaIcO0kLcimkRNWFtFLIhU/ 35mKivIF DpSAyBEZN82mohtqLxktrXtYjAXra9KWJdfBS5QNN/O4ZUzlxiXwF5wPZOYZx8EB4Xh0cpnIprjMXrxK7Q/Ec9pjY8yl/Th7HECHYZbUuScuNv3X7spktGgjrixf5L7OeAU3YOSMYkcRuB2ruN3pVq2qdgYkPCW02hGPaluGC+CcfuO0/75P7coMwPFGv+I67sFnqjwMCORY7FnufXHsQ5tLs2IByJNKt3iR9OdhgVeOfKnPqNtNkxwn1LoM+3twk5mO8cv7P5a24DwxDrUEznfgWxY28cmOlHLjUXiMI/c9t7PN0otjk1DWpmMFJXNyb+/f7IOSUKcCc3CpdgQMtcL04FlXE4PxOd56//yQYiFnkua+AfGIdyZmYdAoalO40Fo3z19qndgJUJSEukyTHiHoLxSnQVoQ4KIMaLZYhsdR4zNZLmhYvzWlKRBQGd5JN5s3avv3rK6/QG8w= 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 --- 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 Mon Dec 18 15:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497159 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 60282C35274 for ; Mon, 18 Dec 2023 15:36:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F9708D000C; Mon, 18 Dec 2023 10:36:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 437118D0009; Mon, 18 Dec 2023 10:36:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 320D48D000C; Mon, 18 Dec 2023 10:36:13 -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 1448A8D0009 for ; Mon, 18 Dec 2023 10:36:13 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E8997A21EB for ; Mon, 18 Dec 2023 15:36:12 +0000 (UTC) X-FDA: 81580340184.29.DEEF530 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 1B6D740013 for ; Mon, 18 Dec 2023 15:36:09 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=42baJCQw; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913770; 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=36T96oIsRQC1BPzxAOWfEESJ9XwkyWKz6mizx5levB4=; b=3Q8Oa65kSFJAfG30p8eUX/brw0u6oX7/sdW5iFxSBycByd4zmoJbNfgbZYlrAyn5vJ1U0p Pf7LEbCcjb+hEYPkcAHyU0WQsg12mHHdiwKGHn79W0QZr0Rl5gUK8l4B0mN+/7xISt9ImG z3GAS9K0y7+eL6f8mF0CvtQqDFEf8BQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=42baJCQw; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913770; a=rsa-sha256; cv=none; b=mvwDC3yPC9WLVU2W/1HIpyphTMLAXjPWGtYdAvIQCqaeCyijFUXoYcG1dTXNZkVXE1YSi5 dAbWPAqNJipW3OcqF+m90FiiYfg+eUFqiVUrPy0GrZF8R8uaTx7PzFDjb6K97hdKdBcw+8 yyIBroDO6JwjZyc+JhVRPqyIWHoWgqk= 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=36T96oIsRQC1BPzxAOWfEESJ9XwkyWKz6mizx5levB4=; b=42baJCQw3pOImDKmFbkkzEpkVQ 5NCVTCjUI/QZvG9jAZnUK4eyKqg84LJYQzNjtFggZSHzUQbx3wv/0y5vf20tJEpkPcN4clo+C8Gah damfhaw5voBLIumLJ7gGslg3H01RWcXG2RyNByfC6JWSnPfezp2VXRvqa9TlemNsnsh6fx90vCdNE QCybiqW+qDXQzcNbVC29SchVdBVODfmFbi1d6AxVM31jdqZAPxo9rQ9vPyfHTafY12LbYBVYOTs+2 oPjMMUHHR1Xbnti7JO9/8/ZtRt3YHFmxVv/j0Ngpl7h4Q3yavIoFQtGXYJSeX3ABChPl9NCimD7kx jSDTxgNw==; 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 1rFFf6-00BELm-1G; Mon, 18 Dec 2023 15:36: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 Subject: [PATCH 05/17] writeback: remove a duplicate prototype for tag_pages_for_writeback Date: Mon, 18 Dec 2023 16:35:41 +0100 Message-Id: <20231218153553.807799-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 1B6D740013 X-Stat-Signature: kmaxz3hfp9ddrweezmuo8dw44rajsuqc X-Rspam-User: X-HE-Tag: 1702913769-466558 X-HE-Meta: U2FsdGVkX18j07837XqzL0/YU5rZdGRfaBtOKBSkfR0vJnvrNKlVfK5oIIJu22y0HyWkMlgLUkq837XY+OLzyZo7NYow4/3UpP95EKUfqEl2R2owK7eItm917cS/EwX/jWuSLpC3TO3frmGGeF4Wv/RluAHBJxDZwLjapQrPoQe8jmXgVd7Y+eSbQMQH5SEMh0R3NYumrBM+6rPxLShb4H1mApZ07TPvfWR/YyxvGZ8QEZIVbg7NFKZrMWnyX5C2sJ++9OfCOvUrbgIhkNMcIHwex/8zOCsOJgc4vx/QJ14g5Z5inTBlj5hpbFU8QehxV0Q/zo0Stb6tvtzmGAp8Uo0WmRmwBx9MLo5gP/2JjrI6XnxlahR6VBPQs+m9iT2+R8JIIXAmdNx3MA2NvepnUr+LHxBDlGqmLDPwjl9FA5WYDi4m/Ka1GovnXFZA2BKCRf6AcEQh1SOBA6HZqRpgR3t4oH5Qso64jCWEVlxN30XhbgW5gbrrvHfF96DapEGN6iAAlbQ734q85JSRMRhbiuKPQPTHQAJgXHWqh+dthPI6DDwUgENcf+s5vlXij2lfqGDeACFc1Ur/upzokNwInJHragW2A2I+sdzCtcca2x8V3RbxSVk9mTPPQk46td1L1zMSyXY5p1Zs6Llfck8AkNRXqccZ6AWRrsZaqfAx94nsWNQvi+F3R/a+TdPeQ15IfG628Og3FGsBI8eOEWNJy57EOo04GSWtkMmxAm4/bCfV0o/Njo346xJaTBSJmIpuS7HNq/wIuKEO5yRysSUJwPIIb9EwTf1DPjTGS9q7PAvKGHAqytT+oPRiKLhSXh0m/foF+H07r1MYhhH2xO+RA9tm7KyrGfysryfeF4+I4j2z7os3SX72ASQ/RQtpXCoX/Vq9ZI6okbQ5nbxnzkjBb/J5irFjZUUzyDRB0NBZDGeqnl4EELy8uLxXbuqy959ImtJeDJtBcXpCA9dBOlH 6jo4v4DE Y3hjHe1OxufcrsKNlXgT4yjn0BWyr0FHKhstCbHFVe+7BrwHf/PQ2NfO/9SuksbjG9i7AUHc3OzXTo8zkP9Dxh2uf0WxziXW63eHhYxcdW1eUonq8RZJHmNVTU9hZvp4cY8zuK2lKAsY77WarJykIkHuxpjb0wADcpKvrto4NJs3T6rXX/r/cWUE6RNzYYTT+lns6+DYGDoCg+zClXkgnDnN46iK+uksYA4D9cLhLWIe5+repWIarRCZqZc9J3ChxzVnR/9kljDUhKXavZwZxW/5dxCwKVmFfDl0BLWnxyHRUHu/s79dFVXc2muzvLiKGYXdYuO9YXtZdjRhXRWr9FDEpfIDsDXFq+LBSi9Ax8uu9hzw2iTE5XBCGsmCsm2yrSbTKqZISKu5+fzTP5OfepKIix6Ld4qATqcGKexStyAVtGoDIgEulF+2RQc7e8GulPVd75Y2qLlQw8f03XvFSkZq2vuVrrWGb3TJFPOdch3yXKUI9/xiO+mkk4dbnsGmbpPqI+ZD8fJPIljU= 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 --- 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 Mon Dec 18 15:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497160 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 D5B60C35274 for ; Mon, 18 Dec 2023 15:36:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 089888D000D; Mon, 18 Dec 2023 10:36:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 039EE8D0009; Mon, 18 Dec 2023 10:36:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF6538D000D; Mon, 18 Dec 2023 10:36:14 -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 CF18C8D0009 for ; Mon, 18 Dec 2023 10:36:14 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A8993140180 for ; Mon, 18 Dec 2023 15:36:14 +0000 (UTC) X-FDA: 81580340268.15.84820AA Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 0BD6DC0020 for ; Mon, 18 Dec 2023 15:36:12 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=C5A4jUNK; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913773; 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=vvqaN8/KIqeuNXG6MsZVXoxWgrAefdh1jtznLiH0jnU=; b=LAMMK9NxoxKPBYcGmXvvbBRLDfAgsCESXPZvGFItieGmu1feuFo9TpukSNfhPU0th/5gs7 a7SlIxJIWuQ2HQ+57r+xMl9rmFe+KqZELxTQFdtOdHFz3Q6zpJ+VFx3FpBTP4tsSpUJxfQ tznJuoJSFsTzMcsAwbw/9hIWXNrZNVo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=C5A4jUNK; dmarc=none; spf=none (imf28.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913773; a=rsa-sha256; cv=none; b=Zj/XFBKMPD5OvQzUE9SxdhsCVq5W8YZgTE835hKcftodJ50eOA1pxT1bqiRe9tkjt6RO1r s1nS8pq6YVFB/4qNOJwyVVxBq+fvxP7hH69wfbw82cErS6qIiXxXJPrEH96tuB7vyEDBkx YbtmP1IJIDjoyttsZWyZn+s9PurZysA= 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=vvqaN8/KIqeuNXG6MsZVXoxWgrAefdh1jtznLiH0jnU=; b=C5A4jUNKNWWGNM0AFYi1+TbZqg OyJLFLMAYeRWAkGFHpJj2/i2TpKNAExClZQ0eq/kfZp9NcqLA2do4BbRXo2Q4W+iK4j5Vs5EGWTtw cidcKA8PuBHBAzMjolCFFwvjF1I65aziLi6OSncFKhd+PQGJunCSWzOvrXiVNjvRdL+5XxP+vGK8s 5lB8Xhy8YqBjIl7CVAQyC5btI+HQsTN1MM7VZBSIoR4vpfh7l2M+kWRPnHGFvl25PWqUT6OFS6ICi R5oHvPfCAlXyzNuVQr2cvIxcGzsS5vrPEMkOuUUNuuUzCVzHfnUMHd5Uzh71D7Wv6+5fte9QYjw/K yYSn0SnQ==; 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 1rFFf9-00BEMU-2Y; Mon, 18 Dec 2023 15:36:12 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/17] writeback: Factor out writeback_finish() Date: Mon, 18 Dec 2023 16:35:42 +0100 Message-Id: <20231218153553.807799-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 0BD6DC0020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: jcrp9wxsj7qgpuxswtaxjdcqy5i6wjhq X-HE-Tag: 1702913772-339372 X-HE-Meta: U2FsdGVkX1/sSCmxMi+upeLdOGDmy04IP8zlJO3wtnGAulOzFGHaBJbFu0bxfXYYgmZalYlyBljn91gKdlLPukJP9cKlw+qe2siQnITMlC+WpPWeMJh8dKZxIa2bIq274VyOGSlyKf5eDyq7xWtExF43Fm44fLYypsmQhJr3G5n9EhV5FXBAQ/sspJR7I+Za8CN4XvsavrhyzBso+QnAXTWXj6d/BMXJn6RwwCPpDAYAFkupeEAOlC3XJNZQn/l+pBLURofmRChhFsij+RZGQhi6W7KFi/DXvm68KSiSCWlX5Yqi44WYYwgqzbwHfNQ+jqTHfb/3yWUz4/O0uPQ4VFw4K+mWuhjcRkJ8LKEQL9lpiU47aik5mpUMThX8JG9jTO7GeXmf0EYL/eVY5kY+m5htd6SUM9EgbDjRQAVowiw2oRG5Bj3Vo4uJr/Z/BDcYQSr+xq8OBaqf5PCTtqglKAAI5AuHCA1vqAbraNhUzMOad5u+KiXbOtPocJH78ll5V+EuXT2gjLVHCBTP4rnFRFqUmlnmaRl+12yueUQyec8FwrtM0d0r3E1P4f8hPLfGYSC5SR4qtXko6UmR+JdzJ6+cgPf29Bzh3wCUUAjF4Sng8YMlL1ajEv5ZNPSYLz8HAEvS8p33ax8mZvUvvrds3QQg6rPq8HcjNk8aTP4LwLyDz/YabB6eM2OCBFL6DtYma1BGIaBTPE6tvuTAXUp2GajZq5pRlHj7+MHd8b8OHo7wpfygSHEO0nE7dfLq61qACPEJPmsa+gkfQWul8uM4J2G9FqvGYSO8MTuDsytO28z609+0ZkFUDjfMH8K3IKh4STwo80FjxPckRFCg4HmPOq1J6IX/JI7/td69Kh1JseULUNJrgEHrLE4orjvzvCoci7PFklpQrF85mcQblROCDWu1dOhUTAu/PXsKwHc+ms4T1ksYoHlCQ43FUqRTyAOsePIqXxWPnqr6SvRja3y LUj/7wwI 59USPLjfsfG12vx/SgapfbNbj6k2SHlIGblw1NN6nVH94doqnT7n4wR+bLbwlAGrAOVOE4AmnEi4Kg6S/fe3kC2tFkf3iUhh8XeNvrnETVY/92KXxczQn5TfaVegV2Or6yxmBCWS1sDLG/6bVTXAnW0d2A7YAERpiwqaD6ikrJZpwAusiQP07AOipGWt9EuAMqXSylJo4i13KWji6UEKMM9QCt0Wc7sXtq4AEYmLtH0lEuGZ26zZ4WWBaa5/x++96W6jijAAZs3IAyaeGs/vYroi/e2msFi8TchJ98pRpfL9RJccXwQAF1Dxe2BVUfNfxP1gncqf/kR2LL7zFLk79UcXaHZtcrJySgMOhKzp1kNov4LqUJzilYoEAaT3b67S5KxvbTWM8sh0a2pIB3hysNVZ8aIQMmQeoJaa0rW8+pkYEebQ/DY21hBcbbNt5PbkcoAmEDwluinzWF3sdDqwGKbEjRBfbRCvJARpYPsKGbEaQGjZf09xYZVAdVLhr9E93WPFLL4mwQ8jT0N7dAAQKd+YLmGTs089Wm6UX 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 --- 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 Mon Dec 18 15:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497161 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 A6905C35274 for ; Mon, 18 Dec 2023 15:36:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9986B8D000E; Mon, 18 Dec 2023 10:36:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 939F08D0009; Mon, 18 Dec 2023 10:36:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DAE78D000E; Mon, 18 Dec 2023 10:36:17 -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 6B8668D0009 for ; Mon, 18 Dec 2023 10:36:17 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4C02B140224 for ; Mon, 18 Dec 2023 15:36:17 +0000 (UTC) X-FDA: 81580340394.07.BDCDC64 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id BAB68100012 for ; Mon, 18 Dec 2023 15:36:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Fx9/cCVV"; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913775; 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=aHXKO1UbJHXuqoP1fMOkKbpvbuANBll89l/hQyqHhR4=; b=IM7MEllU9yE5AV3b1hxwe0Aoi1G2XPCfNd6Y0Cc8HbhXrcNHLfxgVFapBS3aYtMIsmMqHT 1EaEnCY4NJnHSQIOHvIRwEORyjgaQO17ySIcbfCKP2f7wPRzF/lPdKvxNndByIhvee6SHl eXM8n98Bev+O3M4hB7M8ymHhmkc9yk0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Fx9/cCVV"; dmarc=none; spf=none (imf14.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913775; a=rsa-sha256; cv=none; b=hGC+hyWC354BVbm7D1fqrY9WazaZiUr39ftixD5atKkb1MrPZwh0na10NvPAdoRbQ8A0px B7AFaYxsEIKuuFa2GCo9q6Xiwh6tJVrdIXec7sQL7GE9D/6oA+Ih2BQ2KlJyhUAfii0qYt 1Nnal5/99kuAEahGDUVA+9FqmKnLx1U= 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=aHXKO1UbJHXuqoP1fMOkKbpvbuANBll89l/hQyqHhR4=; b=Fx9/cCVVlwYOnhe/PSU89cDqVD NI/Css67r/FlsYc8NmCfniGg54QHQxgHsspAS57gDul5cTzL0hn1ZYeRU9gC8qFIq//ZJLH1vTyTT NkYZETzb+w26apnFjyIKLapIGMmBHyHAabMX4hk9cvfq0clnn+uyJpYeekVoYtCuTYVUNQFlPatrZ SSsp/9CpzQ3RKUCNPWaBU4OgSu7Wl1+hiqb+XWiQ2Uv+YBGT9sPgftDPPkSwJXycLm4D/AKXvHjus 0HFC0kopXSnEv2BVLjCG4hwfCCGuT9gt5VWusTok0xcANlH5KBh8QDWOzHVEd1W+MU2o0JryEnPBY gQ5ZhBvA==; 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 1rFFfC-00BENM-0x; Mon, 18 Dec 2023 15:36:14 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/17] writeback: Factor writeback_get_batch() out of write_cache_pages() Date: Mon, 18 Dec 2023 16:35:43 +0100 Message-Id: <20231218153553.807799-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: BAB68100012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: pqfiq4sim3cc6pcwzsqqwtedqqns5tr7 X-HE-Tag: 1702913775-306425 X-HE-Meta: U2FsdGVkX183RCOBl1KzO4pXxVK3suinXqoi/Tdp6ReyTCZu4DtFw1GT+UcJV8MaRxNj/vE+GlUVKxeiwZh5xM7YDGDnbiXkuGs+xJ9gWqzujZMN9y5Ec7PBQ7UYXvHGiuKNt7dro7g2NdqF4Q0tg1PWY5dTLtlmltGb+sdOhdKsQzuxEsClWSfc7lmSkPA3mOPOOO3YUfMs9Bc1iJHOaXxFc+BhC4NaTCJPAXFzM/p3vA6Av7WNlHxaT1Big4f+QL82iI4Pe9lTUfMM/GLD332HrRbyABKNjf4wJjxyRqikmhtrrE2Vw8FRxzOTbmHl7177d/35JqEHM4AgIYook26CoEMDeI7VMhbXDzWl7KRMk+Bpmb+AXCA6+THAYgXPcpNBaGqIFBWj0v6RHb0NMKKwRl7aVIbQOCadwfi+m9iWhe5OgxJd4unCSmeD4asmcXaFLTDhpN68tUF3ebtRfAefHEAAWk3U/mELStv7I+23MrcqJy41P8oWJtZwmXX0y18MiBBY5JeB6S4xMFU1nh+9L6VmRYLPAeo8hUNsnIivhKe5ewZZU13d0iQoG5yHhjQXqZLiYbqBFSxOhcl7zoqAwPB9TY7IyhEQMfNh66NjVs5lh44mEp6vghtH+ED2aYJSy0BS2AuqV6vCPUhZlHu8aRNc41H57IIYxmn5diNw70ASyeB/A1p4zZa51TX5sffc5ujrfW6oX36nlnBWHmA6dVT17jjSYAHUPVSHF3BtjPTH/KkKfC9frGaHl30Md6kg7rOymAuQIZxDAiGEbhypzH9cBiSNw2HWhmwxeYz6l0r+HFWcqX9EVlVAKx7SfgGyoWapdWt/J6UraFCH0MW+zcMtRJDsvk9ffBFRElFgbSVd6UjWGiSp22tYwlhL/+AXDsaF8XUHOYPCZFey9yHGUPqGTIySFJCaimGnZzaSAca2tXTA1MpJuLE/5DmNGhFKvxIZvExA8BcHnQg hBev8bve a7ZKJWW7cJz+0oSW3X5kQ/65GKHuSNxrXCN9EO/EQrxN64qnijr5oOsc3VTPFFKjZXPorhiRQ5Fh43vW9+Y9R/OUYUPDRLejWuHp/yIoFw5uwZ2t53aS5hcI7T+euPrcx9l9dtCMJWW7f5KyHNDuGaEriSTAUm0RGzU3TZDSpyLfRu1Ih3/UvqnUj0lbnGKXAp7P7aCt5KlOSWolQzA6wprhchw== 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 --- 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 Mon Dec 18 15:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497162 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 63F5FC35274 for ; Mon, 18 Dec 2023 15:36:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAF688D000F; Mon, 18 Dec 2023 10:36:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B39A28D0009; Mon, 18 Dec 2023 10:36:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B13E8D000F; Mon, 18 Dec 2023 10:36:20 -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 84DF48D0009 for ; Mon, 18 Dec 2023 10:36:20 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 65A20A01F2 for ; Mon, 18 Dec 2023 15:36:20 +0000 (UTC) X-FDA: 81580340520.02.56F5693 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP id A6607C0020 for ; Mon, 18 Dec 2023 15:36:18 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QbDL69GR; spf=none (imf10.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913778; 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=FNt5drM75tskFSjmTVt5X4B1n0+AI4vg4FZ50KNwnlI=; b=JioPZFhUdLt3qNYcsqVQKpzTuIbPs0yl5PZZ5g94eAa211Pjk0LG0/rWhw0dZClecoIPTC Bw2M3EhwSt8IzqludiDS+T2NyIRw8ntQotPrvSwb1+NmxkYHAMOFPPtY9htZGrzQFrjD96 7tgShe/9I2syd+GeaJYXCHHQGya52gs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913778; a=rsa-sha256; cv=none; b=kuab7/RWoZUHHFWF3nvvK9snjB9wQWmOwBmQmOQD25qcOGdDofRW5QOO5xmXyZN2F/SGc0 mmH1I+OozSRioXt+SL/HMYVO9KrMX8tytkd+/vYUfLiSl20PsRwkWFhD8X2kTK4ige4lN3 L2JGhQAlTTFyU3IjbTw4FG0GD6EyjUg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QbDL69GR; spf=none (imf10.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=FNt5drM75tskFSjmTVt5X4B1n0+AI4vg4FZ50KNwnlI=; b=QbDL69GRW7vcyaByv+sL4EM+jX e1QFZOSXKXPkEb+eHP3GiM6UxRPacz9vafLmcd5vlzhMaNWjnWNm72N3eC5D3DOMxmjaWumGDpjGr XM6FXOQJMz+HmusWg+1LvjoRZGZU2wpeb6PIpggTeUTU3a+7tMOXiJPs2b8G376PygzwpKTNPmEIs hMmgGXMFBpTBYKLuq7Eb1xdpwVhL/ExPQOMB+E9OezOoHgfinlWKM3AQzMwJIsUS75WJ0yGWCDtN5 eQcmtSldtT3O7o6PWVWQLoa8KFVGz3GXZDRsAm5iHAYmgw9nL9j365MYyfJKPnp5qDf1Z929i1sSr k+mKxi/w==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFFfE-00BEOe-2o; Mon, 18 Dec 2023 15:36:17 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/17] writeback: Factor should_writeback_folio() out of write_cache_pages() Date: Mon, 18 Dec 2023 16:35:44 +0100 Message-Id: <20231218153553.807799-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: A6607C0020 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ibspmk4tmkmngpxb4gb8ge1cpozc3wq8 X-HE-Tag: 1702913778-323974 X-HE-Meta: U2FsdGVkX1/KjbbPGVb6iiale19hXZtxJM94FurfO9OrWoAFrWuKUlagMShhjBGPywJi5/FdPNaoIRppt2hnT1I27DH6qlDf0xta2svd4vRA7nR2mBZDj5E441wverLgp+UI6XVZVPUQUR8zXOMYyZafMrhrvFRpsWbP/YZHt7LnLEtQtBY4MR/x5uCNxVaGL1Aih+S262jRC98futiJvu8OX7vpfgKJeBpH+BaCaZrLK8gvKihqZb8ZoHqsZdZOUSR7XZ7OsY+2ixPBL7mTJ2Jc9LDV0SooqPMFAo4osdxLEiu9XdpqLJn9ETkFPtXEoomX+DDFwIGabLWxdTQC6QQ+Cn0LlrYaWNn1XKwCCG6PQVl+JYoQuqIirtuqw9NilpS3/ayfzUEwrg4q1ajvAXVFl3ZICz69ZjZvRU1KeFciiOHeW8bYhoOrANR+dMdbjqiPwD3PUsrnTVWigO5U5LWAHrFpdW5V4Uo+xRUnlVgo3nAVgWDZlAv6iyXmrEmSFLI299MMqUd/rTL8Tluu+t2U5xNLdqWwRs9kwrcPWryTo7VfPHbJWFscBGe36VRr5kq9ZvVxtrM/5Dch464wz4jdHpGCny/eJ7+ihRvn3x9f0cAKVOuwAlt6VEVOuMxDxuFXYz8dTmK6QBOnnubaTLIi3t1t3tuzV+R5mfTx333FFDkq1mXzO7s6klTJp67M3ZF5x4BB7FeQQuiB3N8BKEhqSdL9ioPHhBVLK5xrBx0oLIf7jUidHGrvmi0Vy8n8i6W1QZjLrQNbuW/T2MBwXpnFLsnKYWo9YT2mxi92ytCC9/xOPN3ujDxcI6UYsz2FGGkxDuaS1m44aHxSbq+ON9E3lLW74ZhNKTF5hOLZ4Go1d1t1B36nQBFAqmKvuSA0nE9nLbIiQ+0Ma7gsGeVZKiM1RfaQgeIqRyKxNCmBrAiLwFF0cZPdPjF1TzYrWwrIkJ1bA7tfRSPfpQS5IEe sP3SI4w0 miLSrCxtmrkvkUyM2ESFd6eZ4sHJub7EXoJdmAHmK+7o9ff7a9u9+4GZ8Plc0HbwBRsZshusj4NB3/TjYe4rAsRVnzdeZPF8VvtsNtkxApshOl/DjOsxZmxrIyyvAYrBcNfzGjjSIzfbLHYdLKJ2KdIcc/M/Y3lVUcpvC+Qj0gS7p5o09NKpuRHHHC1j4/vws8KeMwtbMWD4iEdetexzYXYa0iw46+8qZjB+GSv7psYFqWPJ9j7hKjHrhaeOuslI2mVYzsO9L6cq6I5DeNJrywuLQSpPbaogU8wIHIcoavp0btCqWyaXLY0p1vkIqXobxpWakFDxHhYCXnSx9TNzT+nfhmJhP7QH2lgR/SDcotLKNDUlqq9y+SZ1QzrmgAtXJoe+GEHj31Ts57ZTNrJ1EX52h300bR4CTAgC2dRSnoJdG9LICcBVJIjI4CDxkCIK+VyYFrg3ikC9N/B6sjRmLPD02I9KjCswlQPlgm5Mp+nrMCTb9Y7ztFsDulGIPhnaYuk9Em9fxgkTwCzI= 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) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/page-writeback.c | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 798e5264dc0353..2a004c0b9bdfbf 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2406,6 +2406,36 @@ static void writeback_get_batch(struct address_space *mapping, wbc_to_tag(wbc), &wbc->fbatch); } +static bool should_writeback_folio(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 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; +} + /** * 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 @@ -2470,38 +2500,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 (!should_writeback_folio(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 Mon Dec 18 15:35:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497163 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 B2C5DC35274 for ; Mon, 18 Dec 2023 15:36:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3D9B8D0010; Mon, 18 Dec 2023 10:36:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A72FC8D0009; Mon, 18 Dec 2023 10:36:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C95B8D0010; Mon, 18 Dec 2023 10:36:23 -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 72E638D0009 for ; Mon, 18 Dec 2023 10:36:23 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 42C02C023F for ; Mon, 18 Dec 2023 15:36:23 +0000 (UTC) X-FDA: 81580340646.30.58ED8CD Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 7AAC41C0029 for ; Mon, 18 Dec 2023 15:36:21 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DfogWbTo; dmarc=none; spf=none (imf18.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913781; 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=9E46P8RBBTh6OS7XsshX1gEfzWzF0rjfwCHf/2TCoS8=; b=ZjDsCmQ5LsDYiFqq+jXCYjfRGSq9ff0JMpe5Ssr12RfNM8nB+BZW2/PvK5y5cJNlOQ76AG idWypeb/yAK4QOgs+PGWT/4KI8lEglRnJGVwSvJP5zdxPmXWRubs/6fbKeRNDEE8caQdSh qQqwUzhrhF60AKFHWQZ7yDJkEQyJoH8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DfogWbTo; dmarc=none; spf=none (imf18.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913781; a=rsa-sha256; cv=none; b=PKfnflueBLopSirMnz0hxQNjJIXs2BpfMPWB+8IdXjOG6JJy2yaw7ne7nWJkJYeTXBGOLN swZRhYATeAQHTxJitTmG0bcp49OIlmk8iqgzyclcC6bAwmq2WA5jZHJWjx2xk6hpFTEnTX 1GIaFZmCrsOcWQ7iG+VlEySki6ps/hw= 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=9E46P8RBBTh6OS7XsshX1gEfzWzF0rjfwCHf/2TCoS8=; b=DfogWbTovC+MaOjnIwtN1k+ufe 43Ts4mac1JK2rDHqW2s9mobtENbKUfR9BFoKwLFg1BcjgMQ/GLdPgjocsslPLAvmryBkB+L6aBzFd 4f2bI16jaiAJ26Qxe8VT2ft+yHYcDpYUO4wZZ0CHOua1wdkZm/mH7Yml1PKCixNZ4/egD9MPx9yG5 v8SBQAHvbwgiAd3NzfUQUr96kLLHmE17pRAuOmQu3Y0G9xI54rO+mUK3+sHk+j57wTC5j5rMCEMXx +wxkIw4M6tuiC9vd/QjEMHqBqbxQtz1uRFx2lutS1EQnjOZt5+jkyHdqmKI58AU1hOHa774zf+XRm vMF4vlvQ==; 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 1rFFfH-00BEQj-3D; Mon, 18 Dec 2023 15:36:20 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/17] writeback: Simplify the loops in write_cache_pages() Date: Mon, 18 Dec 2023 16:35:45 +0100 Message-Id: <20231218153553.807799-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 7AAC41C0029 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6feqr19i7i77r16oc489xdt89s38ofyc X-HE-Tag: 1702913781-502342 X-HE-Meta: U2FsdGVkX1/UC+KjGVQMghV7IGKLGhi3FT1TDlLghGKy5PBHHF0mfGLPxRJnHKVlnGhU/4LjLC7qVPXKZbrTCRkvW2yxRPHUe42lYg3jVgnxijH8Dt01ZmPSLU8WSiaEh81y6mou2qWiAl5G7P1oTmLrTRpvXXrI5jeb+5Z64UJO1Y3T6nVbyjxaDIAKqYf4YwV+UdpR9USMo0+IVHrv0bIDS6lYxi4LiVxsqpv8ZUzhbkJ8XQ4ivjRg8v4Zn5rqdOCJgOkcTfJ11gdUbWO93JN/mhHqJhFA3Ub/9PYGlG2z39w96rN1JZPFCBU28u+w0jinLg97WrmIFX6PdqiGsDVY0yW19Z1R4jIN9AZk8iIicfcrPWenHaIbkGRt4DrWqDjTICeDAgUVxgmLA8g8VuqFahv1oNeM5TZU4LfaHFgizSVnUDlGGiYuHNg9/fs+PiBEv+GnHlTyR6B446Ag3ebBvNmlS8HlrvBU6uIO+WZI4hJY71fiw1OLYavbtIirT8GOprsTWksSGuMk9j/noftSln2bGbO4LL4LngnGfb2bLA2Qbx7njqG4EKvL+afrGw4JvdSLoLqKkbTDsSsz4rTmealSnnswW7GxVciJm5D38GJAcOOWTBYwjuFMUXKYa2CRwcXhOa/MbJLyqkctNn2Rwa8gl8rQDul5IBxRGa+ZtAeuKvQ1XIJkn769fGDQnAkknwmZa6DM3CZ3t0292csPVLo86x0qbZPfZ36yw8vgBV0REuNNc5wmQFnLbLzXR3L3guITfAMJIPyzGzqpD0DjMui2UIBD9CKlmwxdR0tLZc1mOIhht/V7Pqho4fgBVqVYt2urAOji0vFftkyXxkNT5y9H2HKMnLNIBF4xwbm493n3budyKGo7qlzI+5loHXZ6rT8Mq24jvj/uVwbKXFHVcFD3AGrSWs1vYQBhffBJOrHPOlgHJ0jw1XQSeSCZdc9Oi25pwIU6S0DRzU1 Xbdk1NyC IVuXaVhU0y2UpI2Zfgt7oaTHPGz3QP3nBy+3WZluRV1RbyEzS+DmDuc9skChLe9KB5dURy7AcpN7tZhtkl2ThRPRi//NxmboZnVNmiGhB1sT4ngQ/nq6Nik4Wvvme5aWnuo1x7SXmK+S7hdfvSB2ulwGLRDlOPbUNY+ya+DS+AFhEQjM7B4ItuFIOsElCcv76sU0KVwqIJFWDoks5ff1qRzTbjqs+PZ7bmS1CpD2QAAJKd5OSDOFONeLC3z8Oj5ZMkWU6fOOUeOanLyECtuBkvluTT7tAWZut0nnkW8dvhnB/7vpbidKHytkvxVcqjlnnhHiGKFxSlJS1jNg7Nmh/xb+yUdiHAWWj6u3d6XpyufLI2jM6TGhkBZWIUJx/ta5fLSltiTHf9y2bhcEhVrVkJfOaBFbq0PlYnFM8NyFZHs0KhgBWuDZgWXkEmCh6dZNmWLNkO4GiLpYcrk6cAMFV+fLVorTJU7HGD26WiZDUbQyP/dAlZbebld1VJzlC1s/tbqNeQDy2xb/bBMc= 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 --- 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 2a004c0b9bdfbf..c7983ea3040be4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2473,6 +2473,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 */ @@ -2487,63 +2488,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 (!should_writeback_folio(mapping, wbc, folio)) { - folio_unlock(folio); - continue; - } + folio_lock(folio); + if (!should_writeback_folio(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 Mon Dec 18 15:35:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497164 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 E5CEFC35274 for ; Mon, 18 Dec 2023 15:36:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 064C98D0009; Mon, 18 Dec 2023 10:36:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F06198D0001; Mon, 18 Dec 2023 10:36:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D33F28D0009; Mon, 18 Dec 2023 10:36:26 -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 AB1018D0001 for ; Mon, 18 Dec 2023 10:36:26 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 86016401E5 for ; Mon, 18 Dec 2023 15:36:26 +0000 (UTC) X-FDA: 81580340772.25.89908FB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id DC3D040023 for ; Mon, 18 Dec 2023 15:36:24 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PzUxxt+v; spf=none (imf07.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913784; 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=Ps3gOgcx63gp+vASNuJqnAAKIBRQ41EfNIZIAmlnf24=; b=QVc8TNjw72rP5qtmFeuAkKnzCtTbcdGgFnesbM1Vpn/eosLZKfAIaEklxElsQrLm39KVR0 AM8bZtHR9b233BL9rnRX378L9ge5mF7pklcsjc4VvzoaqeoU+/nX1p4Jf3rtm67JXh/8Ri BjfbkJWDvv2qclMNCF+nrkcnJkYHch8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913784; a=rsa-sha256; cv=none; b=6j+BmNUJcHC9upA+8r8ONFXW+r+v14jNU4tggYo+P8Kr8UmWXS1PFLp4UFriqDyh+AC0fn DVq+G7pPy9ySzhdq3/cORJIcb8H2Ygx9hnQCP9vUTQpe9jlDOPMTZ8ozJS/1degqXE2MIZ 0HgVmtehceQHAhv/BkzBYpuvqX2ex5s= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PzUxxt+v; spf=none (imf07.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=Ps3gOgcx63gp+vASNuJqnAAKIBRQ41EfNIZIAmlnf24=; b=PzUxxt+v50nPSxDTPZ8egGBWfd MMy4h3eKPEI9Su6ip1RebkN45yXzbC6KCzepkmpLe85GHZoJSqZbASEKMt9yNN8UH7UVTwf/eT0mi w9A6TjmvLXfd7SrnEsmK4cDdhwPQtRcurwRBpW7JUAxqQ0pXquJQsT0pftxGJfvXfp9gLgSqtSymO 4/UBPeQrmuWwzuXGJ8706l8U3n7gsEUdkBmUvwt0JXXH/HXdu0JWfMQKqayYaFepmfeDAbF/DqZG9 2h+m5joplkFF1pbTk9EjlIz1dPpj0mTXzvWh2NGDfy9hKFS71M1WR9jorHRxb7VMrv3F0gkxqG33t ZovPYW6g==; 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 1rFFfL-00BESJ-1j; Mon, 18 Dec 2023 15:36:23 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/17] pagevec: Add ability to iterate a queue Date: Mon, 18 Dec 2023 16:35:46 +0100 Message-Id: <20231218153553.807799-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: DC3D040023 X-Rspam-User: X-Stat-Signature: pfnwqstxo8wcf66hfos6kqhxzih651fi X-Rspamd-Server: rspam03 X-HE-Tag: 1702913784-473425 X-HE-Meta: U2FsdGVkX18U9Jks0Idx52Jro+bZ0uH7iyjB00Uiqb0RqXenP6b/yf/nuOergsNU5jMnZgPMcySpIgPyzAaXkssbTiGTa40+TRfsYLuJGpFbHHlQbugXwsKFKdkhBINATncLvjLQ3r3CVHVPhK62dd1JGRXtZzeuaKW1cnQVjzH7G2dIVl9pkX01go/vxu8AzfraA7Yk6MU63yxtXTUbSOmPY79lcwT8MC/r4854cifWBwUE4tY7oWNmyFPx4zKFKBbd8RQKaQf9Aat26pBiC6ggKbByDO65oZJoz0yG7b/JyAWNwWjfZVRL52XmVvp3hQPtwkxM7v2vbtyMNDKN1M1t1MJNzpI+uGOUX8hksUuYqaC6lBiYo8yXRKSeOoFbSCCfILM4/Pr9w8XCFH2rgEO80lqyUjQO5JvmxpQNIItoavAMCu8UbpM4S7oytF5/b3J1CrjHHYm5vB2zXjT6IhwJEg3WLHTSASASKfQiF/bJ23Redn1EExZdpxc4LzuIuttepmQLZj4TO+DfCmLLBGeHyfWVqJOjIzeUeraKM7Hg6GwyeSRHEnKAn3M5NrfrZMHru4zjCXCvostDm7aS8cBMv4IFgfnjMlYHRe6ShztCj293gU8Odi0jQUYjWxYR5E6YIT8hzd6+GwnFaKzAtcoSRnJKSDSc5tz445Ih82gcmPxLCo57P5NG2Eak1Pf78ipDQzXdv5TAKMKSeGQs8qeAA+1/Y/5Giggkn1F9sP7wzHQCQmJfLwMBlcR+H9J9Z2Irx5w6UcFEhpPi4N6G5NGdyGdCvPbp0KUIegTozI06MI3uBB3nZ8QOtEJCEinVCiPTvAlmyhMgrUGugl9wyV6xZv/XZtli1kNpwvIi467RypKCUZjuAmiA2HnykCdyoJRLC7692EwgWilXVoK7/Bhe+B28rFafP4agWx4dCgCfYpHHPmP9rnYPk6VMVCVTKBBdm9RR8U3a3EPW4V7 pqiB8uHH A/cc47yqEKGJ6N2kVn28ryV4y+I4ia6LtkleV5LIp57u1gam/E9OXXHYGGEDig3L5UufYKbD0P8uM3jIIOhX9E2wpZdQ+TlhMrHUwH/MnfMe5vtH6cSZHT+6/kbYiIf/dx8D5AXOCkAZuCP8s0FJ1IPNJU7sSeTjjBs9snhqI701a2HPumOOJFFIai5ioTybZzILexm6IczRnWjA48GyXF+RvmrkyqJmw1sluTarECVh+0OrAXiWCb3sXrOhmOZx0h/USinifErmt9PW2FpLPJC09iZhJ0tI2aq1wZRiwYBJKVIlHTQAo/++Zh5yzQjVsRQAxP31ZvD99aGP0p7r+KoCCmTKGMtFU1vOm5e1DnFWBKpAgeq6ohJPRmawvUZu+vhZQktlA+cXEsGTezZ8/xbtu6e+qHgZ05CrCWJ/pmZ5eHhxtNbt7He/6HDUtLRrAyVKwcpEPHDvRxoExcF3A1Po7YL3/1QuocdBH 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 --- 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 Mon Dec 18 15:35:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497165 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 1B611C35274 for ; Mon, 18 Dec 2023 15:36:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 803CC8D0002; Mon, 18 Dec 2023 10:36:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B68E8D0001; Mon, 18 Dec 2023 10:36:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67E3A8D0002; Mon, 18 Dec 2023 10:36:30 -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 5315F8D0001 for ; Mon, 18 Dec 2023 10:36:30 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2D80140B7A for ; Mon, 18 Dec 2023 15:36:30 +0000 (UTC) X-FDA: 81580340940.20.F196DCE Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 675BE18002D for ; Mon, 18 Dec 2023 15:36:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=THuXRAhN; spf=none (imf24.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913788; 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=3B9Hp+QAdQFWcqrQUPpFbTk6qvR0M5sjBup3lTEiqhs=; b=x/wQ94S6UuJyNP3jHllYFTD4TnYcLjGgaf25s394NnvB7dTJgbkULuog9Ovuht2yYJBdR1 YENYg5onIupGEtPPUxd/x9xw0TCCD/Iro/+FzEq46zdn6uPpXmuZvtV9eNU0rRe0BQD0gI d4RtFdJyDoLgsxyo2o0IdgVPamXKrEg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913788; a=rsa-sha256; cv=none; b=v78Sx/VeAcbktPLWOANMfn8kxFpqS/hr79GxnQwhGHutcg+2ycuVpT1WFnTpfREqMaGYi2 r6CumGTIPHOysevinM3rmzInVaclEvI7nBT2y3KgMQaeJkugzeh444e1ALARzKAsrm5gXL v9f9hWJYudV8ecIa3kXTiqKtV6OCHNA= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=THuXRAhN; spf=none (imf24.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=3B9Hp+QAdQFWcqrQUPpFbTk6qvR0M5sjBup3lTEiqhs=; b=THuXRAhNeLCiO2K1fm6woSSF0o FKejSp1UwrESZMKns9PM7cdQ7F8P7vGO1leM/ItulT1ZAASbVhH3soffvn0yy2cYNQ7Db4BAOr9ku m7Aeco/LSG1tytEmmHRNB8t01Capsk3p3022lowatIGQS/92K5TIZZ50ORvE1uUbfbl5qTGihahCG t7RR7qRTsnt6rYpRX6/KmySAwqvvivwVdHHPiSnYv+ICCPdXwP4idam3OfER0xCEM1QDucjIIGYwL z3kxcpHeMwiL3Gk+EC3dtqn2BU8RvjxXmiBBSf79ujCTwihDzG75A4W/ShiFDKWGhEztFg+1o/gtd WL+ry0qg==; 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 1rFFfO-00BEUC-1y; Mon, 18 Dec 2023 15:36:27 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/17] writeback: Use the folio_batch queue iterator Date: Mon, 18 Dec 2023 16:35:47 +0100 Message-Id: <20231218153553.807799-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 675BE18002D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qs1xf44a7f1eq3uub4nrupicce96srtu X-HE-Tag: 1702913788-192832 X-HE-Meta: U2FsdGVkX1/FGncAUKb36UV49VoCeVDx1ra3Cb0YtCFpNWdUTHezK+ZQ2PEbyoR+sx0p5swyyCDzRf10Cuxd2OkIOec+/uOQDK7twlKNTO3PCnmuXUQO17H5jRE1ZuaUGfOMUcSravXpjZniPeC1XOzDImhfu8ALBp6E/2nWqDB3AW+AFEE6RMjyesOZkrondgHsfycIgLaP4N0LUK/zRIVcn77JdVk8Bsd7Ha0rWKIYdQ7ykF8exFI/A+ZP7w8khbpcJ4IOYcmjgBfaFHTf/qRuJUF9OKbT1lRuWlIW6qWeFaF06YFxJqX0AljdBG/itAr2Bmb9ZWtioHcajKBEh5dRA3rgVOp044XE1Kwo2yKOnVxCaYh8GIQRqKPNM9opIvp3hJouhcAr70CJA6ceZ+VQQKx1yRvCv0zfrZgxONv/G2P9sYiWl4mWnMkn0vlw/vovjA9L7S2pTF5lCE/bmPaKbJTLzxWxVXsyFaHd2/3IN2eyBXTUf9FCsOuRruQKgOejvfFz4fhl9uPdhX3HftQ30dewysL7MSpNk+u1Bjt+hkOWKYjNV3AnVKMHJyh4Nt78kX1fb980fWx5dDEvVac6VHU9mX4X77OuiArIp9f8PoW1kZc8yN1nKNdp4TwV+UzISsEtdlGskTaSjO5b+WjvUTziP2MovXsMuCQbFZPvb678uBO/u9cFkR4ljHRv+rp8S9yvKhoJxM8q3L0nDrhWa1uDc/8Ln/eEsfmKPQBMol239m8xzTQ9q9SkNbFwejM+8NihQ4gN+PRZwcHFZelMCgqKFJp3OXJ5LKp5zKa/te1xrVpWLh5zDqVLZwwxRHnwwjtrW7gUXB1z4qIiJcdjL6edXFNfmUqm+Dt8+ldhru+5mkBcWH7dpYBXCs3v0Xayvu+Xy/Ik8JNTz9OH864/IC8D39N2e72CLy3oz6NcSOxmCIGaBkeheKiamIN0XqGOEiGZd5tfL7eWBFr BuS/CbXF 17DwzRayavB7/hGKFIhnYYcgdNOmx/nzXul2wJByalQdPkN/XbPkUkjzaFODU8AytHyCPmabE/7saAL/Rv9FpwC9os7XrApyaBP7KFfoOPHL/2hR342na7J6dpf2rFCLm1Ie+RkO8PSkRUoNjdRApNNpESyzWDoHpz9fSJNwBUFjuMDzoikRLVzAUear7Vhbi6IGrcs3gXsY/tnJ6TjLjXa2EwqkUp9Z79YeJs5WyLBsPjS9vetPUMe+RLuaPgdqbEiY5Dm+9kRoJvaA2YOzyfMddMKq1YyLHcVpqz+yKJ5DiGko+s8sewzIgZ5RqLTKmf2rqcdtlc0udkioRr+zZAteBNCJf9UY1mW/K3i25HqsMJYHULQjk1UfQxuRJtimHj6Z94FZQ/jL0Ur3K1TajSxFInmxhWvnhAwWHmRg2bMWz7yWIpk3MGjJxoxsJlz2NmSV0SnJ1BIbGX95oMhrPAJx2cjnxD/P1RvFfstJEmaY8uwCuXY/tSLr0H+2MCLfXlZ70jfXsHRmqHsA= 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 --- mm/page-writeback.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index c7983ea3040be4..70f42fd9a95b5d 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2397,13 +2397,19 @@ static pgoff_t wbc_end(struct writeback_control *wbc) return wbc->range_end >> PAGE_SHIFT; } -static void writeback_get_batch(struct address_space *mapping, +static struct folio *writeback_get_next(struct address_space *mapping, struct writeback_control *wbc) { + struct folio *folio = folio_batch_next(&wbc->fbatch); + + if (folio) + return folio; + folio_batch_release(&wbc->fbatch); cond_resched(); filemap_get_folios_tag(mapping, &wbc->index, wbc_end(wbc), wbc_to_tag(wbc), &wbc->fbatch); + return folio_batch_next(&wbc->fbatch); } static bool should_writeback_folio(struct address_space *mapping, @@ -2473,7 +2479,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 */ @@ -2489,18 +2494,12 @@ int write_cache_pages(struct address_space *mapping, wbc->err = 0; for (;;) { - struct folio *folio; + struct folio *folio = writeback_get_next(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 (!should_writeback_folio(mapping, wbc, folio)) { folio_unlock(folio); From patchwork Mon Dec 18 15:35:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497166 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 D524DC35274 for ; Mon, 18 Dec 2023 15:36:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8046A8D0011; Mon, 18 Dec 2023 10:36:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78F438D0001; Mon, 18 Dec 2023 10:36:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62D5B8D0011; Mon, 18 Dec 2023 10:36:33 -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 452E98D0001 for ; Mon, 18 Dec 2023 10:36:33 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1AFBBA2805 for ; Mon, 18 Dec 2023 15:36:33 +0000 (UTC) X-FDA: 81580341066.14.995D369 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 8C85A1C0022 for ; Mon, 18 Dec 2023 15:36:31 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MXOOyyiG; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913791; 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=11fJOeLJtEu+HLcWStjNzVEg8D8E0pgLFFPvW65M4Co=; b=pzwK+vJfrh175OTHRFBlPtj5R2G2wRmC53r8QfxofyYeF129Qx2/4u7TOWt6kyiCpWjXnV 8xK1+Utm+4NimVzc5AT6OmzP15XFLhyt7C36x6fVvMDnI0T5kXHfTtkybVaxWswOCE5RZT w9ndKln3iAeYdCd/Pru+utznV/lydnA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MXOOyyiG; dmarc=none; spf=none (imf21.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913791; a=rsa-sha256; cv=none; b=puM2ZkYoywZyV6kwM/lUeYr09m8yqYfQnakQl1zl/RRDKQqhG/aMdR5xuJDUJxJsxonORq TT7dCljYyDLQ5cZXti8P06Moh54QJdohvX2Y31Xq1g9vJy28B1qwkTQnw1fiG7wYh5n8sG Um+QMvF0fwsDAZf3IGX84Md2YCBwaFI= 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=11fJOeLJtEu+HLcWStjNzVEg8D8E0pgLFFPvW65M4Co=; b=MXOOyyiG08iR+isoX6KD7RrhRt 0QmbZm+seKCas0S98o9hhqfjQr+vlWEOPT/rhVKpCa/ug/D/NkXWj7C1tgZXQeIQVkVhCIs//zQHy t3gNoGV16ux4RaT1JuRzdxFP47V9wmEuzUaBUuWpBMIWmvjTHcVrRKP+iRpnx2k+O0LglLWfTgCiC p3ZhIyUOhbchYAy4iRYYUIw38YozNgK4QODvPde8KbAfKrK0yLwBCx3tJ63AZ+x815DPNLbVSczvb H5oQ+NezuCm0IvG56bFh5739uRp0nWlfpeCgsFIiZRsfEL8M9gbUEyjA6HfZ7Y7yfgWBJfb13/aN4 WwKzKFCg==; 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 1rFFfS-00BEVg-0O; Mon, 18 Dec 2023 15:36: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 Subject: [PATCH 12/17] writeback: Factor writeback_iter_init() out of write_cache_pages() Date: Mon, 18 Dec 2023 16:35:48 +0100 Message-Id: <20231218153553.807799-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 8C85A1C0022 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: twxa8ijziudqm6mwoecfm58zestyj19a X-HE-Tag: 1702913791-119458 X-HE-Meta: U2FsdGVkX1894/cZfe4gwkDBB9DtHSeF9/WruSFGsOiUFS9obffckFDyK26TyWV/ek9BHQWqMFZp0QBTtoG+YMiqgZI3etuu+S0Xk0xcdMsvhT38DYAp6LGzm1gOp2AnSJttygnSNA7E0aLtQN8oeKRMCryvIg5GLax2/dOTlm/VsNbrQgSyBlDdtlgOBj95r+LmCD/sLQjZPExdMy0nzbh6LoHdDDv0RPuPQOvXA4Ks4jCmRmFDVmrznckbpX8J0jvW+u3CONsCCcezKaDwDxmMnr69475pE+VWUAgwl4RTCqYOlWLEGclzot4jOMyh1Zawz5hNimp7fqc6EFQTvFhg32V192TRaIKR9eQPkJS2882hCL90HXbgbFla1FTrGwbP1XnUfUJFlk/PrkFTZtAfu9gzy/EbtE3R9HIFxJkLQHa7z3fr08+C/2BC194uMsxT1jbqM4RQfLQFV0pMhk0sion5Me+JouZvSq1vvYUgGJ7GCKHhDv1FXvmEyv2neAGusNdLm6VBK9ehcXTsGeeBD5fwUG0wLRIIwP5RDPcc2LoGs7fM1IRMCWsQvGG/V4UzVpi1mDh7/3pY/PElqZeF85OE1/zkprlX1GMuTQxLxQ1AsxbtsC3e3cbXos8wc2TCuW8lCN/CZQ/19pJENaH0T8zIsBNeZ8cMZ+HVJmZ+nrS/5WztMLXLjRsYpLt6rtjgAV+42brEehQAQNfdNc0NRIX3lPQeq3mBIZyI4+KIXSpB9QBXmjlGpkA+2DrVwtg34mRV1bqoMJ9PuAdGScnrmKaAaGj/GG2D+3x+sPj+vrq67NDwoM/ReAboptW9N6U8AxcimGehKNbIkzRBXLBCvRtLBZQCWcnl6qa0dqwHxqNceTbJTulz4GtsJu5teanNfR7BF+lC2JvUrKoZATtlNc3d3uW1u7cChFQ6Ye5Q3HylB/hUlqgmbC0K5OV6TgZ7mwIZNDyqGejjwxk x0oPOO7i vwIG8x+kEcXTEFV5P0ZNBKvMG+UKu/qD/dwBWuvqsF1tMZ8s6N5S0PKaAcvWD4Hj8QWMIL4ou7xRxwNqaE7cdTDLcgOKThLwdKYNHsFsvopYsQoDeG0EBqJztuLsPkJVS+MhIfDARqWu+8V1gK++7IzxgMSjBue+I+ZdQcbYBuc2UOD5CseQPuxJKZAOE7VL1ZUqVBJFno2PkjhP+TyBLz73qjQ== 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 --- 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 70f42fd9a95b5d..efcfffa800884d 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2442,6 +2442,22 @@ static bool should_writeback_folio(struct address_space *mapping, return true; } +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_next(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 @@ -2477,29 +2493,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_next(mapping, wbc); + for (folio = writeback_iter_init(mapping, wbc); + folio; + folio = writeback_get_next(mapping, wbc)) { unsigned long nr; - if (!folio) - break; - folio_lock(folio); if (!should_writeback_folio(mapping, wbc, folio)) { folio_unlock(folio); From patchwork Mon Dec 18 15:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497167 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 BDFCCC46CD2 for ; Mon, 18 Dec 2023 15:36:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62E848D000C; Mon, 18 Dec 2023 10:36:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DE838D0001; Mon, 18 Dec 2023 10:36:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40AA38D000C; Mon, 18 Dec 2023 10:36:37 -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 2CAF18D0001 for ; Mon, 18 Dec 2023 10:36:37 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 01AE61601AD for ; Mon, 18 Dec 2023 15:36:36 +0000 (UTC) X-FDA: 81580341234.30.5709956 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 3347840015 for ; Mon, 18 Dec 2023 15:36:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=v8x9AkNH; spf=none (imf07.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913795; a=rsa-sha256; cv=none; b=bJTRKfdZoipmqyWAJpsIFaMBnsmi2lRs/N51My6Zcjr/JKj3UmKkxLjPDPPA3rBJ4nm6bU PuLxr8KXOzbFYrMa5C3stqVGgA3u97TJzgOYmAnRinLTicQltXeQ5KmpYXm6PZWXJQY9gN UA8stRrazKBjnIum7ojlAvewuI36Hro= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=v8x9AkNH; spf=none (imf07.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913795; 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=wPsE/cfutq1rEAGOfLa3oRuKt43FXWjmjgTx/hXSxEs=; b=UXUoBS9zq1rG1AvJlg9DBNXHS8VU7M8Lm6iHDMH2Fnu0rJdB8w6B/tk//xZJYSv2s8OSKi a/WJM/voCEwj6DvvKgboLBvRGaF3maX94Tw6xgv0VvXZPuHftyH3hT/rmrg7IbYV+Bhuph BBAAF/Rz9HAMiCDlTi++bzAVNYmFkf8= 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=wPsE/cfutq1rEAGOfLa3oRuKt43FXWjmjgTx/hXSxEs=; b=v8x9AkNHKUmXVr4XL4EvllOnXA eHt9IpWbfIqZsl1l7GqGaWOhzmg7u5y0N6GXufr1QDG5Dy7byB/Ne/jM7TatIS09Ec2dHkXOUe7/u wOQSxttmSJUsViYu0u/sGGD8jd/9BN8AV+ZNSqlidRqS51/pJwK9kSVc6RvzUm2iAJ+W0choBCDJd bai/UgzHAqgH0KE8i6zm8sSU0/4s5FB3jvvqfsCsjkCv3EPmOP5o/6fiWeoS5HFappECuG9zpVo2N sMBisySZfzOCUvCGxwiPCRERS0bvvDG6T4NQRManmuNEyWGFFp5FR4NjXzlm6p4330y/hWtdN16Jg KZLsOkZQ==; 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 1rFFfV-00BEXI-2C; Mon, 18 Dec 2023 15:36:34 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/17] writeback: Factor writeback_get_folio() out of write_cache_pages() Date: Mon, 18 Dec 2023 16:35:49 +0100 Message-Id: <20231218153553.807799-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 3347840015 X-Stat-Signature: dkehmg9bc6ecqk1u9845ozh7hfqf76ah X-Rspam-User: X-HE-Tag: 1702913794-280501 X-HE-Meta: U2FsdGVkX18mnoa0TikPTJF+luWSCVyiclDynfecl1iSYfR+mMVss29fz56NFAs5mRnxkWEgQrugqrUVPQkclQQ/jWaFIMFWE7sA2K4pJiJdDi3GEbpbZgrxRHjkhx0rArfaw4q8Gp/Nxz1/i/qBOeIe/9+Q+1BcnJKFwtHHctFzN7GIOBFN3osqpvy6p7Lk7GihpZc+RgpEkSNU11fdfvVt8rhKTdiFaDBJVkek/Eb6+jBNtDfEAL4PXvfb5Y5/GFHl385ahGtYQH0fRMbaGTAI+M/xS7MXXKQTu9mRhirjsDhaLeRrxxKzzL12AOojospHQCeM0nMol+rZRF5/d7nKY0tALnjnN31QEucV3RPtnotZCzCWEVjDkrI577APRIpIKAUwq1yeYUCpqEvJPC5a/fzC+bhZhQbNhUxXZ0rYk/PmpLDLPqCrgATu1qUCItQ7YpFFPSdXFGGgBVRqwxJkq/3+9MuKHemyFk9YbTJlINP2XxjC+ZUS15USv07LFUlK07jFjodrlg8ZMf07dk1zsKjW9awVdL1pO9Re+sQ+4YvYk0KR+E3N7QzO9Vh1nyZZymDTGCjjOV6peIy93479rsJVBR9sPKVTFlMF0V+iUPvxHx5+uau6Gp8yrK1UH1wNq4YVNPnS1wKAfgsLXlljKD+iNQc33tTL6WkGw7dmU8Rl6qsLPEYt7vVIQGAdEYoKiDVF6VcajVgnadAJ/ABv3Zsa7Rpbb0THS2r0LoVNg0AXKDtoayTFKF9UoMzdHLHqCTSO/EEFxCZFLNekeo1KJXtXMdQWqOAi6LguREY3ZrOKndEK6xuJewxwyr9SCWokmuvmjWZPrihgoPqRAeYkhLARP+wSz/NI+41ppo4xGzXT9Yc6t2SEJ7uhAlDDoVq+g27ahzR1dc8JPBvQrKPhYDWf2NgEMr7a+L7h/0SJw+3OkZk9rpGU35jmzepZ15glyOk5xuxeKNfWLLv lt41cKVd R/UgfT8zbZAqFFYXiP+eBIw/lrqtC3VAEqAcDpxVuW73Qk+5knFaxF7wOlA0GPE8Sy8px3jgsIyTU3Xf5ggMsvb9OyJDrsSRBSusiz4HjtMefLHx+HApS+BGqCb+D/7X+BUVpRRvj1Xi4e5sDM6uskfPbaChm/KvYZJWd55OxDz0DYvihj8nxAzeBN3EPnfbZbTn8Wo8wwbUjwuNN3FKYeDRMHFSlEPv6hZGTCPlX8ell5LPdolag9cFAglpFrWoJTEdgdlpaB+3iJlm5XmO/Lf490bo05Te6sVNS236wFdN/A/DPCdQ5BJ7gOSwa5cy2GHCNWM4iY7OmXJwCpMenYwS7g7BQfJ422EnMdQI2Ltsfz3mv607Sy0lO4MhxZTHNGv4cKmo0qKb4jfQOEF59y72gqhb99Ng6W7H4IMoxF3pbBwtRCXPFxxjRk72qWRCCpkIb6ysmRSA3dpRghDs5kw3IBLzPNaC9v2fc4+dJcH4lwll9JfziFBeMPUDxod+xYL6+H3Ejq+utSH4= 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 its own function. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/page-writeback.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index efcfffa800884d..9d37dd5e58ffb6 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2442,6 +2442,25 @@ static bool should_writeback_folio(struct address_space *mapping, return true; } +static struct folio *writeback_get_folio(struct address_space *mapping, + struct writeback_control *wbc) +{ + struct folio *folio; + + for (;;) { + folio = writeback_get_next(mapping, wbc); + if (!folio) + return NULL; + folio_lock(folio); + if (likely(should_writeback_folio(mapping, wbc, folio))) + break; + folio_unlock(folio); + } + + trace_wbc_writepage(wbc, inode_to_bdi(mapping->host)); + return folio; +} + static struct folio *writeback_iter_init(struct address_space *mapping, struct writeback_control *wbc) { @@ -2455,7 +2474,7 @@ static struct folio *writeback_iter_init(struct address_space *mapping, wbc->err = 0; folio_batch_init(&wbc->fbatch); - return writeback_get_next(mapping, wbc); + return writeback_get_folio(mapping, wbc); } /** @@ -2498,17 +2517,9 @@ int write_cache_pages(struct address_space *mapping, for (folio = writeback_iter_init(mapping, wbc); folio; - folio = writeback_get_next(mapping, wbc)) { + folio = writeback_get_folio(mapping, wbc)) { unsigned long nr; - folio_lock(folio); - if (!should_writeback_folio(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 Mon Dec 18 15:35:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497168 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 AFC3EC35274 for ; Mon, 18 Dec 2023 15:36:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 015986B0085; Mon, 18 Dec 2023 10:36:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E91DD6B0088; Mon, 18 Dec 2023 10:36:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C96D46B0089; Mon, 18 Dec 2023 10:36:40 -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 B88656B0085 for ; Mon, 18 Dec 2023 10:36:40 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9524EA292A for ; Mon, 18 Dec 2023 15:36:40 +0000 (UTC) X-FDA: 81580341360.22.219BCFB Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf12.hostedemail.com (Postfix) with ESMTP id C5B864001A for ; Mon, 18 Dec 2023 15:36:38 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="n/KNWRHz"; dmarc=none; spf=none (imf12.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913798; 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=lOde0PGi4Z6M7IdLHCKfLkz19eMYDieJg9XbB+ncAEo=; b=P6Z73JPwPfE2KJJ39gh2ybU9DUEtSCMpfNYqVX0mwgFbKT8Vk3E0YglM1SkzGrsZB4jQD1 zelZUZqMJcRPoo+Zz+r0XBHKzTR+CN/RDAHxAmMFYLaPJ7CaduNEFx1+qToEWfw4GPHkPX IhEKljCn0zpHEOpvf5axHMJCJuLBV9o= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="n/KNWRHz"; dmarc=none; spf=none (imf12.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913798; a=rsa-sha256; cv=none; b=raksNgdSUCZFy84ujG0mAvu3TN7lcvCuFtyB0It/GtHukmnzJWiEIZ7DLwb0akpoqlEjN7 AtCnqAcCv4eeKt29mXz+2VdxX5Thhfbdp/XkxOvGAeHGX85T1pUSIKag8oitnSe+eGiL1o Gp9LaAIsvi0uUqcwQ4uPSkS/K7pAZ/k= 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=lOde0PGi4Z6M7IdLHCKfLkz19eMYDieJg9XbB+ncAEo=; b=n/KNWRHzl0Vuw7qwMs1UYzUUD+ itAzOZiMXFPZCbTYFwBvFV2uQpY3ZdylXEIWixZXWjNKLUCXFSQ57YVIbXC8wJScFm28gORoCP+Yi hZWQK8/6AkPBsNn7WjAHENXCNj+5xS1xxxEnfprZO2gzyaxOtGqdUqb9VYPWGt+1/ebCeTj52bMkV eEWxwgWKuQvWNHrgQpzFNaQqNPqCqaSsXje3yLomMY4ATq2rL67xi0bZijgTq8eTBV2zniKCTgGjs 6yp0+AJIT0zWHgTOFWE15g4u0wKKgOI7K7XRNoilnqCmsKHJwS2V/24atVv67qSQSUEtUNZH/UU0Z vEC8Dhsg==; 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 1rFFfZ-00BEZB-0p; Mon, 18 Dec 2023 15:36: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 Subject: [PATCH 14/17] writeback: Factor writeback_iter_next() out of write_cache_pages() Date: Mon, 18 Dec 2023 16:35:50 +0100 Message-Id: <20231218153553.807799-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: C5B864001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 5914ap7z6o6ueisuj3ktwsnffxmreeq8 X-HE-Tag: 1702913798-839381 X-HE-Meta: U2FsdGVkX1/kPHyF2uNOR37TulBlF2XSqVWsKfd2aoxVuQnxf4Ia2lW6ZycVoOiPOomwbo/KERRUoyYl03CeYYPyAepQTC6kAkX53fIa4Ujlg1BsiTOCZFfFY8g7EtLXqP/gWMmZ5/6BcER/ot0iLghJJ5Yv0scHj94h3Z6HKR1R/q4VHu9Ul41kUUMPEBAJMAHmrnjbdXd2jsSDjj8EhqChTfxdFbmjQeL7wYWLDUhVqab/vhKqxh207aC3n1dVrPIU7Jvq/VoeSmBZPuetdsegWvLyf7Ppk2bvy/VX2VgSC6L8sh+AWblt3p7LglqF+P2C44N5PQSLhx3YIBAlV+ySCp4+dG2B19FTPFuZl92LRYWDtHgo0EFrT/vTOcxJWJ3FvD6YwYUUO0MvA/fMd06oX6EHTTSJLjiYxnPnWoc4uZ7sDyJey2qT7nHFDoGKcUHywdUQfIt5dUA8lIo8gZy/L77zGbCdw35VZ+K1jsgUK4xw5pRJLas5DSc1xqzK1kSmY2osn2kSw6+u5vhGzRGGgfFyqIcmq+ra7W7pfaDCrjCAyHu99YWYqYX+rRyBaC/HDW5w+dB4uKR9GwDuptl5EYJ74UNuUPcrXdZpUK38P+BsbHZPQWTDcNeDBfZJAfYJzLxkh3KATgSAB1DcjjGCkx51sGG5fwiQfgXkoh2Z2q7SoelxgFjldd8hoixyLZS/aXeVAJhIEbJFCeq7Fveg9FWq+qhrpBSxDldkJdIZ0LC8K06K58VEu1x+LPNDcAClKYGJ8XN9vH+0LVXzS4EFv0sSeSPB4FqRc/gakT/DX4OM8YtluM7V8mHrhfkh344iqYIpD/SMS8or7fiuN0o8KCSnfpc16pbFYdDDAGHczpioqVTP7k5UpF1yPmxC/q9i3jwZ7zEC2MwTOTaR+tm+oH+iPJHVTCamcexUNOEhGgF4Dm68ypmVUI+fbldciZ6N2T2lnSx4owTZQlV uAnmIiMV aFvAh85SYfJlDYlSjuP1ed1XONaI/RD3CMXUee/Ffw3SfqYpo9FOoOWzn6f7G4jxBBnVFNkKnDXGwqn2NEN2w+EOU3DBbDzhnPIv3qV6iSnjzJWmI1fhFIAeBL9hSRN54YUmUhp+Tz/xxfyGMy4uRjDVcMB47FklR4Bp16QXgu8upd9ialmmHveHLgjdJ6SvmpcWE2mz2FSsTTuZBLiQfYUCBpsVDFRUvAQKbtFX0EOPR/IBaVz3a4fH3CwPBdGmf8glXEGfXv14NDwBMceQst4kJoQiFenU4ixSt7+EMZquUqiLRxy2YE9HLFUCb4F2ddBnSQ0FxiIGOM7rOIXIo7eSTRjtWOJYH8e/lkOybwVU4A6XolwW+bR/7scJSqv3nz5bEVLP4XUU2oOoJzB4+HLo6k1Q4/DLrCQyhXirRFyMHslaUp0/kuiOHMZzzD7jwPLNFkZdIDBzHq4gMoueYai0zq+ndf/C+7hVLHatF0pvHLwKUVcIOBNZ4E07JzjWFgoLvpAn6Jxhbv66EFyW0J2Nk9GreDWwngYJmEGfdw3mjK7fS0HGmHE+rwg== 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_finish() to return NULL, and 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 --- 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 9d37dd5e58ffb6..0771f19950081f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2449,8 +2449,10 @@ static struct folio *writeback_get_folio(struct address_space *mapping, for (;;) { folio = writeback_get_next(mapping, wbc); - if (!folio) + if (!folio) { + writeback_finish(mapping, wbc, 0); return NULL; + } folio_lock(folio); if (likely(should_writeback_folio(mapping, wbc, folio))) break; @@ -2477,6 +2479,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 @@ -2517,47 +2559,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 Mon Dec 18 15:35:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497169 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 7DDC9C35274 for ; Mon, 18 Dec 2023 15:36:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82AAD6B0088; Mon, 18 Dec 2023 10:36:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DADB6B0089; Mon, 18 Dec 2023 10:36:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67BC96B0095; Mon, 18 Dec 2023 10:36:43 -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 4E1196B0088 for ; Mon, 18 Dec 2023 10:36:43 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 249E840AB9 for ; Mon, 18 Dec 2023 15:36:43 +0000 (UTC) X-FDA: 81580341486.19.A46D515 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 6DBBF18002D for ; Mon, 18 Dec 2023 15:36:41 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wIxOQSPZ; spf=none (imf24.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913801; a=rsa-sha256; cv=none; b=bIqFBIgBfqVHrDHV3YbFzqL0ZTgRIt4o3gKyj8fd4RXN81mnueR24YCd8MIseRWhRQ6V7a hCHyuTeJST0qlqSUGO6MhUMXq9FX1fhogD6eW1TO7927hcdrh87Go2rVFPOtXmN6tZ/eGJ iKw1jkfS/sinH2gil5Ciq0QrX5YlDww= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=wIxOQSPZ; spf=none (imf24.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913801; 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=b65KMtlYAzH3EUkpAxud2ReFVr8IHYHtgd3wSTH/RNI=; b=PrK3LJFVq4ZvgUFQxVPL7x/G9d3bmJX4wusbz8fRrw2C2TZafD+aABji/ZlKn4sPAUWTE8 FKdVXomBvg9ZONFnWPeEdivbyI0A/sCt0CmCqaC31lzgH3HwiMBK/Yj6Jr7c4c0gz9ReRK PgUjTDBH+Koe8AC2GfRbfdN2atWTnX0= 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=b65KMtlYAzH3EUkpAxud2ReFVr8IHYHtgd3wSTH/RNI=; b=wIxOQSPZ9QaTybwrOD9nlYUkRM y+8Zb6dvZntvYiEKJllN8zuuGypcmjeu7cPyJWRRE+Fi8fVWQFfIPzfFljzQWA/7m7EebXSjpuGby ZxBT7WwEcpjYBrspB6z1WTQYVpyBXVdki2ccUQzksG71f2mGj6xHmzzSn29+2TiUT07EYabtmsSEA yjpaneMn2i1b5z0M+EWN6cvSKICP2g8eokXeawjJmIBfdsCN2ms6qC+WjksIXZgx/AY0iZWo/q1dc q1nJKDQPAPGC8P8DMR1Hb0mCPDuXhcA8+sfDzv9zFVilbUWOxiWUrz7F6UwF/edDUhPjfpeF9mZJg gxKIqiRg==; 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 1rFFfc-00BEaV-0K; Mon, 18 Dec 2023 15:36: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 Subject: [PATCH 15/17] writeback: Add for_each_writeback_folio() Date: Mon, 18 Dec 2023 16:35:51 +0100 Message-Id: <20231218153553.807799-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 6DBBF18002D X-Stat-Signature: czyi5asrhoxzxys1e6qynncgqp9kkji7 X-Rspam-User: X-HE-Tag: 1702913801-244053 X-HE-Meta: U2FsdGVkX1/qGw6G+Sf1IXhff3JzB0ZXHfsaOhyY5qYcHqGbvdeGUYapgOGdkoAtcbo82ZSlY77svh0n3quW5ATMifzffhuLlRCBDiCfuP19DUMn/mqYo5ydCP5iuOuoRTdMn8A33t7XlZ2OeAcGb4eBtRAQkMlf9s/BsBJH/JOD2l2j5J+FEtzEJ85+EjgzffrdGBo680ZbEiRRLZy2vC/eWIm1lrzVsqzAX1xTWDsVV5yquoTnfZdEmoJznylZH22aGodHQjsXbx1viHvPxmlWNEJAQjhQ4nUgLcFxU1q0dVe0Js2f4HyqZqe12r6ftmDOAQU3SBb1Ov+C1hT7UybJbUfNc0jQXHhxI/hKRuPfgLKVmBud5dbH9fWXbKIHkRF4d4YBUi1dAA5xbZEY4/v+jYdwITtUlySmnuSCqXrhV3b9tDdKckbUxbXSHHJMbgoS/fVyMilbwd/xuV0YRpYshnj1GgHEFxGNTBRns4ZeMYQSbEbDanSMxV5Vu7VAqELR5HtOkowq+G9VXqIkjBILa4xTUqR27jbQ9ddnUPglchXXmPel2YgJ9Xrq6WTKtr848vHWjO+cyHwHw5okomSKgIYrbwK+1tPvX+wU6apPR2KEpUjMEeoa1z6AX2Y4/3AzW0vZ7FuFZPGsxQrxIIT/VNREa1iUh2OJNIPoXIi2uNNoTYcFd/bcTs2tiITXma/wVbuqDZjS6FJaKa9bV6yug2bCTGriKy8N3pKjRs60iK7hKsYx7tweYT6ifpwhYNnbQS+U5JW/XwjuzZyNsB+lMlEOZ7eYLfvDqs0QJD+EljnoUQLmE5CDG8EokiVXxiP1m52JJJippItaxZfcWoVmXqIq/5JZGzCkVIGVu9VMQlEyfAt+WRtu7Rb2D1scgxU238cf9hiKA9+2NWm3x6w2xQV0yjaRcYruRgT2UWAXgKuciH63OczYIKPOYr3FkSm9EOpeK7qKhelZShk fS9SimnL L1dSTGaTXUTxFVCY8enSE+DQS/k6Xt2C/gAc87OOY7HMVSB2yCv9YoByVonDI1UjvNpk5WbNoEzxxAtCQ3SEAlTBRg3jQlQOIdNckN5qHjMHequ0YHao3a5oWOd8NaBvDMNBSUfckoJCRBxOO/IkWk9a6tPPjE0BnvMQHINXPU+hFuqDJW9YtPz7qKDNww9ocPXp91TKyARPsvPcPMeFqcss4l5Q62ZvEHaYSiWcUYhFuh/2c7qJU9+iMiZG84JfIgaYhMPiqUFVp4lSL94jaBaGeMEBSh0BlcdtPF1zsJgiu0U2haf0lzycmjd8ASzMUnGKvr8TejfHCzXqpQzm7dsowMb3phDqok2Qp507gmss0mmQkN6hSJl91ZEM+gpeGlLwyIRXFtXAC4YS8XxqtBu3K8Ffhnu5uPbeyOCqtma19/j5uR9q9afrR5eatq/hbYlCvoplBKKsg3byu5AhzM/tJmvfKtOlQDuHn1X0WVQzUupilaEwjONAa7/ZTwEoJ7xHz8qdPBOHABLM= 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 --- 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 0771f19950081f..fbffd30a9cc93f 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2463,7 +2463,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) @@ -2479,7 +2479,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); @@ -2557,9 +2557,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 Mon Dec 18 15:35:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497170 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 77D70C35274 for ; Mon, 18 Dec 2023 15:36:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 236966B0089; Mon, 18 Dec 2023 10:36:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E94C6B0095; Mon, 18 Dec 2023 10:36:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 060E06B0096; Mon, 18 Dec 2023 10:36:45 -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 DFB756B0089 for ; Mon, 18 Dec 2023 10:36:45 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ADCCC1A01B3 for ; Mon, 18 Dec 2023 15:36:45 +0000 (UTC) X-FDA: 81580341570.19.D523C1D Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 0DA14100015 for ; Mon, 18 Dec 2023 15:36:43 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LVqlIw7q; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913804; 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=KurkZBc/b3Q18ZfxQxDEcSa/TUrlUIiFySdkJrxwQjU=; b=Pq0kHBlxZ+OSTheD4Sy1xNjxryiBl+5NS1s1Q8CIG6kWVHmucDuhCcPRpHYpwv53dIFA39 JYgOEkSnKPHaZ6oAMhO1MSCX4QDT6dQa+c8ijso0TH/URfVMv3HpPmmCLdpZw/x35pQjWD spQSY0zVImFLGKWVImSInZTnG0Ddm40= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LVqlIw7q; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913804; a=rsa-sha256; cv=none; b=qLlbjE215LaSFFGMlc/jo842XpkgQb0ru105qN+PfdaTdPp76rqUYSBS0pqoiQNStp8Xy6 mqHvoqy2Hp43Ww0X27OjESpnZE32a+/k5D6fG7gILe+6nvQsDpcajPOM7sDs/rZnM9wfe5 hoM5FEJfxVpD9mP0plJOFjjc9zQPYsA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=KurkZBc/b3Q18ZfxQxDEcSa/TUrlUIiFySdkJrxwQjU=; b=LVqlIw7qs07E3gyDPGZmtD0XyP 0J7DxBmpXttZFRG+IwdLRoQ210NJqeMDCPwvx8pcytOPK4WaPF5iALq+Gere9cAAFy5YHYuoayf7o WKwlr5cnMo6YK/xL/Cid/5e4NHsvCFFUVnAZk6rEgRm6ta5km+tzbpG8tZ3u4VQX7YjwvdIvd9La/ UUs/2czN4LRM0MbYNCm8auOK1c94pPR2Eurr2Se1DpfMw6swR2Hs3y1wij2cA5jK2l4wHgZychHBa Linj7FiVDQk01OoYZwI+pB0Q7q0czwR2HmdVCNnS2czPrextgY+XsAC2CLKMbkZM68/VA3sMoQD2r mAGHD9Yw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFFfe-00BEby-2D; Mon, 18 Dec 2023 15:36:43 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/17] writeback: Remove a use of write_cache_pages() from do_writepages() Date: Mon, 18 Dec 2023 16:35:52 +0100 Message-Id: <20231218153553.807799-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 0DA14100015 X-Stat-Signature: yq8y78oo65w3c5b971gfdjurdix35rgi X-HE-Tag: 1702913803-53822 X-HE-Meta: U2FsdGVkX1/al0IgtCww3Ua3DzKkoZCIk3lR/DuBH3vwVXuqb+yS2/uXvsnOIqqy9BY4v8lJTPsy+OCNObhFZ+lc+FVtv+m9a8ptfGwaV2vnJN1eXCaw74oS/ScyHp+trk6UIGM87e7yr5fCJ+1IDkgmlTGqWzd1YWxFd/51URPQctufMDyxZAPfXyzUQBOjP5JiyzUYgtZ8MUmiMIGaMGEaRvOuWYITQP9EX5y0qPjndv8TYf926TG4pBeWMwlqhUOguCoTITtUjV1jjlGwTH0MRf3zVftL/RRZ1NwW/AmAWeazTHadt/O31QW4MgZsS5X12nsoPBuf+Eh71whABsos/FgFvcfU/kH/3E54SgQGS+CdU719Of3fcGvggDjKBDtRuit1JtRL/5RsvRoKk+ZzmkQb9ywRF4f4DmpcvlRcN8ubUaXXjbNH/pTZeEZxTTxkNDQDytTcF+V8gN6LWnBXoOD+l+q6/VrELFP8Z040k0ixfcYNL1g9IkUcw1W1N8vmQ0aCo3hWvFfuPsUJQvWhbZPisWQSnNg6uRbdCz23EGQ6JH9Hn3aA08UBmFb6j0+vWeeYS3MGtF9HHipkw2a+DVdGp0qWzrcWTyJY7JU76vLe029KI19ZG+oW7mD4nAy4+N2Aq8nFq8qr+Jso3aTKMmjheXYWyJh2nekIjzPA+S4EI43YDs/IT8IQ5qidIDDd5a4QXJohkY3Wlj4ny4k6zy5/vPiFjbqZc3fouG11tbidpflk/44C3AxZ8DTFdn/+1u++M24R2xQnHXXlD12v6K54jvjuLmd16MS5W4yVvmsRo8bGighTtdwlH/SmEwjpExzP6PUjakF2/H5YLArYXzeFWgOwF6Gp47c87sz8e+KLi2vkYGy230fMlk2Erye/blSPAfjNBKH52+D7HCBUxPDO/J4Osu+e2r3haEDaM9OesVUjG6W7dcnztBzGY42VpnSGChncWYe9ABi lhrx3YVb rww0GRFM3vRdHNKEfc6jn3BhGLLOkqexFCSpB6LN/W443hS2BkgztXLovrr+PbdHYH2U9dRIVxrW0DhjvMlpHJ3cJQAxqhwyvob8oAJpK1rKoAkDoV+PKrXjo1kYjmJlGNuJT+0Ej7fTDmWW93vzZgzcLsuZmzza9je2Ig79w54qS0I80f707HQ3ao7fAFXa7SIUXiKusUUfiI3FBEyuJ5iBuPAKAK7QB/sorisZ0hedrDZmHd/rETGFfJdYNDr1ZFfr7/JhhDk57BQ6BjUWfoAjxw0tnFTlihsDW2RM6i9V9+x3R+LabQHmg9EVYaozRVqQHFV+yBhEwogoqLfGv0d0WnUVLsMK5mHRU8oA6xyr5l98axa8jTYwfT9sX8RToVatFMUbI3/4YlK5EeG7kUwxND1yO7H6IcEgHtYG8T/xEMu96qDLybNFcZ0e8lQ2LHNUIRXJr3//9gfwO+hTOu6jJ4BfLDhyasRDFnXmvb8FAetA3C208QGKGcFfyhnpBy+dh48BVDmCrT/M= 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 --- mm/page-writeback.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index fbffd30a9cc93f..d3c2c78e0c67ce 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2564,13 +2564,21 @@ int write_cache_pages(struct address_space *mapping, } EXPORT_SYMBOL(write_cache_pages); -static int writepage_cb(struct folio *folio, struct writeback_control *wbc, - void *data) +static int writeback_use_writepage(struct address_space *mapping, + struct writeback_control *wbc) { - struct address_space *mapping = data; - int ret = mapping->a_ops->writepage(&folio->page, wbc); - mapping_set_error(mapping, ret); - return ret; + struct blk_plug plug; + struct folio *folio; + int err; + + blk_start_plug(&plug); + for_each_writeback_folio(mapping, wbc, folio, err) { + err = mapping->a_ops->writepage(&folio->page, wbc); + mapping_set_error(mapping, err); + } + blk_finish_plug(&plug); + + return err; } int do_writepages(struct address_space *mapping, struct writeback_control *wbc) @@ -2586,12 +2594,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) if (mapping->a_ops->writepages) { ret = mapping->a_ops->writepages(mapping, wbc); } else if (mapping->a_ops->writepage) { - struct blk_plug plug; - - blk_start_plug(&plug); - ret = write_cache_pages(mapping, wbc, writepage_cb, - mapping); - blk_finish_plug(&plug); + ret = writeback_use_writepage(mapping, wbc); } else { /* deal with chardevs and other special files */ ret = 0; From patchwork Mon Dec 18 15:35:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13497171 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 4EE3DC46CD3 for ; Mon, 18 Dec 2023 15:36:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E28A6B0095; Mon, 18 Dec 2023 10:36:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F4FA6B0096; Mon, 18 Dec 2023 10:36:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BC536B0098; Mon, 18 Dec 2023 10:36:48 -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 261F16B0095 for ; Mon, 18 Dec 2023 10:36:48 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 05316C023F for ; Mon, 18 Dec 2023 15:36:48 +0000 (UTC) X-FDA: 81580341696.21.AC894C1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id 67FD3A0008 for ; Mon, 18 Dec 2023 15:36:46 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Ta/ZLMIs"; spf=none (imf25.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702913806; a=rsa-sha256; cv=none; b=0OKa+A633rC3wf10V8SW9cyc11lmOAmTZ2j0AY8DLkgEEVeootC/n8wHf+7+ozAvA9bzu1 zSZfI1i8VK4WNWdS+0KZWv4oL7iXNeV9c2VzY+3I0ja3cONnnma3WkdXQpooOsD85U4JED VGM6w5f2TJPzDH67RlshOuTWcYRzipQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="Ta/ZLMIs"; spf=none (imf25.hostedemail.com: domain of BATV+09f18f96a25a69770120+7421+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+09f18f96a25a69770120+7421+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=1702913806; 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=Yv9NEALRhhPVlldz2t/Fuz2oV/CBEjy/kwNcSSKy2c0=; b=7qw4tY/McIHwpsMFwHIgXOzUPV8ThLMq3P7GoWDdQ8CE4nS37/9X2/Qaj/uuYnZcLj1sja 83yVAaKxFoJRU84ar/n54b60J7jDjYNxIqQ7UOaIsFd+/u7NdKNNbi067h85J0qB8AKUP6 FoWN5QGjvy7kaN/30lPdhPrEx8jxTqo= 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=Yv9NEALRhhPVlldz2t/Fuz2oV/CBEjy/kwNcSSKy2c0=; b=Ta/ZLMIsSHqIp2kIeOMq/K8hB2 zFZCr1dwmBjJEP7zd40V7gPNrS8Qq8UdpAP4HvpFibJa7PnELaGjiXIkJgs9LbZfhxzMLiZxR19/Z ++ITeDX1dp9VlPnF7QA5rPA1D7yzo/KssnWGNQfL8BiIiooj5jmwq4zPBo9jPWNrxYSz0+JvXqQzt PcEtGKUqDiewhkGM0ONfc2onosXMtAAhLVUhezlbdzmUWnT4EE50UjXRKfAWvUhEtjA4PLGZp0qYc a8UXrSBukXbauIaVN5VwADLcnX3Mq8vOHhtXGAGyXTGZLBBIcMALFeurlzETNild+N+rdYR7/ZYiq U19LWeWQ==; 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 1rFFfh-00BEdJ-09; Mon, 18 Dec 2023 15:36:45 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/17] writeback: update the kerneldoc comment for tag_pages_for_writeback Date: Mon, 18 Dec 2023 16:35:53 +0100 Message-Id: <20231218153553.807799-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> 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: 67FD3A0008 X-Stat-Signature: xaujqqffj41ybczqgegr9ts7198xgqbm X-Rspam-User: X-HE-Tag: 1702913806-223742 X-HE-Meta: U2FsdGVkX18Kjwlohx+ZgEpRD9uvW6vQPt++TXZTZC1qxMQ11rRWy/b5eTvwGjeDMsE5qZOzkmzFjgK9BPprPu8AydsTdX2+lAMKPpBUN9k2oUD+TdcipY3dF4N8PsyLjrOsn0DEmywOn8xYvlt9tEhz8c9+HY8bzTL8j4PTvUUFIpCNXibnOFvaHAb/ZIl6Wm8Mmo3X7B+wSo/S3Uz98HNowZNkerOlRAB8DARr5B5sxrlMLhDghY0/duFwVfW+wz7fox920iOZSECAikczUfftCbGwTM58mvR0ppP+6EPS5QpPkVbv32786y7+x5wNf210m45Y+6YeqHl/khpHsQa7Is2BaevuGqkYXs6A9Azc27uMY5wIiKhgAGwktI92OtYbLnMAcXf9GsZYWA44oM9WNm/BL4T+Pt1Pml14OijSlEMb0tApKASsRTvx256g+dDwSqI8ItFXuVVxpJ7pBHQp+d0EXGSUE6isYhYbv7bmW+Wfoxky7bgBxhItL70zRBbm5kX3Nq34IwIPgWL11k4fg2ikSCe4gEgpUaLaxANun5LCYms3roCCv5YblYPmX9plrp5Z3EpZDWfUiA+KaAzStRogQ6KGwtF2Tg5qcmvCQoika7LbZqQjwW/q+6nkTo9KhPQwt4pPE9Lzf6/vmKi+6sgzHGu7OVaIFLlBij6PCxC24gD8/WJmbMj5Hs4fYT6j8p0ryFeysGecYkdzEiqv8yf55Il1QCNqBrjXCJiKF3YffsEw8Efx1MRAu4NoAuSdyhCm/luGqf3QDRiff/hebGFhZv++mneo437jwgaCcNI82P4eqGkjt5sRIctlX4qPEw8oA4MlmPHXVIxlrCiLr6DERfZjWaS0/i7AtRELQYkN1ur33mYtCWRu3kfaTg+jVNEWwkQo2S2YmQMm+wCogARQqR1Sk4Se8fAPZrweVzEU6Iny0J0Ss/3I6rZuwI4Di5ZmpoFZLkuBr8q smjQNpDG WtZAEaXW9HXcGe7ObPREJsL/JNEEUgIIFtGkCaT9opUE8TQS/9CME5z1Ujug+4scLO8/YJlDd1KcfmjR2OWnjKSuf3ltzZZRcQzgMbUsJ8S58zE7ul53FF7VSwY9whn/Q28riLxRGPPtt7C7xcSD9wuYmx7BiZJLHgkGEpx38yvN7SXxiI8aVVC6EQ7EVjTt8cFpMhHIhd/Zkg3q5SxxZDL7xiepfdLjlz1ZYOg0e/5ng2UOZO+1ruttLqROszag7bC+6N4RxyLmg+6jzKo2oS9paxnAUqDZyFqWpDZwnOPKxqKi4Y298G0b0KbA6p/2yuScSebeUj0goRcF7T6JrATYFjuAN15HYtqm0LvuPzoQfaD8EP3iG9kPdba7J+8jUHQ8rRSrP/5b841cQYSuL90BMJEqtS786kAwyIOpPFZ37qOGUw5D6bJ0i9wIIWGGZhlesxlDNZQLfpxPoeBRaiC6ZCzOCroa+maXXjAAHKbJvx5g= 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 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 d3c2c78e0c67ce..bc69044fd063e8 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)