[syslinux] [PATCH v2] btrfs: Fix logical to physical block address mapping

Gene Cumm gene.cumm at gmail.com
Sun Dec 27 04:45:07 PST 2015


On Thu, Dec 24, 2015 at 8:58 AM, Paulo Alcantara <pcacjr at gmail.com> wrote:
> The current btrfs support did not handled multiple stripes stored in
> chunk items, hence skipping the physical addresses that were needed to
> do the mapping.
>
> Besides, the chunk tree may contain DEV_ITEM keys which store
> information on all of the underlying block devices, so we must skip them
> instead of finishing lookup.
>
> The bug was reproduced with btrfs-progs v4.2.2.
>
> Cc: Gene Cumm <gene.cumm at gmail.com>
> Cc: H. Peter Anvin <hpa at zytor.com>
> Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>
> ---
> v1 -> v2:
>  * Do not set ignore_key multiple times. Set it before parsing chunk
>    tree.
> ---
>  core/fs/btrfs/btrfs.c | 52 +++++++++++++++++++++++++++++++++++----------------
>  core/fs/btrfs/btrfs.h |  2 ++
>  2 files changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
> index 53e1105..ca611db 100644
> --- a/core/fs/btrfs/btrfs.c
> +++ b/core/fs/btrfs/btrfs.c

> @@ -371,16 +386,21 @@ static void btrfs_read_chunk_tree(struct fs_info *fs)
>                 search_tree(fs, bfs->sb.chunk_root, &search_key, &path);
>                 do {
>                         do {
> +                               /* skip information about underlying block
> +                                * devices.
> +                                */
> +                               if (!btrfs_comp_keys_type(&ignore_key,
> +                                                         &path.item.key))
> +                                       goto skip_dev_item;

Why not just a continue rather than a goto to an empty label?

>                                 if (btrfs_comp_keys_type(&search_key,
> -                                                       &path.item.key))
> +                                                        &path.item.key))
>                                         break;
> +
>                                 chunk = (struct btrfs_chunk *)(path.data);
> -                               /* insert to mapping table, ignore stripes */
> -                               item.logical = path.item.key.offset;
> -                               item.length = chunk->length;
> -                               item.devid = chunk->stripe.devid;
> -                               item.physical = chunk->stripe.offset;
> -                               insert_map(fs, &item);
> +                               insert_map(fs, &path.item.key, chunk);
> +
> +                       skip_dev_item:
> +                               ;
>                         } while (!next_slot(fs, &search_key, &path));
>                         if (btrfs_comp_keys_type(&search_key, &path.item.key))
>                                 break;

-- 
-Gene


More information about the Syslinux mailing list