From f57a68cd065320c35302a1eb8adbd80a0988536a Mon Sep 17 00:00:00 2001 From: liuh Date: Tue, 27 Aug 2024 15:30:15 +0800 Subject: [PATCH] btrfs-progs: fix the conflicting super block flags --- ...ix-the-conflicting-super-block-flags.patch | 93 +++++++++++++++++++ btrfs-progs.spec | 6 +- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch diff --git a/0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch b/0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch new file mode 100644 index 0000000..e2424f2 --- /dev/null +++ b/0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch @@ -0,0 +1,93 @@ +From 2f8a6ee294e070427a54cacce571d06062390e02 Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Sat, 8 Jun 2024 13:29:34 +0930 +Subject: [PATCH] btrfs-progs: fix the conflicting super block flags + +[BUG] +There is a bug report that a canceled checksum conversion (still +experimental feature) resulted in unexpected super flags: + +csum_type 0 (crc32c) +csum_size 4 +csum 0x14973811 [match] +bytenr 65536 +flags 0x1000000001 + ( WRITTEN | + CHANGING_FSID_V2 ) +magic _BHRfS_M [match] + +While for a filesystem under checksum conversion it should have either +CHANGING_DATA_CSUM or CHANGING_META_CSUM. + +[CAUSE] +It turns out that, due to btrfs-progs keeps its own extra flags inside +its own ctree.h headers, not the shared uapi headers, we have +conflicting super flags: + +kernel-shared/uapi/btrfs_tree.h:#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) +kernel-shared/uapi/btrfs_tree.h:#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) +kernel-shared/uapi/btrfs_tree.h:#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) +kernel-shared/ctree.h:#define BTRFS_SUPER_FLAG_CHANGING_DATA_CSUM (1ULL << 36) +kernel-shared/ctree.h:#define BTRFS_SUPER_FLAG_CHANGING_META_CSUM (1ULL << 37) + +Note that CHANGING_FSID_V2 is conflicting with CHANGING_DATA_CSUM. + +[FIX] +Cross port the proper updated uapi headers into btrfs-progs, and remove +the definition from ctree.h. + +This would change the value for CHANGING_DATA_CSUM and +CHANGING_META_CSUM, but considering they are experimental features, and +kernel would reject them anyway, the damage is not that huge and we can +accept such change before exposing it to end users. + +Pull-request: #810 +Signed-off-by: Qu Wenruo +Signed-off-by: David Sterba +--- + kernel-shared/ctree.h | 10 ---------- + kernel-shared/uapi/btrfs_tree.h | 7 +++++++ + 2 files changed, 7 insertions(+), 10 deletions(-) + +diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h +index bcf11d8..080c8c1 100644 +--- a/kernel-shared/ctree.h ++++ b/kernel-shared/ctree.h +@@ -59,16 +59,6 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes) + sizeof(struct btrfs_stripe) * (num_stripes - 1); + } + +-#define BTRFS_SUPER_FLAG_CHANGING_DATA_CSUM (1ULL << 36) +-#define BTRFS_SUPER_FLAG_CHANGING_META_CSUM (1ULL << 37) +- +-/* +- * The fs is undergoing block group tree feature change. +- * If no BLOCK_GROUP_TREE compat ro flag, it's changing from regular +- * bg item in extent tree to new bg tree. +- */ +-#define BTRFS_SUPER_FLAG_CHANGING_BG_TREE (1ULL << 38) +- + static inline u32 __BTRFS_LEAF_DATA_SIZE(u32 nodesize) + { + return nodesize - sizeof(struct btrfs_header); +diff --git a/kernel-shared/uapi/btrfs_tree.h b/kernel-shared/uapi/btrfs_tree.h +index e2ac228..2713462 100644 +--- a/kernel-shared/uapi/btrfs_tree.h ++++ b/kernel-shared/uapi/btrfs_tree.h +@@ -758,6 +758,13 @@ struct btrfs_free_space_header { + #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) + #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) + ++/* ++ * Temporaray flags utilized by btrfs-progs to do offline conversion. They are ++ * rejected by kernel. Keep them all here to avoid conflicts. ++ */ ++#define BTRFS_SUPER_FLAG_CHANGING_BG_TREE (1ULL << 38) ++#define BTRFS_SUPER_FLAG_CHANGING_DATA_CSUM (1ULL << 39) ++#define BTRFS_SUPER_FLAG_CHANGING_META_CSUM (1ULL << 40) + + /* + * items in the extent btree are used to record the objectid of the +-- +2.43.0 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index 00ba51d..70e9e7c 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 6.6.3 -Release: 10 +Release: 11 Summary: btrfs userspace programs License: GPLv2 and GPL+ and LGPL-2.1+ and GPL-3.0+ and LGPL-2.1 and MIT URL: https://btrfs.wiki.kernel.org/index.php/Main_Page @@ -15,6 +15,7 @@ Patch0006: 0006-fix-double-free-on-error-in-read_raid56.patch Patch0007: 0007-btrfs-progs-fi-show-canonicalize-path-when-using-blk.patch Patch0008: 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch Patch0009: 0009-btrfs-progs-error-out-immediately-if-an-unknown-back.patch +Patch0010: 0010-btrfs-progs-fix-the-conflicting-super-block-flags.patch BuildRequires: python3-devel >= 3.4 BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel @@ -80,6 +81,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir %{_mandir}/man8/*.gz %changelog +* Tue Aug 27 2024 liuh - 6.6.3-11 +- btrfs-progs: fix the conflicting super block flags + * Wed Jul 17 2024 liuh - 6.6.3-10 - btrfs-progs: error out immediately if an unknown backref type is found -- Gitee