btrfs-progs: Enhance tree block check by checking empty leaf or node

For btrfs, it's possible to have empty leaf, but empty node is not
possible.

Add check for empty node for tree blocks.

Suggested-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2016-05-19 16:44:35 +08:00 committed by David Sterba
parent 6a0d3bf28d
commit 7c43be8b57
1 changed files with 5 additions and 0 deletions

View File

@ -67,6 +67,11 @@ static int check_tree_block(struct btrfs_fs_info *fs_info,
nodesize))
return BTRFS_BAD_NRITEMS;
/* Only leaf can be empty */
if (btrfs_header_nritems(buf) == 0 &&
btrfs_header_level(buf) != 0)
return BTRFS_BAD_NRITEMS;
fs_devices = fs_info->fs_devices;
while (fs_devices) {
if (fs_info->ignore_fsid_mismatch ||