From: Qu Wenruo <wqu@suse.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix off-by-one max tree level bound when replaying log trees
Date: Fri, 13 Nov 2026 07:35:44 +1030 [thread overview]
Message-ID: <94f4e7fc-0aa6-4cf1-876a-e41c0c1a2523@suse.com> (raw)
In-Reply-To: <b8a17190faf5846c5d843cef9c0887a050eaf98f.1794513725.git.fdmanana@suse.com>
在 2026/11/13 06:36, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> In walk_up_log_tree() we are bounding the loop iteration to 7 levels
> instead of 8. This is a bug since the maximum number of levels for a
> tree is 8 and they go from 0 (leaf level) to 7, so the loop condition
> should be:
>
> i < BTRFS_MAX_LEVEL (which 8)
>
> and not
>
> i < BTRFS_MAX_LEVEL - 1 (7)
>
> This means that in case if we ever get a log tree with 8 levels, which
> theoretically should be impossible specially because they are very
> short lived, we would miss replaying large parts of the log tree.
>
> Link: https://sashiko.dev/#/bug/linux-8d5b7229-3920-47fa-ad36-3a7ddd02f0e7
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/tree-log.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 85ef3c26e0e4..399414ae67c8 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -3067,7 +3067,7 @@ static noinline int walk_up_log_tree(struct btrfs_path *path, int *level,
> int slot;
> int ret;
>
> - for (i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) {
> + for (i = *level; i < BTRFS_MAX_LEVEL && path->nodes[i]; i++) {
> slot = path->slots[i];
> if (slot + 1 < btrfs_header_nritems(path->nodes[i])) {
> path->slots[i]++;
prev parent reply other threads:[~2026-11-12 21:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 20:06 [PATCH] btrfs: fix off-by-one max tree level bound when replaying log trees fdmanana
2026-11-12 21:05 ` Qu Wenruo [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=94f4e7fc-0aa6-4cf1-876a-e41c0c1a2523@suse.com \
--to=wqu@suse.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.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