Skip to content

Commit 2f08108

Browse files
shligitmasoncl
authored andcommitted
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 <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 289454a commit 2f08108

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

fs/btrfs/extent-tree.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8482,14 +8482,6 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
84828482
if (IS_ERR(trans))
84838483
return PTR_ERR(trans);
84848484

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-
84938485
ret = set_block_group_ro(cache, 0);
84948486
if (!ret)
84958487
goto out;
@@ -8500,6 +8492,11 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
85008492
goto out;
85018493
ret = set_block_group_ro(cache, 0);
85028494
out:
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+
85038500
btrfs_end_transaction(trans, root);
85048501
return ret;
85058502
}

0 commit comments

Comments
 (0)