diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-08-20 08:51:50 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:06 -0400 |
commit | 7c2fe32a238eb12422beca5cbd5194a594baa559 (patch) | |
tree | a95bada9d991780e0611e94529e63c8178f4f3be /fs/btrfs/extent_map.c | |
parent | 902b22f341efa00be802418a0a8c57bddcd269a6 (diff) |
Btrfs: Fix add_extent_mapping to check for duplicates across the whole range
add_extent_mapping was allowing the insertion of overlapping extents.
This never used to happen because it only inserted the extents from disk
and those were never overlapping.
But, with the data=ordered code, the disk and memory representations of the
file are not the same. add_extent_mapping needs to ensure a new extent
does not overlap before it inserts.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r-- | fs/btrfs/extent_map.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index 954b047639ab..78ced11d18c7 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c | |||
@@ -207,7 +207,14 @@ int add_extent_mapping(struct extent_map_tree *tree, | |||
207 | int ret = 0; | 207 | int ret = 0; |
208 | struct extent_map *merge = NULL; | 208 | struct extent_map *merge = NULL; |
209 | struct rb_node *rb; | 209 | struct rb_node *rb; |
210 | struct extent_map *exist; | ||
210 | 211 | ||
212 | exist = lookup_extent_mapping(tree, em->start, em->len); | ||
213 | if (exist) { | ||
214 | free_extent_map(exist); | ||
215 | ret = -EEXIST; | ||
216 | goto out; | ||
217 | } | ||
211 | assert_spin_locked(&tree->lock); | 218 | assert_spin_locked(&tree->lock); |
212 | rb = tree_insert(&tree->map, em->start, &em->rb_node); | 219 | rb = tree_insert(&tree->map, em->start, &em->rb_node); |
213 | if (rb) { | 220 | if (rb) { |