aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7effed6f2fa6..0ec3acd14cbf 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8829,6 +8829,24 @@ again:
8829 goto again; 8829 goto again;
8830 } 8830 }
8831 8831
8832 /*
8833 * if we are changing raid levels, try to allocate a corresponding
8834 * block group with the new raid level.
8835 */
8836 alloc_flags = update_block_group_flags(root, cache->flags);
8837 if (alloc_flags != cache->flags) {
8838 ret = do_chunk_alloc(trans, root, alloc_flags,
8839 CHUNK_ALLOC_FORCE);
8840 /*
8841 * ENOSPC is allowed here, we may have enough space
8842 * already allocated at the new raid level to
8843 * carry on
8844 */
8845 if (ret == -ENOSPC)
8846 ret = 0;
8847 if (ret < 0)
8848 goto out;
8849 }
8832 8850
8833 ret = set_block_group_ro(cache, 0); 8851 ret = set_block_group_ro(cache, 0);
8834 if (!ret) 8852 if (!ret)
@@ -8842,7 +8860,9 @@ again:
8842out: 8860out:
8843 if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) { 8861 if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) {
8844 alloc_flags = update_block_group_flags(root, cache->flags); 8862 alloc_flags = update_block_group_flags(root, cache->flags);
8863 lock_chunks(root->fs_info->chunk_root);
8845 check_system_chunk(trans, root, alloc_flags); 8864 check_system_chunk(trans, root, alloc_flags);
8865 unlock_chunks(root->fs_info->chunk_root);
8846 } 8866 }
8847 mutex_unlock(&root->fs_info->ro_block_group_mutex); 8867 mutex_unlock(&root->fs_info->ro_block_group_mutex);
8848 8868