Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2519689lqp; Mon, 25 Mar 2024 00:53:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVi8Wqcu9Mq5MOczAfp+Ew+qq3X9efFnD2Qz8OJsbSgndSU+E11K/o8Bm/hVXFtBQZRmH0cf8hV6bro6iXv5QCXHATMonXosFwSmmfJ6A== X-Google-Smtp-Source: AGHT+IE0k3ocOGipsTKsn8YxtI0gIkLTA+z6j2Fj/oqjQu5INI7tuWpg6YcEGvJCRCGZspHJbndY X-Received: by 2002:a05:6808:1296:b0:3c1:f1e8:ec6d with SMTP id a22-20020a056808129600b003c1f1e8ec6dmr9010315oiw.7.1711353186077; Mon, 25 Mar 2024 00:53:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711353186; cv=pass; d=google.com; s=arc-20160816; b=Wafj5CXdfwx3QFz5fLP+6qzhUyeKWiGgNN3BKBlGgfzZJkQ7EknBVKc1u/jlcdHZOM aSGAzHPC2+uF3SPuFoGrGKTSiXts2EVA4WB1dX68hTUm4pGblExOQP7ZVtimGhGYWXFi IKnSekPdcylkKCPs5cIP7h6T9c4i35iXMdD484vPMQnMe2q+BQs4Sv5pGEGF3Y7Ezioe 2a4ygfV9wYfdLeilVPQHLDfa3Oxqi0d1PasowgdFpQs+BdxLWTrOlTughWMOvS2OpFD2 nwiW80W74VW4ufouSBYGl+S+Y+YRYnvgLu6NnVzW7YnG5t6xtxWgW+x2YNJoefDHbgyo nOLA== 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=ENr9j/VCzDVO1R6gWOxi4SXHvdqD3zq3kKlP3QJfqPk=; fh=QgK/GdU0qbDNRur2SdZH0b4sYMuLEh1Fqi4K167Kt0g=; b=zJotJtrdwojh0Jhym/jPJAJNdB7uAJgf4b+myj9i9TPUGrjzyjEEe7W+vNyIxa2NEg As4A4jt30BvGyLyW4CRxoxdYSmoRzXuIN29x+x4KoJkb0zj3I6OpJq+1WCpmz9Ds8Yvi s49UfUDuebMcmNOQ/z4GCjGheDYhAVKAij5N0AtQvZ3DnE4c7fSV1MmzUHnFVN0mf0lk JGxdYBKAaBXDsvTfuE9rdVfFrNXLR2JULwFu5IbmN6N6DeLR+0Q3d76UZUsGhn1do4XE sQVTYrxF4DN/ueJjxm9CITL2agODM3siG+KvR+nBqvzIqx0DN5ZhKECI1VKVxdjcGY74 6yxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RUZI2hqU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115605-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y6-20020aa79e06000000b006ea8b233549si4637737pfq.328.2024.03.25.00.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115605-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RUZI2hqU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115605-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115605-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4EAEF294A2E for ; Mon, 25 Mar 2024 07:52:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E1F3130ADA; Mon, 25 Mar 2024 02:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RUZI2hqU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8E96E130AD6; Sun, 24 Mar 2024 23:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321354; cv=none; b=DzIsVTI9q1UhnPaoP95sX//jXv/gDR9uX8tgOzBqnx34+jJ502rBZkVNaSlzppnFtStclcV4AyrmXW9YO3GNSb3FCzUVjPP7Ak2Bh/BzB5DIGqjk60PXm+/UFtSE1h90DNM1ZTCtOGmAC8bnSCf1s678WsPpsZtHhRpbNMlVd9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321354; c=relaxed/simple; bh=jtxf9O/jwcbFCCjmh74DlbdpYuDebk1mTbL4kpKOfUM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MXtfhoNiV8WP0bI6s/CgC8bkeP4IAwiTX5Imyds2TyF3FwPHyTD2hRUGA6GepS2v3oiqwNckLuxPwv6zVs0QmutGaTx81HTmxeAwQlWWIUw6vHAaLWvdXIxaB+LHKyUaeOuipeuLLeqhhg9/4ZFR6ejoj5sGMtG6rg04Yffg2Q4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RUZI2hqU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8B45C43390; Sun, 24 Mar 2024 23:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321353; bh=jtxf9O/jwcbFCCjmh74DlbdpYuDebk1mTbL4kpKOfUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUZI2hqUONZUinqUSfBHl2R1pY3xEzgXGsxZChry6q1T3I4F6OzzdQKedZAF5lkej gInDjMNvOGCG/K282Fgl+uUnDziCmx55e5+Wtx+oBigp01yf9BfBe2w8t6wAc6FP89 xk82vhXT3uqYy5q6b1iuVlWjiaZZlxfc/xFFmxSlP0kimTShN8RNqJQOhuuv9iVnLf m7NiOYa2bsfUiCJvmzEaP05hnvWDFmv6MmhOoFgS3OT22C6i7axqYcN87cJbInvPqN owPD977icRCL0d4moawCulcldAyfEQ0ffQiKbzlueJ3k/R+joEU2HvW1rNRMxcjnfy s+0GydgOC82uQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Christian Brauner , Sasha Levin Subject: [PATCH 6.6 078/638] iomap: clear the per-folio dirty bits on all writeback failures Date: Sun, 24 Mar 2024 18:51:55 -0400 Message-ID: <20240324230116.1348576-79-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324230116.1348576-1-sashal@kernel.org> References: <20240324230116.1348576-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Christoph Hellwig [ Upstream commit 7ea1d9b4a840c2dd01d1234663d4a8ef256cfe39 ] write_cache_pages always clear the page dirty bit before calling into the file systems, and leaves folios with a writeback failure without the dirty bit after return. We also clear the per-block writeback bits for writeback failures unless no I/O has submitted, which will leave the folio in an inconsistent state where it doesn't have the folio dirty, but one or more per-block dirty bits. This seems to be due the place where the iomap_clear_range_dirty call was inserted into the existing not very clearly structured code when adding per-block dirty bit support and not actually intentional. Switch to always clearing the dirty on writeback failure. Fixes: 4ce02c679722 ("iomap: Add per-block dirty state tracking to improve performance") Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20231207072710.176093-2-hch@lst.de Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- fs/iomap/buffered-io.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 2bc0aa23fde3b..1c63e48230aed 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1830,16 +1830,10 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc, if (unlikely(error)) { /* * Let the filesystem know what portion of the current page - * failed to map. If the page hasn't been added to ioend, it - * won't be affected by I/O completion and we must unlock it - * now. + * failed to map. */ if (wpc->ops->discard_folio) wpc->ops->discard_folio(folio, pos); - if (!count) { - folio_unlock(folio); - goto done; - } } /* @@ -1848,6 +1842,16 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc, * all the dirty bits in the folio here. */ iomap_clear_range_dirty(folio, 0, folio_size(folio)); + + /* + * If the page hasn't been added to the ioend, it won't be affected by + * I/O completion and we must unlock it now. + */ + if (error && !count) { + folio_unlock(folio); + goto done; + } + folio_start_writeback(folio); folio_unlock(folio); -- 2.43.0