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

btrfs: let can_allocate_chunk return error



For the later patch, convert the return type from bool to int and return
errors. No functional changes.

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent d7601566
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -3965,12 +3965,12 @@ static void found_extent(struct find_free_extent_ctl *ffe_ctl,
	}
	}
}
}


static bool can_allocate_chunk(struct btrfs_fs_info *fs_info,
static int can_allocate_chunk(struct btrfs_fs_info *fs_info,
			      struct find_free_extent_ctl *ffe_ctl)
			      struct find_free_extent_ctl *ffe_ctl)
{
{
	switch (ffe_ctl->policy) {
	switch (ffe_ctl->policy) {
	case BTRFS_EXTENT_ALLOC_CLUSTERED:
	case BTRFS_EXTENT_ALLOC_CLUSTERED:
		return true;
		return 0;
	case BTRFS_EXTENT_ALLOC_ZONED:
	case BTRFS_EXTENT_ALLOC_ZONED:
		/*
		/*
		 * If we have enough free space left in an already
		 * If we have enough free space left in an already
@@ -3980,8 +3980,8 @@ static bool can_allocate_chunk(struct btrfs_fs_info *fs_info,
		 */
		 */
		if (ffe_ctl->max_extent_size >= ffe_ctl->min_alloc_size &&
		if (ffe_ctl->max_extent_size >= ffe_ctl->min_alloc_size &&
		    !btrfs_can_activate_zone(fs_info->fs_devices, ffe_ctl->flags))
		    !btrfs_can_activate_zone(fs_info->fs_devices, ffe_ctl->flags))
			return false;
			return -ENOSPC;
		return true;
		return 0;
	default:
	default:
		BUG();
		BUG();
	}
	}
@@ -4063,8 +4063,9 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
			int exist = 0;
			int exist = 0;


			/*Check if allocation policy allows to create a new chunk */
			/*Check if allocation policy allows to create a new chunk */
			if (!can_allocate_chunk(fs_info, ffe_ctl))
			ret = can_allocate_chunk(fs_info, ffe_ctl);
				return -ENOSPC;
			if (ret)
				return ret;


			trans = current->journal_info;
			trans = current->journal_info;
			if (trans)
			if (trans)