Commit b25c19f4 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba
Browse files

btrfs: handle invalid profile in chunk allocation



Do not BUG_ON() when an invalid profile is passed to __btrfs_alloc_chunk().
Instead return -EINVAL with ASSERT() to catch a bug in the development
stage.

Suggested-by: default avatarJohannes Thumshirn <Johannes.Thumshirn@wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 52d40aba
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -4773,7 +4773,10 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
	int j;
	int index;

	BUG_ON(!alloc_profile_is_valid(type, 0));
	if (!alloc_profile_is_valid(type, 0)) {
		ASSERT(0);
		return -EINVAL;
	}

	if (list_empty(&fs_devices->alloc_list)) {
		if (btrfs_test_opt(info, ENOSPC_DEBUG))