History

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.

Qu Wenruo committed 6 years ago

Commit 1465af11 parent e97659c2 files · +26 −5Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/btrfs_tree.h+14−0
@@ -4,6 +4,11 @@ · 3 unmodified lines
44
55 #include <linux/btrfs.h>
66 #include <linux/types.h>
7+#ifdef __KERNEL__
8+#include <linux/stddef.h>
9+#else
10+#include <stddef.h>
11+#endif
712
813 /*
914 * This header contains the structure definitions and constants used
@@ -644,6 +649,15 @@ struct btrfs_root_item { · 634 unmodified lines
644649 __le64 reserved[8]; /* for future */
645650 } __attribute__ ((__packed__));
646651
652+/*
653+ * Btrfs root item used to be smaller than current size. The old format ends
654+ * at where member generation_v2 is.
655+ */
656+static inline __u32 btrfs_legacy_root_item_size(void)
657+{
658+ return offsetof(struct btrfs_root_item, generation_v2);
659+}
660+
647661 /*
648662 * this is used for both forward and backward root refs
649663 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t