aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2016-05-19 16:44:35 +0800
committerDavid Sterba <dsterba@suse.com>2016-06-01 14:56:56 +0200
commit7c43be8b578ba0133f18beb20d46c68e0225f941 (patch)
treebae2f4c0f49cf1ba65993706ed1a39b475d5e53d /disk-io.c
parent6a0d3bf28d42b9b4249056b213636952d4575ace (diff)
downloadbtrfs-progs-7c43be8b578ba0133f18beb20d46c68e0225f941.tar.gz
btrfs-progs-7c43be8b578ba0133f18beb20d46c68e0225f941.tar.xz
btrfs-progs-7c43be8b578ba0133f18beb20d46c68e0225f941.zip
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>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/disk-io.c b/disk-io.c
index 86abdeb..b4f185f 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -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 ||