aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index e3a25be5c663..8bd1b402f3fd 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -292,7 +292,7 @@ static int merge_state(struct extent_io_tree *tree,
292 struct extent_state *other; 292 struct extent_state *other;
293 struct rb_node *other_node; 293 struct rb_node *other_node;
294 294
295 if (state->state & EXTENT_IOBITS) 295 if (state->state & (EXTENT_IOBITS | EXTENT_BOUNDARY))
296 return 0; 296 return 0;
297 297
298 other_node = rb_prev(&state->rb_node); 298 other_node = rb_prev(&state->rb_node);
@@ -1070,7 +1070,8 @@ search_again:
1070 1070
1071 while(1) { 1071 while(1) {
1072 state = rb_entry(node, struct extent_state, rb_node); 1072 state = rb_entry(node, struct extent_state, rb_node);
1073 if (found && state->start != cur_start) { 1073 if (found && (state->start != cur_start ||
1074 (state->state & EXTENT_BOUNDARY))) {
1074 goto out; 1075 goto out;
1075 } 1076 }
1076 if (!(state->state & EXTENT_DELALLOC)) { 1077 if (!(state->state & EXTENT_DELALLOC)) {
@@ -1078,7 +1079,7 @@ search_again:
1078 *end = state->end; 1079 *end = state->end;
1079 goto out; 1080 goto out;
1080 } 1081 }
1081 if (!found) { 1082 if (!found && !(state->state & EXTENT_BOUNDARY)) {
1082 struct extent_state *prev_state; 1083 struct extent_state *prev_state;
1083 struct rb_node *prev_node = node; 1084 struct rb_node *prev_node = node;
1084 while(1) { 1085 while(1) {
@@ -1088,7 +1089,11 @@ search_again:
1088 prev_state = rb_entry(prev_node, 1089 prev_state = rb_entry(prev_node,
1089 struct extent_state, 1090 struct extent_state,
1090 rb_node); 1091 rb_node);
1091 if (!(prev_state->state & EXTENT_DELALLOC)) 1092 if ((prev_state->end + 1 != state->start) ||
1093 !(prev_state->state & EXTENT_DELALLOC))
1094 break;
1095 if ((cur_start - prev_state->start) * 2 >
1096 max_bytes)
1092 break; 1097 break;
1093 state = prev_state; 1098 state = prev_state;
1094 node = prev_node; 1099 node = prev_node;