diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 09582b81640cc8e02ced7ea7c8ec6b22acdc8dba..c09a40db53dbf8dff60ed9c942c217ca6546b058 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1481,10 +1481,12 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, *end = state->end; cur_start = state->end + 1; node = rb_next(node); - if (!node) - break; total_bytes += state->end - state->start + 1; - if (total_bytes >= max_bytes) + if (total_bytes >= max_bytes) { + *end = *start + max_bytes - 1; + break; + } + if (!node) break; } out: