Skip to contentSkip to conversation

btrfs: ctree: Dump the leaf before BUG_ON()

PATCH Superseded Qu Wenruo 5 participants 5 messages Apr 24, 2019 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: ctree: Dump the leaf before BUG_ON()

We have a user reporting BUG_ON() triggered in
btrfs_set_item_key_safe().

Let's dump the leaf content before triggering BUG_ON() so that we can have some clue on what's going wrong.
The output of tree locks should help us to debug such problem.

---
 fs/btrfs/ctree.c | 2 ++
 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
index f52eb952597b..c769a7b50ba4 100644
@@ -3185,10 +3185,12 @@ void btrfs_set_item_key_safe(struct btrfs_fs_info *fs_info,
 	slot = path->slots[0];
 	if (slot > 0) {
 		btrfs_item_key(eb, &disk_key, slot - 1);
+		btrfs_print_leaf(eb);
 		BUG_ON(comp_keys(&disk_key, new_key) >= 0);
 	}
 	if (slot < btrfs_header_nritems(eb) - 1) {
 		btrfs_item_key(eb, &disk_key, slot + 1);
+		btrfs_print_leaf(eb);
 		BUG_ON(comp_keys(&disk_key, new_key) <= 0);
 	}
 
Signature · 1 line
2.21.0
#1 lore raw
Quoted 4 lines · Qu Wenruo

Let's dump the leaf content before triggering BUG_ON() so that we can have some clue on what's going wrong.
The output of tree locks should help us to debug such problem.

The reason is some sort of in-memory corruption/confusion of the extent maps, causing overlapping extents. However so far it hasn't been possible to reproduce that on-demand to actually debug it. Filipe suspected it has to do with extent mapping merging logic. This only occurs when working with the log tree which takes its data from the in-memory extent mapping tree.

#2 lore raw
Quoted 8 lines · Nikolay Borisov
Quoted 4 lines · Qu Wenruo

Let's dump the leaf content before triggering BUG_ON() so that we can have some clue on what's going wrong.
The output of tree locks should help us to debug such problem.

Quoted 6 lines

The reason is some sort of in-memory corruption/confusion of the extent maps, causing overlapping extents. However so far it hasn't been possible to reproduce that on-demand to actually debug it. Filipe suspected it has to do with extent mapping merging logic. This only occurs when working with the log tree which takes its data from the in-memory extent mapping tree.

Anyway, this won't hurt. right?

If it gives us some clue, that's the best case. If not, it won't make the current situation worse, right?

Thanks,
Qu

#3 lore raw
Quoted 19 lines · Qu Wenruo
Quoted 8 lines · Nikolay Borisov
Quoted 4 lines · Qu Wenruo

Let's dump the leaf content before triggering BUG_ON() so that we can have some clue on what's going wrong.
The output of tree locks should help us to debug such problem.

Quoted 6 lines

The reason is some sort of in-memory corruption/confusion of the extent maps, causing overlapping extents. However so far it hasn't been possible to reproduce that on-demand to actually debug it. Filipe suspected it has to do with extent mapping merging logic. This only occurs when working with the log tree which takes its data from the in-memory extent mapping tree.

Quoted 4 lines

Anyway, this won't hurt. right?

If it gives us some clue, that's the best case. If not, it won't make the current situation worse, right?

Right, but dumping the leaf alone, may not tell you much (I've been there). Printing the new key and slot, together with the leaf dump, helps much more.

Thanks.

Quoted 3 lines

Thanks,
Qu

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
#4 lore raw
Quoted 20 lines · Filipe Manana
Quoted 19 lines · Qu Wenruo
Quoted 14 lines · Nikolay Borisov
Quoted 4 lines · Qu Wenruo

Let's dump the leaf content before triggering BUG_ON() so that we can have some clue on what's going wrong.
The output of tree locks should help us to debug such problem.

The reason is some sort of in-memory corruption/confusion of the extent maps, causing overlapping extents. However so far it hasn't been possible to reproduce that on-demand to actually debug it. Filipe suspected it has to do with extent mapping merging logic. This only occurs when working with the log tree which takes its data from the in-memory extent mapping tree.

Quoted 7 lines
Quoted 4 lines

Anyway, this won't hurt. right?

If it gives us some clue, that's the best case. If not, it won't make the current situation worse, right?

Right, but dumping the leaf alone, may not tell you much (I've been there). Printing the new key and slot, together with the leaf dump, helps much more.

Right, I'd add them.

Thanks,
Qu

Quoted 9 lines

Thanks.

Quoted 3 lines

Thanks,
Qu