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/RnaP5MrpMwziVd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+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;