Commit 0449314a authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: skip states when they does not contain bits to clear

Clearing a range's bits is different with setting them, since we don't
need to touch them when states do not contain bits we want.
Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
parent 285190d9
...@@ -513,6 +513,15 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -513,6 +513,15 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
WARN_ON(state->end < start); WARN_ON(state->end < start);
last_end = state->end; last_end = state->end;
if (state->end < end && !need_resched())
next_node = rb_next(&state->rb_node);
else
next_node = NULL;
/* the state doesn't have the wanted bits, go ahead */
if (!(state->state & bits))
goto next;
/* /*
* | ---- desired range ---- | * | ---- desired range ---- |
* | state | or * | state | or
...@@ -565,12 +574,8 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -565,12 +574,8 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
goto out; goto out;
} }
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); set |= clear_state_bit(tree, state, &bits, wake);
next:
if (last_end == (u64)-1) if (last_end == (u64)-1)
goto out; goto out;
start = last_end + 1; start = last_end + 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment