On Tue, May 14, 2013 at 07:50:28PM +0800, Wang Shilong wrote:
> When making btrfs filesystem. we firstly write root leaf to
> specified filed, and then we recow the root. If we don't recow,
> some trees are not in the correct block group.
>
> Steps to reproduce:
> dd if=/dev/zero of=test.img bs=1M count=100
> mkfs.btrfs -f test.img
> btrfs-debug-tree test.img
Very simple reproducer, I guess that it gets fixed with first update of
the misplaced blocks.
> --- a/mkfs.c
> +++ b/mkfs.c
> @@ -151,37 +151,55 @@ static int recow_roots(struct btrfs_trans_handle *trans,
> int ret;
> struct extent_buffer *tmp;
> struct btrfs_fs_info *info = root->fs_info;
> + u64 generation;
>
> - ret = __btrfs_cow_block(trans, info->fs_root, info->fs_root->node,
> - NULL, 0, &tmp, 0, 0);
> - BUG_ON(ret);
> - free_extent_buffer(tmp);
> + generation = btrfs_root_generation(&info->fs_root->root_item);
> + if (generation != trans->transid) {
> + ret = __btrfs_cow_block(trans, info->fs_root,
> + info->fs_root->node, NULL, 0, &tmp, 0, 0);
> + BUG_ON(ret);
> + free_extent_buffer(tmp);
> + }
This gets repeated, please use wrapper for that.
david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html