Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset()
Date: Fri, 13 Nov 2026 13:43:45 +1030	[thread overview]
Message-ID: <cc63fc94-e99a-42e9-965c-6b138b0760b2@gmx.com> (raw)
In-Reply-To: <dc3e7e3972a3d82ad871c53418a646498204400d.1794504751.git.fdmanana@suse.com>



在 2026/11/13 04:03, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> In the while loop that finds the first file extent item, counting from the
> end of the file, that is not a hole, we are accessing the disk_bytenr
> field of each file extent item, which is wrong in case we have an item
> that represents an inline extent. In that case the inline data starts at
> the disk_bytenr offset and therefore we are reading user data or in case
> the inline data is less than 8 bytes, we are accessing another region of
> the leaf or even beyond the leaf boundaries in case it's the last item.
> 
> This should be a very rare case, as it implies having an inline extent
> followed by a hole file extent item (the no-holes feature is not used).
> 
> Fixes: ac3c0d36a2a2 ("btrfs: make fiemap more efficient and accurate reporting extent sharedness")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/fiemap.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
> index 817171028413..285398eb36dc 100644
> --- a/fs/btrfs/fiemap.c
> +++ b/fs/btrfs/fiemap.c
> @@ -621,6 +621,8 @@ static int fiemap_find_last_extent_offset(struct btrfs_inode *inode,
>   		leaf = path->nodes[0];
>   		ei = btrfs_item_ptr(leaf, path->slots[0],
>   				    struct btrfs_file_extent_item);
> +		if (btrfs_file_extent_type(leaf, ei) == BTRFS_FILE_EXTENT_INLINE)
> +			break;
>   		disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, ei);
>   	}
>   


      reply	other threads:[~2026-11-13  3:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 17:33 [PATCH] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() fdmanana
2026-11-13  3:13 ` 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=cc63fc94-e99a-42e9-965c-6b138b0760b2@gmx.com \
    --to=quwenruo.btrfs@gmx.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