]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: skip states when they does not contain bits to clear
authorLiu Bo <liubo2009@cn.fujitsu.com>
Thu, 16 Feb 2012 10:34:37 +0000 (18:34 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 16 Feb 2012 16:23:17 +0000 (17:23 +0100)
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: Liu Bo <liubo2009@cn.fujitsu.com>
fs/btrfs/extent_io.c

index 8d6f55fbd28e8a0564d931c9b564a2cd9b8b90d4..fe14285b53f1a49d4f39efc2a6621002ddc96fa2 100644 (file)
@@ -513,6 +513,15 @@ hit_next:
        WARN_ON(state->end < start);
        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 ---- |
         *  | state | or
@@ -565,12 +574,8 @@ hit_next:
                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);
+next:
        if (last_end == (u64)-1)
                goto out;
        start = last_end + 1;