aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/inode.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f9fd8b14ef08..4ab713bd4139 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7153,19 +7153,12 @@ insert:
7153 * existing will always be non-NULL, since there must be 7153 * existing will always be non-NULL, since there must be
7154 * extent causing the -EEXIST. 7154 * extent causing the -EEXIST.
7155 */ 7155 */
7156 if (existing->start == em->start && 7156 if (start >= existing->start &&
7157 extent_map_end(existing) >= extent_map_end(em) && 7157 start < extent_map_end(existing)) {
7158 em->block_start == existing->block_start) {
7159 /*
7160 * The existing extent map already encompasses the
7161 * entire extent map we tried to add.
7162 */
7163 free_extent_map(em); 7158 free_extent_map(em);
7164 em = existing; 7159 em = existing;
7165 err = 0; 7160 err = 0;
7166 7161 } else {
7167 } else if (start >= extent_map_end(existing) ||
7168 start <= existing->start) {
7169 /* 7162 /*
7170 * The existing extent map is the one nearest to 7163 * The existing extent map is the one nearest to
7171 * the [start, start + len) range which overlaps 7164 * the [start, start + len) range which overlaps
@@ -7177,10 +7170,6 @@ insert:
7177 free_extent_map(em); 7170 free_extent_map(em);
7178 em = NULL; 7171 em = NULL;
7179 } 7172 }
7180 } else {
7181 free_extent_map(em);
7182 em = existing;
7183 err = 0;
7184 } 7173 }
7185 } 7174 }
7186 write_unlock(&em_tree->lock); 7175 write_unlock(&em_tree->lock);