diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2015-07-23 17:18:10 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-08-31 19:25:10 +0200 |
commit | c11eeecd784b906ee64613cb2dd8186bc6b5dc34 (patch) | |
tree | 373abdc3e606052bf3ae17fe877770f7307bf0f3 /btrfs-convert.c | |
parent | 854437ca3c228d8ab3eb24d2efc1c21b5d56a635 (diff) | |
download | btrfs-progs-c11eeecd784b906ee64613cb2dd8186bc6b5dc34.tar.gz |
btrfs-progs: convert: Avoid allocating metadata extent crossing stripe boundary
As convert implement its own alloc extent, avoid such metadata problem
too.
Reported-by: Chris Murphy <lists@colorremedies.com>
Reported-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r-- | btrfs-convert.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c index b89c685..c97068e 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -207,7 +207,8 @@ static int cache_free_extents(struct btrfs_root *root, ext2_filsys ext2_fs) } static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes, - u64 hint_byte, struct btrfs_key *ins) + u64 hint_byte, struct btrfs_key *ins, + int metadata) { u64 start; u64 end; @@ -246,6 +247,14 @@ static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes, continue; } + if (metadata) { + BUG_ON(num_bytes != root->nodesize); + if (check_crossing_stripes(start, num_bytes)) { + last = round_down(start + num_bytes, + BTRFS_STRIPE_LEN); + continue; + } + } clear_extent_dirty(&root->fs_info->free_space_cache, start, start + num_bytes - 1, 0); @@ -1280,7 +1289,7 @@ static int create_ext2_image(struct btrfs_root *root, ext2_filsys ext2_fs, * special, we can't rely on relocate_extents_range to relocate it. */ for (last_byte = 0; last_byte < first_free; last_byte += sectorsize) { - ret = custom_alloc_extent(root, sectorsize, 0, &key); + ret = custom_alloc_extent(root, sectorsize, 0, &key, 0); if (ret) goto fail; ret = copy_disk_extent(root, key.objectid, last_byte, @@ -1938,7 +1947,7 @@ static int relocate_one_reference(struct btrfs_trans_handle *trans, ret = get_state_private(reloc_tree, bytenr, &new_pos); BUG_ON(ret); } else { - ret = custom_alloc_extent(root, sectorsize, 0, &key); + ret = custom_alloc_extent(root, sectorsize, 0, &key, 0); if (ret) goto fail; new_pos = key.objectid; |