From patchwork Sat Feb 3 07:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 196310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp1041381dyc; Sat, 3 Feb 2024 06:21:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKFR0T+36zWv8AKmfv5mbIBF3GsDDSTL6SV9VvUN5zWM9CSt4e4mXc4T2frG5Nfes0RHQD X-Received: by 2002:a50:d59d:0:b0:55f:c4e9:60df with SMTP id v29-20020a50d59d000000b0055fc4e960dfmr1487300edi.20.1706970080196; Sat, 03 Feb 2024 06:21:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706970080; cv=pass; d=google.com; s=arc-20160816; b=KUhUsuNz4Bu6uiLtc/oCJ6QRS67ue8Hkq5Un2mw3vwoPIubYZzDKoS+KXlSlMh06rl lwfGYu7phauJL7vYS7NlaERe25L5kseaqkSKPY9iAAnByHIHYK/KvUtIFz+vAMSBFmqN Q2vDwryE/6/2fQah6EohUT8nLxQMOTBpW8r20A+o1QPEhFbFYGOwnKZH9hV4aKqGAEu3 C3SVUwoddYuaEw7D36yqZjs6hthpt2IlswN2IxryWqTKoSx5gk+AJUx5GHxT6KlUfPQP 4TdxBmxhxgvWNygZs2WgoPtjeLq/dJer31AZFWjryuf4p1/AIHVQlzvJgzwtor99okyE 3m2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=49fgiBCP04epsyHu4VZLFhJdGCRmLlr7ZEyZXKDtz3E=; fh=3RcM/WaoiZdJPBLsdLkSpJlGlSjNPivoQLqnWkUn4XQ=; b=fXPyJBVvhYqUQcaGHFZaSbwfhLp6Rk+AtrTMAeksOQFUFXItA+JC2k5JwyA6pMKg/6 WDQ/E1FUKE4cEcksxG3fMD7xHCPiuPRmcDPLeU4F6GqSMyEXgbYvyax/fuESKd+PkAB4 7IFJEvUaxg6kG5i35I27ZS+SteGX5l8NpPO8llOQgBCwxD/q5WSMJScByPnRpaLgGcdd Py1EX/nACe9VRV5uO0EGnqIWuCxambynAbU18vQ5MUPU1mQOo4tpGZ9K+Tug/L3JUAhG mpGSrQha8iWqCILqc1QYHAEpekhMjJGdipyD06dym2ADmhdQ6JeQHHfHHKzBOTchpyCi 7l3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=XlUtYVzv; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50952-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWtew1WclgAm4BvgIG0CwOGMuc4bTXG93wlPF3SCKEja6/mS7WHeHSNcK+6zRrFyR/QVEt4P9KT4oD5MVSC1mnVxFBOAw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eg10-20020a056402288a00b0055729eed820si1850931edb.37.2024.02.03.06.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 06:21:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=XlUtYVzv; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-50952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50952-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 47FAD1F29788 for ; Sat, 3 Feb 2024 07:13:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B443F4F885; Sat, 3 Feb 2024 07:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XlUtYVzv" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1F3E4F21D; Sat, 3 Feb 2024 07:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706944339; cv=none; b=XHXDnC2tMK6HkG9C9az0WgiuJVdQDDAP0UvLo+SMWNb/CtRg00SpZgFtpBBJnMwLSU/9wAkugPLrvHY6j/IuMuhfQJnTmUSDq8tI6Sx2hyN3+WorPT2fVde8pndQYX/+bM7SgnQ9yc/YGJj4r+SbhYzuM1zFnY7d/5YeaonGDRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706944339; c=relaxed/simple; bh=2Ra1DIMO+G/TyPfQxYqph8jYmrGnaJYGYnlhqWoTXnE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KGduLhuLAg/hS90YQqkMx2klUCmydvCIcksqcF8ni4TZTu3a48zxXi8WH2dtBM+0eYB2NQh5qedlzbTdw/zKS/F3khJdwGSvioqlBHJwLAAiRoeJ45VToSkSXkJ9rZ+gzOFmFp1wqpjNxGdJ9N3G9nAWv134SPtmILYBmA2RBig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=XlUtYVzv; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=49fgiBCP04epsyHu4VZLFhJdGCRmLlr7ZEyZXKDtz3E=; b=XlUtYVzvEHslYCkKcXL+kLKkWh 9WTLKLOLzxgooVTG83weTxXHEkwnSz4ybyLAeTF63d9qpkg5/3QqKB1r0fiaxhUO3cVx09NH+5Eo5 QFGjAEPz/oAvFBpRtC9I0fpdDPAIDkdv9qsZ/o2Yk6jT1RW6Z8Qoa81kLjYtsh7/LoSy3GUxUHyIz MQ0OFbDNGbmshBa1RhuYyufJiFWc9kY5FoAub/R7AI5Ep+JcunFwqr5QsPuqV2eofrvNuVUc7kq0H mfFJrDAX6yoOt/HhTtIfyWWS9UVv6ptOAdSuTkYnPQpb3GhIL9zWe/+GHCh8en4saFjCp4gzKTqae RAaS1RPw==; Received: from [89.144.222.32] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWACE-0000000Fk0K-0UzU; Sat, 03 Feb 2024 07:12:14 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner Subject: [PATCH 03/13] writeback: also update wbc->nr_to_write on writeback failure Date: Sat, 3 Feb 2024 08:11:37 +0100 Message-Id: <20240203071147.862076-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240203071147.862076-1-hch@lst.de> References: <20240203071147.862076-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789887858754886389 X-GMAIL-MSGID: 1789887858754886389 When exiting write_cache_pages early due to a non-integrity write failure, wbc->nr_to_write currently doesn't account for the folio we just failed to write. This doesn't matter because the callers always ingore the value on a failure, but moving the update to common code will allow to simplify the code, so do it. Signed-off-by: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Jan Kara Acked-by: Dave Chinner --- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index b4d978f77b0b69..ee9eb347890cd3 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;