Signed-off-by: Chris Mason <clm@fb.com>
Tested-by: Dave Sterba <dsterba@suse.cz>
Reported-by: Holger Hoffstaette <holger.hoffstaette@googlemail.com>
+[adapted for stable kernel branch, v4.0.5]
+Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
---
fs/btrfs/extent-tree.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -8484,6 +8484,24 @@ static int set_block_group_ro(struct btr
- u64 min_allocable_bytes;
- int ret = -ENOSPC;
-
+@@ -8535,6 +8535,24 @@ int btrfs_set_block_group_ro(struct btrf
+ trans = btrfs_join_transaction(root);
+ if (IS_ERR(trans))
+ return PTR_ERR(trans);
+ /*
+ * if we are changing raid levels, try to allocate a corresponding
+ * block group with the new raid level.
+ goto out;
+ }
- /*
- * We need some metadata space and system metadata space for
+ ret = set_block_group_ro(cache, 0);
+ if (!ret)