if (cached_state) {
cached = *cached_state;
*cached_state = NULL;
- if (cached->tree && cached->start == start) {
+ cached_state = NULL;
+ if (cached && cached->tree && cached->start == start) {
atomic_dec(&cached->refs);
state = cached;
- last_end = state->end;
- goto found;
+ goto hit_next;
}
free_extent_state(cached);
}
if (last_end == (u64)-1)
goto out;
start = last_end + 1;
- } else {
- start = state->start;
}
goto search_again;
}
if (wake)
wake_up(&state->wq);
+
set |= clear_state_bit(tree, prealloc, bits,
wake, delete);
prealloc = NULL;
goto out;
}
-found:
+
if (state->end < end && prealloc && !need_resched())
next_node = rb_next(&state->rb_node);
else
next_node = NULL;
+
set |= clear_state_bit(tree, state, bits, wake, delete);
if (last_end == (u64)-1)
goto out;
int err = 0;
u64 last_start;
u64 last_end;
+
again:
if (!prealloc && (mask & __GFP_WAIT)) {
prealloc = alloc_extent_state(mask);
err = -EEXIST;
goto out;
}
+
set_state_bits(tree, state, bits);
cache_state(state, cached_state);
merge_state(tree, state);
if (last_end == (u64)-1)
goto out;
start = last_end + 1;
- } else {
- start = state->start;
}
goto search_again;
}