From: Yichong Chen <chenyichong@uniontech.com>
To: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>
Cc: Boris Burkov <boris@bur.io>, Matthew Wilcox <willy@infradead.org>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Yichong Chen <chenyichong@uniontech.com>
Subject: [PATCH] btrfs: remove verity Merkle folio from page cache on error
Date: Mon, 6 Jul 2026 13:39:07 +0800 [thread overview]
Message-ID: <20260706053907.544337-1-chenyichong@uniontech.com> (raw)
btrfs_read_merkle_tree_page() allocates a folio and adds it to the
page cache before reading the Merkle tree data from btree items.
If read_key_bytes() fails, the folio is still locked and present in the
page cache. Drop it from the page cache and unlock it before releasing the
allocation reference so a later read can retry instead of finding a locked,
not-uptodate folio.
Fixes: 06ed09351b67 ("btrfs: convert btrfs_read_merkle_tree_page() to use a folio")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
fs/btrfs/verity.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
index 983365a73541..99468791a98e 100644
--- a/fs/btrfs/verity.c
+++ b/fs/btrfs/verity.c
@@ -753,6 +753,8 @@ 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);
if (ret < 0) {
+ filemap_remove_folio(folio);
+ folio_unlock(folio);
folio_put(folio);
return ERR_PTR(ret);
}
--
2.51.0
next reply other threads:[~2026-07-06 5:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 5:39 Yichong Chen [this message]
2026-07-07 5:35 ` [PATCH] btrfs: remove verity Merkle folio from page cache on error Yichong Chen
2026-07-07 5:55 ` [PATCH v2] btrfs: add verity Merkle folio to page cache after reading it Yichong Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706053907.544337-1-chenyichong@uniontech.com \
--to=chenyichong@uniontech.com \
--cc=boris@bur.io \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox