btrfs: tree-checker: fix false alert caused by legacy btrfs root item
authorQu Wenruo <wqu@suse.com>
Tue, 22 Sep 2020 02:37:01 +0000 (10:37 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:13:23 +0000 (12:13 +0200)
commit1465af12e254a68706e110846f59cf0f09683184
tree1720a50ff0d674e104c28f5653194c20f65855dd
parente97659cefe1e9dc0bb4284195ba4ab380d0cf1fe
btrfs: tree-checker: fix false alert caused by legacy btrfs root item

Commit 259ee7754b67 ("btrfs: tree-checker: Add ROOT_ITEM check")
introduced btrfs root item size check, however btrfs root item has two
versions, the legacy one which just ends before generation_v2 member, is
smaller than current btrfs root item size.

This caused btrfs kernel to reject valid but old tree root leaves.

Fix this problem by also allowing legacy root item, since kernel can
already handle them pretty well and upgrade to newer root item format
when needed.

Reported-by: Martin Steigerwald <martin@lichtvoll.de>
Fixes: 259ee7754b67 ("btrfs: tree-checker: Add ROOT_ITEM check")
CC: stable@vger.kernel.org # 5.4+
Tested-By: Martin Steigerwald <martin@lichtvoll.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-checker.c
include/uapi/linux/btrfs_tree.h