On Thu, May 25, 2017 at 06:26:29PM -0600, Liu Bo wrote:
> btrfs_print_leaf() is used in btrfs_get_extent_inline_ref_type, so
> here we really want to print the invalid value of ref type instead of
> causing a kernel panic.
> 
> Signed-off-by: Liu Bo <bo.li....@oracle.com>
> ---
>  fs/btrfs/print-tree.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
> index fcae61e..4448be6 100644
> --- a/fs/btrfs/print-tree.c
> +++ b/fs/btrfs/print-tree.c
> @@ -63,6 +63,7 @@ static void print_extent_item(struct extent_buffer *eb, int 
> slot, int type)
>       u32 item_size = btrfs_item_size_nr(eb, slot);
>       u64 flags;
>       u64 offset;
> +     int is_data;
>  
>       if (item_size < sizeof(*ei)) {
>  #ifdef BTRFS_COMPAT_EXTENT_TREE_V0
> @@ -98,6 +99,8 @@ static void print_extent_item(struct extent_buffer *eb, int 
> slot, int type)
>               iref = (struct btrfs_extent_inline_ref *)(ei + 1);
>       }
>  
> +     is_data = !!(flags & BTRFS_EXTENT_FLAG_DATA);
> +
>       ptr = (unsigned long)iref;
>       end = (unsigned long)ei + item_size;
>       while (ptr < end) {
> @@ -121,7 +124,10 @@ static void print_extent_item(struct extent_buffer *eb, 
> int slot, int type)
>                              offset, btrfs_shared_data_ref_count(eb, sref));
>                       break;
>               default:
> -                     BUG();
> +                     btrfs_err(eb->fs_info,
> +                               "extent %llu has invalid ref type %d\n",
> +                               eb->start, type);
> +                     return;

I don't see is_data used anywhere, also not in the followup patches.
Please use a bool type in case it's valid here.

>               }
>               ptr += btrfs_extent_inline_ref_size(type);
>       }
> -- 
> 2.9.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to