From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org, Hongling Zeng <zenghongling@kylinos.cn>
Subject: Re: [PATCH] btrfs: refactor read_key_bytes() to remove the dest_folio parameter
Date: Fri, 21 Aug 2026 18:22:44 +0200 [thread overview]
Message-ID: <20260821162244.GD9053@twin.jikos.cz> (raw)
In-Reply-To: <9dbe80bc5b11556619603748db55424cb75a4407.1786951820.git.wqu@suse.com>
On Mon, Aug 17, 2026 at 05:00:43PM +0930, Qu Wenruo wrote:
> The function read_key_bytes() have 3 call sites:
>
> - For BTRFS_VERITY_DESC_ITEM_KEY offset 0 inside btrfs_get_verity_descriptor()
> - For BTRFS_VERITY_DESC_ITEM_KEY offset 1 inside btrfs_get_verity_descriptor()
> Those are to read the description items, which are pretty small with
> fixed item size.
>
> Those call sites do not utilize the @dest_folio parameter.
>
> - For btrfs_read_merkle_tree_page()
> This is to read the BTRFS_VERITY_MERKLE_ITEM_KEY, which can be pretty
> large and split into multiple items.
>
> This is the only call site utilizing the @dest_folio parameter.
>
> Just for the only btrfs_read_merkle_tree_page() call site, we have a
> complex scheme for @dest and @dest_folio parameters.
> Since @dest can be NULL, it means if we pass @dest as NULL, then no
> matter if @dest_folio is provided, the merkle data will not be loaded
> into that @dest_folio.
>
> This can lead to a bug where a highmem folio is not mapped, then we pass
> folio_address(folio), which is NULL, into read_key_bytes(), causing no
> data to be written into @dest_folio.
>
> To address the complex scheme between @dest and @dest_folio, remove the
> @dest_folio parameter completely, and let the only caller to map the
> folio and pass the mapped kernel address into read_key_bytes() instead.
>
> This not only reduces the parameter list, but also make it much clear on
> the @dest parameter handling.
> The only downside is a longer duration of locally mapped page, but this
> should still be fine, as kmap_local_folio() can survive context switch.
>
> Reported-by: Hongling Zeng <zenghongling@kylinos.cn>
> Link: https://lore.kernel.org/linux-btrfs/20260817022012.19658-1-zenghongling@kylinos.cn/
> Fixes: 146054090b08 ("btrfs: initial fsverity support")
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
prev parent reply other threads:[~2026-08-21 16:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 7:30 [PATCH] btrfs: refactor read_key_bytes() to remove the dest_folio parameter Qu Wenruo
2026-08-21 16:22 ` David Sterba [this message]
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=20260821162244.GD9053@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
--cc=zenghongling@kylinos.cn \
/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