Skip to contentSkip to conversation

Btrfs: do not merge logged extents if we've removed them from the tree

PATCH In review Josef Bacik 3 participants 5 messages Jan 28, 2013 – Jan 29, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: do not merge logged extents if we've removed them from the tree

You can run into this problem where if somebody is fsyncing and writing out the existing extents you will have removed the extent map from the em tree, but it's still valid for the current fsync so we go ahead and write it. The problem is we unconditionally try to merge it back into the em tree, but if we've removed it from the em tree that will cause problems. So fix this by only trying to merge it in if it is still a part of the tree. Thanks,

---
 fs/btrfs/extent_map.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/extent_map.c +2 -1
index ed88f5e..9759911 100644
@@ -289,7 +289,8 @@ out:
 void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em)
 {
 	clear_bit(EXTENT_FLAG_LOGGING, &em->flags);
-	try_merge_map(tree, em);
+	if (em->in_tree)
+		try_merge_map(tree, em);
 }
 
 /**
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 2 lines

problem is we unconditionally try to merge it back into the em tree, but if we've removed it from the em tree that will cause problems. So fix this by

What problems? If I were staring at the symptoms of this bug how would I find that this commit fixes it?

- z

#2 lore raw
Quoted 6 lines · Zach Brown
Quoted 2 lines

problem is we unconditionally try to merge it back into the em tree, but if we've removed it from the em tree that will cause problems. So fix this by

What problems? If I were staring at the symptoms of this bug how would I find that this commit fixes it?

I'll fix the commit message, we just add something to the tree that doesn't have a ref so it's a basic use after free sort of scenario. Thanks,

Josef

Quoted 1 line

- z

#3 lore raw
Quoted 2 lines

I'll fix the commit message, we just add something to the tree that doesn't have a ref so it's a basic use after free sort of scenario. Thanks,

Thanks, complete commit messages help us old farts keep up.

- z

Reviewed-by on v1 1/1
#4 lore raw
In reply to Josef Bacik
Quoted 7 lines · Josef Bacik

You can run into this problem where if somebody is fsyncing and writing out the existing extents you will have removed the extent map from the em tree, but it's still valid for the current fsync so we go ahead and write it. The problem is we unconditionally try to merge it back into the em tree, but if we've removed it from the em tree that will cause problems. So fix this by only trying to merge it in if it is still a part of the tree. Thanks,

Quoted 26 lines
---
 fs/btrfs/extent_map.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
fs/btrfs/extent_map.c +2 -1
index ed88f5e..9759911 100644
@@ -289,7 +289,8 @@ out:
 void clear_em_logging(struct extent_map_tree *tree, struct extent_map *em)
 {
 	clear_bit(EXTENT_FLAG_LOGGING, &em->flags);
-	try_merge_map(tree, em);
+	if (em->in_tree)
+		try_merge_map(tree, em);
 }
 
 /**
Signature · 6 lines
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html