Add missing flags in the kernel.
v3 cover Add missing flags in the kernel.
v2->v3:
Modify BTRFS_SUPER_FLAG_SUPP so that it would fail instead of warn.
v1->v2:
Fail to mount if BTRFS_SUPER_FLAG_CHANGING_FSID is set.
Following bits are already used in user land, so bring it to the kernel as well.
#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
Anand Jain (3):
btrfs: fail mount when sb flag is not in BTRFS_SUPER_FLAG_SUPP
btrfs: define SUPER_FLAG_METADUMP_V2
btrfs: add support for SUPER_FLAG_CHANGING_FSID in btrfs.ko
fs/btrfs/disk-io.c | 6 ++++-- include/uapi/linux/btrfs_tree.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.15.0
PATCH v3 2/3 btrfs: define SUPER_FLAG_METADUMP_V2
btrfs-progs uses super flag bit BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34). So just define that in kernel so that we know its been used. This patch does not add it to BTRFS_SUPER_FLAG_SUPP yet.
--- include/uapi/linux/btrfs_tree.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/btrfs_tree.h +1 -0
@@ -456,6 +456,7 @@ struct btrfs_free_space_header {#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) +#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)/*
Signature · 1 line
2.15.0
PATCH v3 1/3 btrfs: fail mount when sb flag is not in BTRFS_SUPER_FLAG_SUPP
In reply to Anand JainIt appear from the original commit [1] that there isn't any design specific reason not to fail the mount instead of just warning. This patch will change it to fail.
[1]
commit 319e4d0661e5323c9f9945f0f8fb5905e5fe74c3
btrfs: Enhance super validation check
--- fs/btrfs/disk-io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +4 -2
@@ -3906,9 +3906,11 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info)btrfs_err (fs_info,"no valid FS found" ); ret = -EINVAL ; } -if (btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ) -btrfs_warn (fs_info,"unrecognized super flag: %llu" , +if (btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ) { +btrfs_err (fs_info,"unrecognized or unsupported super flag: %llu" ,btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ); + ret = -EINVAL ; + }if (btrfs_super_root_level (sb) >=BTRFS_MAX_LEVEL ) {btrfs_err (fs_info,"tree_root level too big: %d >= %d" ,btrfs_super_root_level (sb),BTRFS_MAX_LEVEL );
Signature · 1 line
2.15.0
PATCH v3 3/3 btrfs: add support for SUPER_FLAG_CHANGING_FSID in btrfs.ko
In reply to Anand JainUserland sets SUPER_FLAG_CHANGING_FSID and resets it only when changing fsid is complete. Its not a good idea to mount the device anything in between, so this patch fails the mount if SB SUPER_FLAG_CHANGING_FSID is set. As we don't add SUPER_FLAG_CHANGING_FSID into BTRFS_SUPER_FLAG_SUPP list, so mount will fail if SUPER_FLAG_CHANGING_FSID is set in the user land.
--- include/uapi/linux/btrfs_tree.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/btrfs_tree.h +1 -0
@@ -457,6 +457,7 @@ struct btrfs_free_space_header {#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) +#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)/*
Signature · 1 line
2.15.0
Re: [PATCH 1/3] btrfs: fail mount when sb flag is not in BTRFS_SUPER_FLAG_SUPP
In reply to Anand JainQuoted 10 lines · Anand Jain
It appear from the original commit [1] that there isn't any design specific reason not to fail the mount instead of just warning. This patch will change it to fail.
[1]
commit319e4d0661e5323c9f9945f0f8fb5905e5fe74c3
btrfs: Enhance super validation checkSigned-off-by Anand Jain <[email protected]>
The patch itself is good.
But it should be the last patch, to avoid breaking bisect.
With that fixed, feel free to add my tag:
Thanks,
Qu
Quoted 23 lines
--- fs/btrfs/disk-io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/btrfs/disk-io.c +4
-2@@ -3906,9 +3906,11 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info)btrfs_err (fs_info,"no valid FS found" ); ret = -EINVAL ; } -if (btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ) -btrfs_warn (fs_info,"unrecognized super flag: %llu" , +if (btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ) { +btrfs_err (fs_info,"unrecognized or unsupported super flag: %llu" ,btrfs_super_flags (sb) & ~BTRFS_SUPER_FLAG_SUPP ); + ret = -EINVAL ; + }if (btrfs_super_root_level (sb) >=BTRFS_MAX_LEVEL ) {btrfs_err (fs_info,"tree_root level too big: %d >= %d" ,btrfs_super_root_level (sb),BTRFS_MAX_LEVEL );
Re: [PATCH 3/3] btrfs: add support for SUPER_FLAG_CHANGING_FSID in btrfs.ko
In reply to Anand JainQuoted 9 lines · Anand Jain
Userland sets
SUPER_FLAG_CHANGING_FSIDand resets it only when changing fsid is complete. Its not a good idea to mount the device anything in between, so this patch fails the mount if SBSUPER_FLAG_CHANGING_FSIDis set. As we don't addSUPER_FLAG_CHANGING_FSIDintoBTRFS_SUPER_FLAG_SUPPlist, so mount will fail ifSUPER_FLAG_CHANGING_FSIDis set in the user land.Signed-off-by Anand Jain <[email protected]>
Thanks,
Qu
Quoted 17 lines
--- include/uapi/linux/btrfs_tree.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/btrfs_tree.h +1
-0@@ -457,6 +457,7 @@ struct btrfs_free_space_header {#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) +#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)/*
Re: [PATCH 2/3] btrfs: define SUPER_FLAG_METADUMP_V2
In reply to Anand JainQuoted 14 lines · Anand Jain
btrfs-progs uses super flag bit
BTRFS_SUPER_FLAG_METADUMP_V2(1ULL << 34). So just define that in kernel so that we know its been used. This patch does not add it toBTRFS_SUPER_FLAG_SUPPyet.Signed-off-by Anand Jain <[email protected]>--- include/uapi/linux/btrfs_tree.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/btrfs_tree.h +0
-0
include/uapi/linux/btrfs_tree.h struct btrfs_free_space_header { · line 459
Quoted 4 lines
include/uapi/linux/btrfs_tree.h +1
-0@@ -456,6 +456,7 @@ struct btrfs_free_space_header {#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) +#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
Please also include this to BTRFS_SUPER_FLAG_SUPP.
It's quite common developers (at least myself) may try to mount a recovered btrfs image.
(That's also the reason why the patch should be put before the BTRFS_SUPER_FLAG_SUPP check patch)
Thanks,
Qu
Quoted 4 lines
include/uapi/linux/btrfs_tree.h +0
-0/*
Re: [PATCH 2/3] btrfs: define SUPER_FLAG_METADUMP_V2
Quoted 24 lines · Qu Wenruo
Quoted 14 lines · Anand Jain
btrfs-progs uses super flag bit
BTRFS_SUPER_FLAG_METADUMP_V2(1ULL << 34). So just define that in kernel so that we know its been used. This patch does not add it toBTRFS_SUPER_FLAG_SUPPyet.Signed-off-by Anand Jain <[email protected]>--- include/uapi/linux/btrfs_tree.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/btrfs_tree.h +0
-0include/uapi/linux/btrfs_tree.h struct btrfs_free_space_header { · line 459
Quoted 4 lines
include/uapi/linux/btrfs_tree.h +1
-0@@ -456,6 +456,7 @@ struct btrfs_free_space_header {#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) +#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)Please also include this to
BTRFS_SUPER_FLAG_SUPP.
Quoted 5 lines
It's quite common developers (at least myself) may try to mount a recovered btrfs image.
(That's also the reason why the patch should be put before the
BTRFS_SUPER_FLAG_SUPPcheck patch)
Agreed.