Message ID | 4b9edf48c6071085f376e9861faf4dd6ecdac95b.1717966255.git.wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] btrfs: uapi: record temporary super flags utilized by btrfstune | expand |
On Mon, Jun 10, 2024 at 06:22:56AM +0930, Qu Wenruo wrote: > [BUG] > There is a bug report that a canceled csum conversion (still > experimental feature) resulted 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] > > Meanwhile for a fs under csum 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] > The proper fix would be done inside btrfs-progs, but to keep everything > properly recorded, we should have everything inside the same uapi > header. > > This patch would copy all the new flags into uapi header, and change the > value for CHANGING_DATA_CSUM and CHANGING_META_CSUM, while keep the > value of CHANGING_BG_TREE untouched. > > Thankfully csum change is still only experimental and all those > CHANGING_* flags are transient (only for btrfs-progs to resume the > conversion, and kernel will reject them all), the damage is still minor. > > Signed-off-by: Qu Wenruo <wqu@suse.com> > --- > Changelog: > v2: > - Keep the number consistent between kernel and btrfs-progs Reviewed-by: David Sterba <dsterba@suse.com> Thanks. Syncing the user space specific bits to kernel was unfortunatelly always lagging behind if done at all, now it caused a noticeable problem. Keeping the definitions in the place where one would expect it is good, the kernel<->userspace sync is ongoing but still slowly and not in full extent so you may find other examples. Every bit helps though.
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h index d24e8e121507..c7636331e566 100644 --- a/include/uapi/linux/btrfs_tree.h +++ b/include/uapi/linux/btrfs_tree.h @@ -777,6 +777,14 @@ struct btrfs_stripe_extent { #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) +/* + * Those are temporaray flags utilized by btrfs-progs to do offline conversion. + * They are rejected by kernel. + * But still 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
[BUG] There is a bug report that a canceled csum conversion (still experimental feature) resulted 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] Meanwhile for a fs under csum 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] The proper fix would be done inside btrfs-progs, but to keep everything properly recorded, we should have everything inside the same uapi header. This patch would copy all the new flags into uapi header, and change the value for CHANGING_DATA_CSUM and CHANGING_META_CSUM, while keep the value of CHANGING_BG_TREE untouched. Thankfully csum change is still only experimental and all those CHANGING_* flags are transient (only for btrfs-progs to resume the conversion, and kernel will reject them all), the damage is still minor. Signed-off-by: Qu Wenruo <wqu@suse.com> --- Changelog: v2: - Keep the number consistent between kernel and btrfs-progs --- include/uapi/linux/btrfs_tree.h | 8 ++++++++ 1 file changed, 8 insertions(+)