You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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>
This commit is contained in:
@@ -207,7 +207,14 @@ int add_extent_mapping(struct extent_map_tree *tree,
|
||||
int ret = 0;
|
||||
struct extent_map *merge = NULL;
|
||||
struct rb_node *rb;
|
||||
struct extent_map *exist;
|
||||
|
||||
exist = lookup_extent_mapping(tree, em->start, em->len);
|
||||
if (exist) {
|
||||
free_extent_map(exist);
|
||||
ret = -EEXIST;
|
||||
goto out;
|
||||
}
|
||||
assert_spin_locked(&tree->lock);
|
||||
rb = tree_insert(&tree->map, em->start, &em->rb_node);
|
||||
if (rb) {
|
||||
|
||||
Reference in New Issue
Block a user