Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2359625lqp; Sun, 24 Mar 2024 15:38:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFighf2QzvMXpVm5F4CzXQ/9Qs1on/t4VoZFuTUaThAFt3C/RZ7PPa/LzjPpmT8vyvHHpLHS9sEodaHZ5ZKfp66u3bnARIYFySQH7ddg== X-Google-Smtp-Source: AGHT+IFg7KjjGTpLFJVO4IKR+MdC8txrjAraMvF1yTG5FGcPBdkE5vpPXQx2SiKWP4/iFl04Wrid X-Received: by 2002:a05:6a00:1708:b0:6e7:3223:4556 with SMTP id h8-20020a056a00170800b006e732234556mr5863492pfc.32.1711319899452; Sun, 24 Mar 2024 15:38:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711319899; cv=pass; d=google.com; s=arc-20160816; b=HFWKBjZXi81qamqGIlcETJeMLSji3AQDVf5oH1WQeERa67qjSBz+onflNeddEC6qkY 2LzddPx7O6VpZSzcapWst5Tm++6vzfjRU/3OqlCAg2LlQkEjM4Q0B7M1p4VLxGsTRkVl bPLlUOhtPu8XtvOvSlo6k8oBdhQrARirJ2CQldSMCFa5PYUeWiXuluQwzeNtZM+gYOQj Da5gF4b9hLtFpiqpohwffE4de0YJz+UzNqb6EPZJgTy7Y7bzSKbdtUzwnuN0tySURtdt Nqnfkesg/IWaEWPQ9lQsNpdi255Byrzj3D8vZ8//LDFQBjqrGhxVRwxCsFeraUy3G/R5 yIpQ== 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=0dgoMnzEorux5Wn88QXekpLDLtUfc/Fi2HrcpT9RlFY=; fh=QgK/GdU0qbDNRur2SdZH0b4sYMuLEh1Fqi4K167Kt0g=; b=VEArk2xjXupQwHFB2CtjnJeg9EyGvC2Jzr90RHgM3d9nesg4r1JA2Lzr9Nsn4liz9f 8Lgcz124nEdvGXn01QBgypfdmBYYL57jYF1zzFbP0yy94qwYAZCWh6taT0iLAfBua/tZ e6l03Ls4ke9auH0uPDpAj+bOw9TLIinlDlurFayONYoJxQMbDAhXHVVSNhF2+rWTmM2K Uu0HDJIodQ2Lcpc+OE1Kd1Hd37CTGH3mTYMezJHjh8nyHMeruGdvPo64D6nK1Vkp5Uvv NEUXU7BwBYQZYIw5YxRa6mE7ZJZ4SDWN/SA2VnxQ0w0ox00VdIkY4QhlDr3kHgrOvjpi N9eQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mxv0l1Rx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112899-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112899-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 v8-20020a63b648000000b005e8428f86efsi6202224pgt.275.2024.03.24.15.38.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:38:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112899-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=Mxv0l1Rx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112899-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112899-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 226CD2812EC for ; Sun, 24 Mar 2024 22:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8473C5490A; Sun, 24 Mar 2024 22:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mxv0l1Rx" 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 A8845548E3; Sun, 24 Mar 2024 22:35:09 +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=1711319709; cv=none; b=CHwHHl2uHNU2Lt3WLXxY5fDO3h11wItifn3B7evsUnrpaA+CTb7sCY+A9ir6GnQdtxQnnvMGE93GNvOEkeCEKa5Ii3QJG/keMcBSE2FhJ/rt+NzQks2dc+UBirbsg9dh0dzrjXJFKiYnSJ25uo9KA1J74PYKbLmcAy4iWdgCssM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319709; c=relaxed/simple; bh=UZ1IFt2fs6RF2Ir542kA8pBRLhL3MsJPGgyv1aIBtTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gKskoOjN0pxxadEruF6WE46baHL8VxiL6FHhA42X/x63EM02x8vQT6XmmBzi3559fmKM+5D41duHFh5GtBxeqkRRcjLGeDN733kyrRuYHk1uIBvhYxOaEyIJyQZVwjsxPGYbyWsU6kVnV+tXwOJiqF8YJJ6XBkYZI8T40NWeHcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mxv0l1Rx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EA44C433C7; Sun, 24 Mar 2024 22:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319709; bh=UZ1IFt2fs6RF2Ir542kA8pBRLhL3MsJPGgyv1aIBtTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mxv0l1RxE1eBJejMbHzZrAV5cYd5P76pIpPvCSCrjM8/Huhw2texGJRpUcsQWmXv0 b15y9SM8JfxUuIPrWpMCZGbvzK7zFxGJPkmJqsLL3x5H7sEPMcxuEe42OQNBNy7dFf EKKSJ/Uuddl/lR8Yw7pQTA+DZQc6tOBr5ErRCuvV8wops4YytU+j3rFYV1eiWyzAsX PNQ+Gqx7I/MdgWSBIH0q+ZEhWOSM1Y5vdWk3B8aBomY6h5HNUjtlxn9KQXIvIrsBS2 nD0cZsuPedz9mbzGsNexqopIo5cPeZuWZ3MKsr166mtUPLUS4PpRr7bvzr6BrUdnHm /PxqYykk5+Hfg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Christian Brauner , Sasha Levin Subject: [PATCH 6.8 012/715] iomap: clear the per-folio dirty bits on all writeback failures Date: Sun, 24 Mar 2024 18:23:11 -0400 Message-ID: <20240324223455.1342824-13-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 093c4515b22a5..228fd2e05e12f 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1833,16 +1833,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; - } } /* @@ -1851,6 +1845,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