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@xxxxxxx>
---
fs/btrfs/extent-tree.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8f0d489f76fa..3ab0d2f5d718 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3373,6 +3373,7 @@ enum btrfs_loop_type {
LOOP_CACHING_WAIT,
LOOP_ALLOC_CHUNK,
LOOP_NO_EMPTY_SIZE,
+ LOOP_GIVEUP,
};
static inline void
@@ -3847,6 +3848,11 @@ static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info,
}
if (ffe_ctl->loop == LOOP_NO_EMPTY_SIZE) {
+ 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.
--
2.25.0