aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorLiu Bo <liubo2009@cn.fujitsu.com>2012-05-10 06:10:39 -0400
committerJosef Bacik <josef@redhat.com>2012-05-30 10:23:34 -0400
commitd1ac6e41d5437385957fd708e285defd0b1a430c (patch)
tree43ca3c14aa8b5b89de1b519e326799ce594a7779 /fs/btrfs/extent_io.c
parentf8c5d0b443ff87c43ba690fa2b5bd2c9387d8624 (diff)
Btrfs: use fastpath in extent state ops as much as possible
Fully utilize our extent state's new helper functions to use fastpath as much as possible. Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com> Reviewed-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 7af93435cee0..69a527c7a0b3 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -569,10 +569,8 @@ hit_next:
569 if (err) 569 if (err)
570 goto out; 570 goto out;
571 if (state->end <= end) { 571 if (state->end <= end) {
572 clear_state_bit(tree, state, &bits, wake); 572 state = clear_state_bit(tree, state, &bits, wake);
573 if (last_end == (u64)-1) 573 goto next;
574 goto out;
575 start = last_end + 1;
576 } 574 }
577 goto search_again; 575 goto search_again;
578 } 576 }
@@ -780,7 +778,6 @@ hit_next:
780 * Just lock what we found and keep going 778 * Just lock what we found and keep going
781 */ 779 */
782 if (state->start == start && state->end <= end) { 780 if (state->start == start && state->end <= end) {
783 struct rb_node *next_node;
784 if (state->state & exclusive_bits) { 781 if (state->state & exclusive_bits) {
785 *failed_start = state->start; 782 *failed_start = state->start;
786 err = -EEXIST; 783 err = -EEXIST;
@@ -788,20 +785,15 @@ hit_next:
788 } 785 }
789 786
790 set_state_bits(tree, state, &bits); 787 set_state_bits(tree, state, &bits);
791
792 cache_state(state, cached_state); 788 cache_state(state, cached_state);
793 merge_state(tree, state); 789 merge_state(tree, state);
794 if (last_end == (u64)-1) 790 if (last_end == (u64)-1)
795 goto out; 791 goto out;
796
797 start = last_end + 1; 792 start = last_end + 1;
798 next_node = rb_next(&state->rb_node); 793 state = next_state(state);
799 if (next_node && start < end && prealloc && !need_resched()) { 794 if (start < end && state && state->start == start &&
800 state = rb_entry(next_node, struct extent_state, 795 !need_resched())
801 rb_node); 796 goto hit_next;
802 if (state->start == start)
803 goto hit_next;
804 }
805 goto search_again; 797 goto search_again;
806 } 798 }
807 799
@@ -844,6 +836,10 @@ hit_next:
844 if (last_end == (u64)-1) 836 if (last_end == (u64)-1)
845 goto out; 837 goto out;
846 start = last_end + 1; 838 start = last_end + 1;
839 state = next_state(state);
840 if (start < end && state && state->start == start &&
841 !need_resched())
842 goto hit_next;
847 } 843 }
848 goto search_again; 844 goto search_again;
849 } 845 }
@@ -993,21 +989,14 @@ hit_next:
993 * Just lock what we found and keep going 989 * Just lock what we found and keep going
994 */ 990 */
995 if (state->start == start && state->end <= end) { 991 if (state->start == start && state->end <= end) {
996 struct rb_node *next_node;
997
998 set_state_bits(tree, state, &bits); 992 set_state_bits(tree, state, &bits);
999 clear_state_bit(tree, state, &clear_bits, 0); 993 state = clear_state_bit(tree, state, &clear_bits, 0);
1000 if (last_end == (u64)-1) 994 if (last_end == (u64)-1)
1001 goto out; 995 goto out;
1002
1003 start = last_end + 1; 996 start = last_end + 1;
1004 next_node = rb_next(&state->rb_node); 997 if (start < end && state && state->start == start &&
1005 if (next_node && start < end && prealloc && !need_resched()) { 998 !need_resched())
1006 state = rb_entry(next_node, struct extent_state, 999 goto hit_next;
1007 rb_node);
1008 if (state->start == start)
1009 goto hit_next;
1010 }
1011 goto search_again; 1000 goto search_again;
1012 } 1001 }
1013 1002
@@ -1041,10 +1030,13 @@ hit_next:
1041 goto out; 1030 goto out;
1042 if (state->end <= end) { 1031 if (state->end <= end) {
1043 set_state_bits(tree, state, &bits); 1032 set_state_bits(tree, state, &bits);
1044 clear_state_bit(tree, state, &clear_bits, 0); 1033 state = clear_state_bit(tree, state, &clear_bits, 0);
1045 if (last_end == (u64)-1) 1034 if (last_end == (u64)-1)
1046 goto out; 1035 goto out;
1047 start = last_end + 1; 1036 start = last_end + 1;
1037 if (start < end && state && state->start == start &&
1038 !need_resched())
1039 goto hit_next;
1048 } 1040 }
1049 goto search_again; 1041 goto search_again;
1050 } 1042 }