Skip to content

Commit

Permalink
Btrfs: use fastpath in extent state ops as much as possible
Browse files Browse the repository at this point in the history
Fully utilize our extent state's new helper functions to use
fastpath as much as possible.

Signed-off-by: Liu Bo <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
  • Loading branch information
liub authored and Josef Bacik committed May 30, 2012
1 parent f8c5d0b commit d1ac6e4
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,8 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
if (err)
goto out;
if (state->end <= end) {
clear_state_bit(tree, state, &bits, wake);
if (last_end == (u64)-1)
goto out;
start = last_end + 1;
state = clear_state_bit(tree, state, &bits, wake);
goto next;
}
goto search_again;
}
Expand Down Expand Up @@ -780,28 +778,22 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
* Just lock what we found and keep going
*/
if (state->start == start && state->end <= end) {
struct rb_node *next_node;
if (state->state & exclusive_bits) {
*failed_start = state->start;
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;
next_node = rb_next(&state->rb_node);
if (next_node && start < end && prealloc && !need_resched()) {
state = rb_entry(next_node, struct extent_state,
rb_node);
if (state->start == start)
goto hit_next;
}
state = next_state(state);
if (start < end && state && state->start == start &&
!need_resched())
goto hit_next;
goto search_again;
}

Expand Down Expand Up @@ -844,6 +836,10 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
if (last_end == (u64)-1)
goto out;
start = last_end + 1;
state = next_state(state);
if (start < end && state && state->start == start &&
!need_resched())
goto hit_next;
}
goto search_again;
}
Expand Down Expand Up @@ -993,21 +989,14 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
* Just lock what we found and keep going
*/
if (state->start == start && state->end <= end) {
struct rb_node *next_node;

set_state_bits(tree, state, &bits);
clear_state_bit(tree, state, &clear_bits, 0);
state = clear_state_bit(tree, state, &clear_bits, 0);
if (last_end == (u64)-1)
goto out;

start = last_end + 1;
next_node = rb_next(&state->rb_node);
if (next_node && start < end && prealloc && !need_resched()) {
state = rb_entry(next_node, struct extent_state,
rb_node);
if (state->start == start)
goto hit_next;
}
if (start < end && state && state->start == start &&
!need_resched())
goto hit_next;
goto search_again;
}

Expand Down Expand Up @@ -1041,10 +1030,13 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
goto out;
if (state->end <= end) {
set_state_bits(tree, state, &bits);
clear_state_bit(tree, state, &clear_bits, 0);
state = clear_state_bit(tree, state, &clear_bits, 0);
if (last_end == (u64)-1)
goto out;
start = last_end + 1;
if (start < end && state && state->start == start &&
!need_resched())
goto hit_next;
}
goto search_again;
}
Expand Down

0 comments on commit d1ac6e4

Please sign in to comment.