Skip to content

Commit 153c35b

Browse files
committed
Btrfs: fix regression in raid level conversion
Commit 2f08108 changed btrfs_set_block_group_ro to avoid trying to allocate new chunks with the new raid profile during conversion. This fixed failures when there was no space on the drive to allocate a new chunk, but the metadata reserves were sufficient to continue the conversion. But this ended up causing a regression when the drive had plenty of space to allocate new chunks, mostly because reduce_alloc_profile isn't using the new raid profile. Fixing btrfs_reduce_alloc_profile is a bigger patch. For now, do a partial revert of 2f08108, and don't error out if we hit ENOSPC. Signed-off-by: Chris Mason <[email protected]> Tested-by: Dave Sterba <[email protected]> Reported-by: Holger Hoffstaette <[email protected]>
1 parent a962959 commit 153c35b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8829,6 +8829,24 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
88298829
goto again;
88308830
}
88318831

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+
}
88328850

88338851
ret = set_block_group_ro(cache, 0);
88348852
if (!ret)

0 commit comments

Comments
 (0)