Skip to content

Commit 1f21ef0

Browse files
fdmananamasoncl
authored andcommitted
Btrfs: check if items are ordered when a leaf is marked dirty
To ease finding bugs during development related to modifying btree leaves in such a way that it makes its items not sorted by key anymore. Since this is an expensive check, it's only enabled if CONFIG_BTRFS_FS_CHECK_INTEGRITY is set, which isn't meant to be enabled for regular users. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
1 parent 35045bf commit 1f21ef0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,6 +3738,12 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
37383738
__percpu_counter_add(&root->fs_info->dirty_metadata_bytes,
37393739
buf->len,
37403740
root->fs_info->dirty_metadata_batch);
3741+
#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
3742+
if (btrfs_header_level(buf) == 0 && check_leaf(root, buf)) {
3743+
btrfs_print_leaf(root, buf);
3744+
ASSERT(0);
3745+
}
3746+
#endif
37413747
}
37423748

37433749
static void __btrfs_btree_balance_dirty(struct btrfs_root *root,

0 commit comments

Comments
 (0)