aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2015-01-09 13:40:15 -0500
committerChris Mason <clm@fb.com>2015-02-02 22:25:20 -0500
commit2f0810880f082fa8ba66ab2c33b02e4ff9770a5e (patch)
treed6c4885a3890158235431db66fe625604b239974 /fs/btrfs/extent-tree.c
parent289454ad26a2d752e04b07234a175feda9ec0f4e (diff)
btrfs: delete chunk allocation attemp when setting block group ro
Below test will fail currently: mkfs.ext4 -F /dev/sda btrfs-convert /dev/sda mount /dev/sda /mnt btrfs device add -f /dev/sdb /mnt btrfs balance start -v -dconvert=raid1 -mconvert=raid1 /mnt The reason is there are some block groups with usage 0, but the whole disk hasn't free space to allocate new chunk, so we even can't set such block group readonly. This patch deletes the chunk allocation when setting block group ro. For META, we already have reserve. But for SYSTEM, we don't have, so the check_system_chunk is still required. Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 857a859948a3..50de1fa6fc9e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8482,14 +8482,6 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
8482 if (IS_ERR(trans)) 8482 if (IS_ERR(trans))
8483 return PTR_ERR(trans); 8483 return PTR_ERR(trans);
8484 8484
8485 alloc_flags = update_block_group_flags(root, cache->flags);
8486 if (alloc_flags != cache->flags) {
8487 ret = do_chunk_alloc(trans, root, alloc_flags,
8488 CHUNK_ALLOC_FORCE);
8489 if (ret < 0)
8490 goto out;
8491 }
8492
8493 ret = set_block_group_ro(cache, 0); 8485 ret = set_block_group_ro(cache, 0);
8494 if (!ret) 8486 if (!ret)
8495 goto out; 8487 goto out;
@@ -8500,6 +8492,11 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
8500 goto out; 8492 goto out;
8501 ret = set_block_group_ro(cache, 0); 8493 ret = set_block_group_ro(cache, 0);
8502out: 8494out:
8495 if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
8496 alloc_flags = update_block_group_flags(root, cache->flags);
8497 check_system_chunk(trans, root, alloc_flags);
8498 }
8499
8503 btrfs_end_transaction(trans, root); 8500 btrfs_end_transaction(trans, root);
8504 return ret; 8501 return ret;
8505} 8502}