summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2016-01-29 13:03:31 +0800
committerDavid Sterba <dsterba@suse.com>2016-06-07 18:15:19 +0200
commit561f773433129acf5ba2bdd9abd85876f5d098ce (patch)
tree1d35f3486949edbf0ab7dcf489104c60878c4253 /btrfs-convert.c
parente5724bfc8e015835154b77a6e2b1eb7ed4b9f16c (diff)
btrfs-progs: convert: Strictly avoid meta or system chunk allocation
Before this patch, btrfs-convert only rely on large enough initial system/metadata chunk size to ensure no newer system/meta chunk will be created. But that's not safe enough. So add two new members in fs_info, avoid_sys/meta_chunk_alloc flags to prevent any newer system or meta chunks to be created before init_btrfs_v2(). 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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index c2616aee..7ec61675 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2349,6 +2349,13 @@ static int init_btrfs_v2(struct btrfs_mkfs_config *cfg, struct btrfs_root *root,
struct btrfs_fs_info *fs_info = root->fs_info;
int ret;
+ /*
+ * Don't alloc any metadata/system chunk, as we don't want
+ * any meta/sys chunk allcated before all data chunks are inserted.
+ * Or we screw up the chunk layout just like the old implement.
+ */
+ fs_info->avoid_sys_chunk_alloc = 1;
+ fs_info->avoid_meta_chunk_alloc = 1;
trans = btrfs_start_transaction(root, 1);
BUG_ON(!trans);
ret = btrfs_fix_block_accounting(trans, root);
@@ -2386,6 +2393,8 @@ static int init_btrfs_v2(struct btrfs_mkfs_config *cfg, struct btrfs_root *root,
goto err;
ret = btrfs_commit_transaction(trans, root);
+ fs_info->avoid_sys_chunk_alloc = 0;
+ fs_info->avoid_meta_chunk_alloc = 0;
err:
return ret;
}