Re: [PATCH 5/8] btrfs: tree-checker: don't fail on empty extent roots for extent tree v2

Qu Wenruo
2021-11-06T01:11:56Z

On 2021/11/6 04:49, Josef Bacik wrote:
> For extent tree v2 we can definitely have empty extent roots, so skip
> this particular check if we have that set.

OK I guess the changes in tree-checker is not yet complete.

As I thought there would be more and bigger changes to support those
global roots.

But so far so good for tree-checker.

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

Thanks,
Qu
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> fs/btrfs/tree-checker.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index 7733e8ac0a69..1c33dd0e4afc 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -1633,7 +1633,6 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
> /* These trees must never be empty */
> if (unlikely(owner == BTRFS_ROOT_TREE_OBJECTID ||
> owner == BTRFS_CHUNK_TREE_OBJECTID ||
> - owner == BTRFS_EXTENT_TREE_OBJECTID ||
> owner == BTRFS_DEV_TREE_OBJECTID ||
> owner == BTRFS_FS_TREE_OBJECTID ||
> owner == BTRFS_DATA_RELOC_TREE_OBJECTID)) {
> @@ -1642,12 +1641,25 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
> owner);
> return -EUCLEAN;
> }
> +
> /* Unknown tree */
> if (unlikely(owner == 0)) {
> generic_err(leaf, 0,
> "invalid owner, root 0 is not defined");
> return -EUCLEAN;
> }
> +
> + /* EXTENT_TREE_V2 can have empty extent trees. */
> + if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
> + return 0;
> +
> + if (unlikely(owner == BTRFS_EXTENT_TREE_OBJECTID)) {
> + generic_err(leaf, 0,
> + "invalid root, root %llu must never be empty",
> + owner);
> + return -EUCLEAN;
> + }
> +
> return 0;
> }
>
>