Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0765B332EAE; Sat, 12 Sep 2026 14:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789225088; cv=none; b=UlLHysj+sotxTSvL+gHW9g808Tm+bKqRLq6TlJUGS7AbyA6aaOg7OJwQOG8Y2jUwkL2pHyY9aQzS7ERtDU3HO1PrhOhrcivVMz5uQPHxcFTUy+EjJamip0GI/N7Rzye8QN7cybgJMVJlV/3+V0kXKt/UdDz5306A12RuEEuCYKw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789225088; c=relaxed/simple; bh=yGEAwZYaVRVcZU6JjSfVPKULQ4V+22k2FFgYCtgR/dM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VJ5ONTbKvB35V6edRljsE68QoNrCamy4i2N1kWKfGMXeHf79tInOAho6t4hG/8/qeYYZvE+JHJricBicN/ieQkUqtulUxyjWSwrhPXZ9AmI+AllXGdfilmREqYMoKhuF5XmQ+rHu3ePKPvOLFjEgUBVIU5osj0r/jzmecOdNHkg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kycFXHzA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kycFXHzA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00D1A1F000FF; Sat, 12 Sep 2026 14:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789225085; bh=fBTivmb56p0S/uDmYCf4EGIZUTB1Ak9/IVoQKvRzL5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kycFXHzAUzT7HNsVLmAm44SZWN9cTTW8YTrLgcf94EVOYVc9TqdQCzHRjr7l/5U+K Tf6NAapO+G317qma+SNipomWo7GLiWeMcliTC1R34llmwiZ5k67bDHbWPzrnSeFhD/ gJI62NEZ9qcSfpFOqh+ohGRSyBZd7p/hJGyedkLg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Boris Burkov , Yichong Chen , David Sterba , Sasha Levin Subject: [PATCH 6.6 1125/1424] btrfs: retry verity reads for not-uptodate Merkle folios Date: Sat, 12 Sep 2026 08:59:17 +0200 Message-ID: <20260912065632.494253256@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yichong Chen [ Upstream commit 8cc569696dac51fc62bb39b3b8f530582b916d29 ] btrfs_read_merkle_tree_page() can find a folio in the mapping that is not uptodate. After taking the folio lock, the current code treats that state as a read error and returns -EIO. That can make a previous transient read failure sticky. If the failed read left a not-uptodate folio in the mapping, later callers find that folio and fail instead of retrying the read. Keep the existing page-cache insertion and locking order, but retry the Merkle item read when a not-uptodate folio is found in the mapping. Also unlock the folio when read_key_bytes() fails so that a later caller can lock it and retry the read. Fixes: 06ed09351b67 ("btrfs: convert btrfs_read_merkle_tree_page() to use a folio") Reviewed-by: Boris Burkov Signed-off-by: Yichong Chen Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/verity.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c index 744f4f4d4c681..ddb651e0bb05c 100644 --- a/fs/btrfs/verity.c +++ b/fs/btrfs/verity.c @@ -732,14 +732,18 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, goto out; folio_lock(folio); - /* If it's not uptodate after we have the lock, we got a read error. */ - if (!folio_test_uptodate(folio)) { + /* Folio was truncated from mapping. */ + if (!folio->mapping) { folio_unlock(folio); folio_put(folio); - return ERR_PTR(-EIO); + goto again; } - folio_unlock(folio); - goto out; + /* Another reader may have filled the folio while we waited. */ + if (folio_test_uptodate(folio)) { + folio_unlock(folio); + goto out; + } + goto read_folio; } folio = filemap_alloc_folio(mapping_gfp_constraint(inode->i_mapping, ~__GFP_FS), @@ -756,6 +760,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, return ERR_PTR(ret); } +read_folio: /* * Merkle item keys are indexed from byte 0 in the merkle tree. * They have the form: @@ -765,6 +770,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, ret = read_key_bytes(BTRFS_I(inode), BTRFS_VERITY_MERKLE_ITEM_KEY, off, folio_address(folio), PAGE_SIZE, &folio->page); if (ret < 0) { + folio_unlock(folio); folio_put(folio); return ERR_PTR(ret); } -- 2.53.0