@@ -3373,6 +3373,7 @@ enum btrfs_loop_type {
LOOP_CACHING_WAIT,
LOOP_ALLOC_CHUNK,
LOOP_NO_EMPTY_SIZE,
+ LOOP_GIVEUP,
};
static inline void
@@ -3789,7 +3790,6 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
bool full_search)
{
struct btrfs_root *root = fs_info->extent_root;
- struct clustered_alloc_info *clustered = ffe_ctl->alloc_info;
int ret;
if ((ffe_ctl->loop == LOOP_CACHING_NOWAIT) &&
@@ -3863,6 +3863,14 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
}
if (ffe_ctl->loop == LOOP_NO_EMPTY_SIZE) {
+ struct clustered_alloc_info *clustered =
+ ffe_ctl->alloc_info;
+
+ if (ffe_ctl->policy != BTRFS_EXTENT_ALLOC_CLUSTERED) {
+ ffe_ctl->loop = LOOP_GIVEUP;
+ return -ENOSPC;
+ }
+
/*
* Don't loop again if we already have no empty_size and
* no empty_cluster.
LOOP_NO_EMPTY_SIZE is solely dedicated for clustered allocation. So, we can skip this stage and go to LOOP_GIVEUP stage to indicate we gave up the allocation. This commit also moves the scope of the "clustered" variable. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/extent-tree.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)