btrfs: output more info when duplicated ordered extent is found

During development of a new feature, I triggered that btrfs_panic()
inside insert_ordered_extent() and spent quite some unnecessary before
noticing I'm passing incorrect flags when creating a new ordered extent.

Unfortunately the existing error message is not providing much help.

Enhance the output to provide file offset, num bytes and flags of both
existing and new ordered extents.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2026-03-14 10:30:39 +10:30 committed by David Sterba
parent 232770bcf3
commit 3c53ad7549

View File

@ -253,10 +253,15 @@ static void insert_ordered_extent(struct btrfs_ordered_extent *entry)
spin_lock(&inode->ordered_tree_lock);
node = tree_insert(&inode->ordered_tree, entry->file_offset,
&entry->rb_node);
if (unlikely(node))
if (unlikely(node)) {
struct btrfs_ordered_extent *exist =
rb_entry(node, struct btrfs_ordered_extent, rb_node);
btrfs_panic(fs_info, -EEXIST,
"inconsistency in ordered tree at offset %llu",
entry->file_offset);
"overlapping ordered extents, existing oe file_offset %llu num_bytes %llu flags 0x%lx, new oe file_offset %llu num_bytes %llu flags 0x%lx",
exist->file_offset, exist->num_bytes, exist->flags,
entry->file_offset, entry->num_bytes, entry->flags);
}
spin_unlock(&inode->ordered_tree_lock);
spin_lock(&root->ordered_extent_lock);