f2fs: introduce sb.required_features to store incompatible features
Chao Yu
maintainerPATCH RESEND v3 1/1 f2fs: introduce sb.required_features to store incompatible features
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with F2FS_INCOMPAT_FEATURE_FUNCS() macro.
Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
---
v3:
- change commit title.
- fix wrong macro name.
fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)
fs/f2fs/f2fs.h +15 -0
@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */
@@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)
fs/f2fs/super.c +10 -0
@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ +if (le32_to_cpu (raw_super->required_features) & + ~F2FS_INCOMPAT_FEATURES ) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);
include/linux/f2fs_fs.h +2 -1
@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;
Signature · 1 line
2.22.0
Jaegeuk Kim
maintainerQuoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &
...
#define F2FS_FEATURE_VERITY 0x0400 /* reserved */
...
#define F2FS_FEATURE_CASEFOLD 0x1000
#define F2FS_FEATURE_SUPPORT 0x1BFF
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) {
...
return -EINVAL;
}Quoted 27 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFF
Quoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) {
...
return -EINVAL;
}Um, I thought .required_features are used to store new feature flags from 0x0.
All 'F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
Jaegeuk Kim
maintainerQuoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }
Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...
I'm thinking,
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> ok
Quoted 34 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> ok
I see, it's a bit waste for 0x1FFF low bits in sb->required_features. Why not leaving 0x0FFF in sb->feature w/o sanity check. And make all new incompatible features (including casefold) adding into sb->required_features.
Then that would be:
kernel tool
v5.2 .. 1.12
#define F2FS_FEATURE_SUPPORT 0x0000
v5.3 .. 1.13
#define F2FS_FEATURE_CASEFOLD 0x0001
#define F2FS_FEATURE_SUPPORT 0x0001
v5.4 .. 1.14
#define F2FS_FEATURE_CASEFOLD 0x0001
#define F2FS_FEATURE_COMPRESS 0x0002
#define F2FS_FEATURE_SUPPORT 0x0003
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT
v1.12 0x0000 v5.2 no_check -> ok
v1.12 0x0000 v5.3 0x0001 -> ok
v1.12 0x0000 v5.4 0x0003 -> ok
v1.13 0x0001 v5.2 that's issue we need to fix
v1.13 0x0001 v5.3 0x0001 -> ok
v1.13 0x0001 v5.4 0x0003 -> ok
v1.14 0x0003 v5.2 that's issue we need to fix
v1.14 0x0003 v5.3 0x0001 -> fail
v1.14 0x0003 v5.4 0x0003 -> ok
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
Jaegeuk Kim
maintainerQuoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> ok
Quoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.
I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define F2FS_FEATURE_CASEFOLD 0x0001
Quoted 73 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okAnd all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
Quoted 96 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 93 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> ok
Quoted 8 lines
Quoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001
Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
kernel tool
v5.2 .. 1.12
#define F2FS_FEATURE_SUPPORT 0x0BFF
v5.3 .. 1.13
#define F2FS_FEATURE_CASEFOLD 0x1000
#define F2FS_FEATURE_SUPPORT 0x1BFF
v5.4 .. 1.14
#define F2FS_FEATURE_CASEFOLD 0x1000
#define F2FS_FEATURE_COMPRESS 0x2000
#define F2FS_FEATURE_SUPPORT 0x3BFF
f2fs-tools sb->feature f2fs F2FS_FEATURE_SUPPORT
[enable all features in tools]
v1.12 0x0BFF v5.2 no_check -> ok
v1.12 0x0BFF v5.3 0x1BFF -> ok
v1.12 0x0BFF v5.4 0x3BFF -> ok
v1.13 0x1BFF v5.2 that's issue we need to fix
v1.13 0x1BFF v5.3 0x1BFF -> ok
v1.13 0x1BFF v5.4 0x3BFF -> ok
v1.14 0x3BFF v5.2 that's issue we need to fix
v1.14 0x3BFF v5.3 0x1BFF -> fail
v1.14 0x3BFF v5.4 0x3BFF -> ok
Or am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
Jaegeuk Kim
maintainerQuoted 104 lines · Chao Yu
Quoted 103 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
Quoted 6 lines
Quoted 1 line
#define
F2FS_FEATURE_CASEFOLD0x0001Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Quoted 25 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> ok
Quoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 107 lines · Jaegeuk Kim
Quoted 106 lines · Chao Yu
Quoted 104 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001
Quoted 7 lines
Quoted 4 lines
Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined F2FS_FEATURE_SUPPORT (0x0BFF) which excludes F2FS_FEATURE_VERITY (0x0400) feature bit, then once verity feature merged in kernel, we can add it into F2FS_FEATURE_SUPPORT, any problem we may face here?
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
.
Jaegeuk Kim
maintainerQuoted 113 lines · Chao Yu
Quoted 112 lines · Jaegeuk Kim
Quoted 110 lines · Chao Yu
Quoted 96 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 93 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 8 lines
Quoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Quoted 8 lines
Quoted 2 lines
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?
I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.
Quoted 115 lines
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
.
Quoted 117 lines · Jaegeuk Kim
Quoted 116 lines · Chao Yu
Quoted 114 lines · Jaegeuk Kim
Quoted 104 lines · Chao Yu
Quoted 103 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
Quoted 6 lines
Quoted 1 line
#define
F2FS_FEATURE_CASEFOLD0x0001Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Quoted 8 lines
Quoted 5 lines
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set
F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.
Yes, I can understand this.
So F2FS_FEATURE_SUPPORT can exclude them directly?
excluded:
#define F2FS_FEATURE_BLKZONED 0x0002
#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
#define F2FS_FEATURE_LOST_FOUND 0x0200
included:
#define F2FS_FEATURE_ENCRYPT 0x0001
#define F2FS_FEATURE_EXTRA_ATTR 0x0008
#define F2FS_FEATURE_PRJQUOTA 0x0010
#define F2FS_FEATURE_INODE_CHKSUM 0x0020
#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR 0x0040
#define F2FS_FEATURE_QUOTA_INO 0x0080
#define F2FS_FEATURE_INODE_CRTIME 0x0100
#define F2FS_FEATURE_SB_CHKSUM 0x0800
//#define F2FS_FEATURE_VERITY 0x0400 /* reserved */
#define F2FS_FEATURE_CASEFOLD 0x1000
#define F2FS_FEATURE_SUPPORT 0x19B9
Thanks,
Quoted 118 lines
Quoted 116 lines
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
.
.
Jaegeuk Kim
maintainerQuoted 124 lines · Chao Yu
Quoted 123 lines · Jaegeuk Kim
Quoted 121 lines · Chao Yu
Quoted 107 lines · Jaegeuk Kim
Quoted 106 lines · Chao Yu
Quoted 104 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001Quoted 7 lines
Quoted 4 lines
Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?
Quoted 6 lines
Quoted 2 lines
I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set
F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.Yes, I can understand this.
So
F2FS_FEATURE_SUPPORTcan exclude them directly?
No, I'd like to control it via mkfs. Kernel always needs to say what they can support, IIUC your point.
Quoted 142 lines
excluded:
#define
F2FS_FEATURE_BLKZONED0x0002
#defineF2FS_FEATURE_ATOMIC_WRITE0x0004
#defineF2FS_FEATURE_LOST_FOUND0x0200included:
#define
F2FS_FEATURE_ENCRYPT0x0001
#defineF2FS_FEATURE_EXTRA_ATTR0x0008
#defineF2FS_FEATURE_PRJQUOTA0x0010
#defineF2FS_FEATURE_INODE_CHKSUM0x0020
#defineF2FS_FEATURE_FLEXIBLE_INLINE_XATTR0x0040
#defineF2FS_FEATURE_QUOTA_INO0x0080
#defineF2FS_FEATURE_INODE_CRTIME0x0100
#defineF2FS_FEATURE_SB_CHKSUM0x0800
//#defineF2FS_FEATURE_VERITY0x0400/* reserved */
#defineF2FS_FEATURE_CASEFOLD0x1000#define
F2FS_FEATURE_SUPPORT0x19B9Thanks,
Quoted 118 lines
Quoted 116 lines
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
.
.
Quoted 128 lines · Jaegeuk Kim
Quoted 127 lines · Chao Yu
Quoted 125 lines · Jaegeuk Kim
Quoted 113 lines · Chao Yu
Quoted 112 lines · Jaegeuk Kim
Quoted 110 lines · Chao Yu
Quoted 96 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 93 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 58 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's bit should be added into sb.required_features field, and define new feature function with
F2FS_INCOMPAT_FEATURE_FUNCS()macro.Then during mount, we will do sanity check with enabled features in image, if there are features in sb.required_features that kernel can not recognize, just fail the mount.
Signed-off-by Chao Yu <[email protected]>---
v3:
- change commit title.
- fix wrong macro name.fs/f2fs/f2fs.h | 15 +++++++++++++++ fs/f2fs/super.c | 10 ++++++++++ include/linux/f2fs_fs.h | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-)fs/f2fs/f2fs.h +15
-0@@ -163,6 +163,15 @@ struct f2fs_mount_info {#define F2FS_CLEAR_FEATURE (sbi, mask) \ (sbi->raw_super->feature &= ~cpu_to_le32(mask)) +#define F2FS_INCOMPAT_FEATURES 0 + +#define F2FS_HAS_INCOMPAT_FEATURE (sbi, mask) \ + ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0) +#define F2FS_SET_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features |= cpu_to_le32(mask)) +#define F2FS_CLEAR_INCOMPAT_FEATURE (sbi, mask) \ + (sbi->raw_super->required_features &= ~cpu_to_le32(mask)) +/* * Default values for user and/or group using reserved blocks */ @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);F2FS_FEATURE_FUNCS (sb_chksum,SB_CHKSUM );F2FS_FEATURE_FUNCS (casefold,CASEFOLD ); +#define F2FS_INCOMPAT_FEATURE_FUNCS (name, flagname) \ +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \ +{ \ + return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \ +} +#ifdef CONFIG_BLK_DEV_ZONED static inline bool f2fs_blkz_is_seq (struct f2fs_sb_info *sbi,int devi,block_t blkaddr)fs/f2fs/super.c +0
-0fs/f2fs/super.c static int sanity_check_raw_super(struct f2fs_sb_info *sbi, · line 2517
Quoted 5 lines
fs/f2fs/super.c +2
-0@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return -EINVAL ; } +/* check whether current kernel supports all features on image */ + if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 8 lines
Quoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Quoted 8 lines
Quoted 2 lines
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set
F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.
Quoted 6 lines
Quoted 3 lines
Yes, I can understand this.
So
F2FS_FEATURE_SUPPORTcan exclude them directly?No, I'd like to control it via mkfs. Kernel always needs to say what they can support, IIUC your point.
Oh, it's different macros, we will define F2FS_INCOMPAT_FEATURE_SUPPORT 0x19B9, and F2FS_ALL_FEATURE_SUPPORT (0x0001 | 0x0002 ... ).
In sanity check function, we only check .feature with F2FS_INCOMPAT_FEATURE_SUPPORT. And of course, meanwhile kernel will say it supports features in F2FS_ALL_FEATURE_SUPPORT.
Thanks,
Quoted 145 lines
Quoted 21 lines
excluded:
#define
F2FS_FEATURE_BLKZONED0x0002
#defineF2FS_FEATURE_ATOMIC_WRITE0x0004
#defineF2FS_FEATURE_LOST_FOUND0x0200included:
#define
F2FS_FEATURE_ENCRYPT0x0001
#defineF2FS_FEATURE_EXTRA_ATTR0x0008
#defineF2FS_FEATURE_PRJQUOTA0x0010
#defineF2FS_FEATURE_INODE_CHKSUM0x0020
#defineF2FS_FEATURE_FLEXIBLE_INLINE_XATTR0x0040
#defineF2FS_FEATURE_QUOTA_INO0x0080
#defineF2FS_FEATURE_INODE_CRTIME0x0100
#defineF2FS_FEATURE_SB_CHKSUM0x0800
//#defineF2FS_FEATURE_VERITY0x0400/* reserved */
#defineF2FS_FEATURE_CASEFOLD0x1000Quoted 122 lines
#define
F2FS_FEATURE_SUPPORT0x19B9Thanks,
Quoted 118 lines
Quoted 116 lines
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
fs/f2fs/super.c +8
-0+ ~F2FS_INCOMPAT_FEATURES) { +f2fs_info (sbi,"Unsupported feature: %x: supported: %x" , +le32_to_cpu (raw_super->required_features) ^ +F2FS_INCOMPAT_FEATURES , +F2FS_INCOMPAT_FEATURES ); +return -EINVAL ; + } +/* Check checksum_offset and crc in superblock */ if (__F2FS_HAS_FEATURE (raw_super,F2FS_FEATURE_SB_CHKSUM )) { crc_offset =le32_to_cpu (raw_super->checksum_offset);include/linux/f2fs_fs.h +2
-1@@ -117,7 +117,8 @@ struct f2fs_super_block {__u8 hot_ext_count;/* # of hot file extension */ __le16 s_encoding;/* Filename charset encoding */ __le16 s_encoding_flags;/* Filename charset encoding flags */ -__u8 reserved[306 ];/* valid reserved region */ +__le32 required_features;/* incompatible features to old kernel */ +__u8 reserved[302 ];/* valid reserved region */ __le32 crc;/* checksum of superblock */ } __packed;Signature · 1 line
2.22.0.
.
.
.
.
.
Jaegeuk Kim
maintainerQuoted 136 lines · Chao Yu
Quoted 128 lines · Jaegeuk Kim
Quoted 127 lines · Chao Yu
Quoted 125 lines · Jaegeuk Kim
Quoted 113 lines · Chao Yu
Quoted 112 lines · Jaegeuk Kim
Quoted 110 lines · Chao Yu
Quoted 96 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 93 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 71 lines · Jaegeuk Kim
Quoted 63 lines · Chao Yu
From: Chao Yu <[email protected]>
Later after this patch was merged, all new incompatible feature's
bit should be added into sb.required_features field, and define new
feature function with F2FS_INCOMPAT_FEATURE_FUNCS() macro.Then during mount, we will do sanity check with enabled features in
image, if there are features in sb.required_features that kernel can
not recognize, just fail the mount.Signed-off-by: Chao Yu <[email protected]>
---
v3:
- change commit title.
- fix wrong macro name.
fs/f2fs/f2fs.h | 15 +++++++++++++++
fs/f2fs/super.c | 10 ++++++++++
include/linux/f2fs_fs.h | 3 ++-
3 files changed, 27 insertions(+), 1 deletion(-)diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a6eb828af57f..b8e17d4ddb8d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -163,6 +163,15 @@ struct f2fs_mount_info {
#define F2FS_CLEAR_FEATURE(sbi, mask) \
(sbi->raw_super->feature &= ~cpu_to_le32(mask))+#define F2FS_INCOMPAT_FEATURES 0
+
+#define F2FS_HAS_INCOMPAT_FEATURE(sbi, mask) \
+ ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0)
+#define F2FS_SET_INCOMPAT_FEATURE(sbi, mask) \
+ (sbi->raw_super->required_features |= cpu_to_le32(mask))
+#define F2FS_CLEAR_INCOMPAT_FEATURE(sbi, mask) \
+ (sbi->raw_super->required_features &= ~cpu_to_le32(mask))
+
/*
* Default values for user and/or group using reserved blocks
*/
@@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
F2FS_FEATURE_FUNCS(casefold, CASEFOLD);+#define F2FS_INCOMPAT_FEATURE_FUNCS(name, flagname) \
+static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
+{ \
+ return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \
+}
+
#ifdef CONFIG_BLK_DEV_ZONED
static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
block_t blkaddr)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5540fee0fe3f..3701dcce90e6 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
return -EINVAL;
}+ /* check whether current kernel supports all features on image */
+ if (le32_to_cpu(raw_super->required_features) &...
#defineF2FS_FEATURE_VERITY0x0400/* reserved */
...
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFQuoted 4 lines
if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) { ... return -EINVAL; }Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 8 lines
Quoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Quoted 8 lines
Quoted 2 lines
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set
F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.Quoted 6 lines
Quoted 3 lines
Yes, I can understand this.
So
F2FS_FEATURE_SUPPORTcan exclude them directly?No, I'd like to control it via mkfs. Kernel always needs to say what they can support, IIUC your point.
Quoted 6 lines
Oh, it's different macros, we will define
F2FS_INCOMPAT_FEATURE_SUPPORT0x19B9, andF2FS_ALL_FEATURE_SUPPORT(0x0001|0x0002... ).In sanity check function, we only check .feature with
F2FS_INCOMPAT_FEATURE_SUPPORT. And of course, meanwhile kernel will say it supports features inF2FS_ALL_FEATURE_SUPPORT.
Still I don't get the point where we need multiple macros. Why not user just can give required_feature in mkfs and check it by kernel later?
Quoted 148 lines
Thanks,
Quoted 145 lines
Quoted 21 lines
excluded:
#define
F2FS_FEATURE_BLKZONED0x0002
#defineF2FS_FEATURE_ATOMIC_WRITE0x0004
#defineF2FS_FEATURE_LOST_FOUND0x0200included:
#define
F2FS_FEATURE_ENCRYPT0x0001
#defineF2FS_FEATURE_EXTRA_ATTR0x0008
#defineF2FS_FEATURE_PRJQUOTA0x0010
#defineF2FS_FEATURE_INODE_CHKSUM0x0020
#defineF2FS_FEATURE_FLEXIBLE_INLINE_XATTR0x0040
#defineF2FS_FEATURE_QUOTA_INO0x0080
#defineF2FS_FEATURE_INODE_CRTIME0x0100
#defineF2FS_FEATURE_SB_CHKSUM0x0800
//#defineF2FS_FEATURE_VERITY0x0400/* reserved */
#defineF2FS_FEATURE_CASEFOLD0x1000Quoted 122 lines
#define
F2FS_FEATURE_SUPPORT0x19B9Thanks,
Quoted 118 lines
Quoted 116 lines
Thanks
Quoted 112 lines
Quoted 26 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okQuoted 84 lines
v1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
Quoted 29 lines
+ ~F2FS_INCOMPAT_FEATURES) {
+ f2fs_info(sbi, "Unsupported feature: %x: supported: %x",
+ le32_to_cpu(raw_super->required_features) ^
+ F2FS_INCOMPAT_FEATURES,
+ F2FS_INCOMPAT_FEATURES);
+ return -EINVAL;
+ }
+
/* Check checksum_offset and crc in superblock */
if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
crc_offset = le32_to_cpu(raw_super->checksum_offset);
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index a2b36b2e286f..4141be3f219c 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -117,7 +117,8 @@ struct f2fs_super_block {
__u8 hot_ext_count; /* # of hot file extension */
__le16 s_encoding; /* Filename charset encoding */
__le16 s_encoding_flags; /* Filename charset encoding flags */
- __u8 reserved[306]; /* valid reserved region */
+ __le32 required_features; /* incompatible features to old kernel */
+ __u8 reserved[302]; /* valid reserved region */
__le32 crc; /* checksum of superblock */
} __packed;--
2.22.0.
.
.
.
.
.
Quoted 137 lines · Jaegeuk Kim
Quoted 136 lines · Chao Yu
Quoted 134 lines · Jaegeuk Kim
Quoted 124 lines · Chao Yu
Quoted 123 lines · Jaegeuk Kim
Quoted 121 lines · Chao Yu
Quoted 107 lines · Jaegeuk Kim
Quoted 106 lines · Chao Yu
Quoted 104 lines · Jaegeuk Kim
Quoted 95 lines · Chao Yu
Quoted 85 lines · Jaegeuk Kim
Quoted 77 lines · Chao Yu
Quoted 75 lines · Jaegeuk Kim
On 07/29, Chao Yu wrote:
From: Chao Yu <[email protected]>Later after this patch was merged, all new incompatible feature's
bit should be added into sb.required_features field, and define new
feature function with F2FS_INCOMPAT_FEATURE_FUNCS() macro.Then during mount, we will do sanity check with enabled features in
image, if there are features in sb.required_features that kernel can
not recognize, just fail the mount.Signed-off-by: Chao Yu <[email protected]>
---
v3:
- change commit title.
- fix wrong macro name.
fs/f2fs/f2fs.h | 15 +++++++++++++++
fs/f2fs/super.c | 10 ++++++++++
include/linux/f2fs_fs.h | 3 ++-
3 files changed, 27 insertions(+), 1 deletion(-)diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index a6eb828af57f..b8e17d4ddb8d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -163,6 +163,15 @@ struct f2fs_mount_info {
#define F2FS_CLEAR_FEATURE(sbi, mask) \
(sbi->raw_super->feature &= ~cpu_to_le32(mask))+#define F2FS_INCOMPAT_FEATURES 0
+
+#define F2FS_HAS_INCOMPAT_FEATURE(sbi, mask) \
+ ((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0)
+#define F2FS_SET_INCOMPAT_FEATURE(sbi, mask) \
+ (sbi->raw_super->required_features |= cpu_to_le32(mask))
+#define F2FS_CLEAR_INCOMPAT_FEATURE(sbi, mask) \
+ (sbi->raw_super->required_features &= ~cpu_to_le32(mask))
+
/*
* Default values for user and/or group using reserved blocks
*/
@@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
F2FS_FEATURE_FUNCS(casefold, CASEFOLD);+#define F2FS_INCOMPAT_FEATURE_FUNCS(name, flagname) \
+static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
+{ \
+ return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \
+}
+
#ifdef CONFIG_BLK_DEV_ZONED
static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
block_t blkaddr)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 5540fee0fe3f..3701dcce90e6 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
return -EINVAL;
}+ /* check whether current kernel supports all features on image */
+ if (le32_to_cpu(raw_super->required_features) &...
#define F2FS_FEATURE_VERITY 0x0400 /* reserved */
...
#define F2FS_FEATURE_CASEFOLD 0x1000
#define F2FS_FEATURE_SUPPORT 0x1BFFif (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) {
...
return -EINVAL;
}Quoted 4 lines
Um, I thought .required_features are used to store new feature flags from
0x0.All '
F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of sb.required_features, I'm confused...I'm thinking,
Quoted 8 lines
f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT v0 0 v0 no_check -> ok v1 0x1BFF v0 no_check -> ok v0 0 v1 0x1BFF -> ok v1 0x1BFF v1 0x1BFF -> ok v2 0x3BFF v1 0x1BFF -> fail v1 0x1BFF v2 0x3BFF -> ok v2 0x3BFF v2 0x3BFF -> okQuoted 3 lines
I see, it's a bit waste for
0x1FFFlow bits insb->required_features. Why not leaving0x0FFFinsb->featurew/o sanity check. And make all new incompatible features (including casefold) adding intosb->required_features.I don't think we can define like this, and we still have 32bits feature filed. This would give another confusion to understand. VERITY is reserved only now.
#define
F2FS_FEATURE_CASEFOLD0x0001Quoted 7 lines
Quoted 4 lines
Oops, so you want to make .required_features being almost a mirror of .feature, and do sanity check on it... I can see now. :P
If so, why not just use .feature:
Sometimes, we don't need to set the flag, but not required at some point. (e.g., verify)
Sorry, I'm not sure whether I have understood your point... :(
IIUC of your point, we have defined
F2FS_FEATURE_SUPPORT(0x0BFF) which excludesF2FS_FEATURE_VERITY(0x0400) feature bit, then once verity feature merged in kernel, we can add it intoF2FS_FEATURE_SUPPORT, any problem we may face here?Quoted 6 lines
Quoted 2 lines
I was thinking the cases like "don't care features" made by mkfs. For example, mkfs can set
F2FS_FEATURE_BLKZONED, which doesn't need f2fs being supported.Yes, I can understand this.
So
F2FS_FEATURE_SUPPORTcan exclude them directly?No, I'd like to control it via mkfs. Kernel always needs to say what they can support, IIUC your point.
Quoted 8 lines
Quoted 6 lines
Oh, it's different macros, we will define
F2FS_INCOMPAT_FEATURE_SUPPORT0x19B9, andF2FS_ALL_FEATURE_SUPPORT(0x0001|0x0002... ).In sanity check function, we only check .feature with
F2FS_INCOMPAT_FEATURE_SUPPORT. And of course, meanwhile kernel will say it supports features inF2FS_ALL_FEATURE_SUPPORT.Still I don't get the point where we need multiple macros. Why not user just can
We don't have to, but I just meant all supported and incompatible features are different in kernel side.
Quoted 1 line
give
required_featurein mkfs and check it by kernel later?
Yes, we can, I just doubt that we don't need the field .required_features...
Because .feature has included all features user wanted, and F2FS_INCOMPAT_FEATURE_SUPPORT has included all features (need layout change) kernel need to check. I didn't get the point why we need additional field, am I missing something?
Thanks,
Quoted 143 lines
Quoted 143 lines
Thanks,
Quoted 139 lines
Quoted 139 lines
excluded:
#define
F2FS_FEATURE_BLKZONED0x0002
#defineF2FS_FEATURE_ATOMIC_WRITE0x0004
#defineF2FS_FEATURE_LOST_FOUND0x0200included:
#define
F2FS_FEATURE_ENCRYPT0x0001
#defineF2FS_FEATURE_EXTRA_ATTR0x0008
#defineF2FS_FEATURE_PRJQUOTA0x0010
#defineF2FS_FEATURE_INODE_CHKSUM0x0020
#defineF2FS_FEATURE_FLEXIBLE_INLINE_XATTR0x0040
#defineF2FS_FEATURE_QUOTA_INO0x0080
#defineF2FS_FEATURE_INODE_CRTIME0x0100
#defineF2FS_FEATURE_SB_CHKSUM0x0800
//#defineF2FS_FEATURE_VERITY0x0400/* reserved */
#defineF2FS_FEATURE_CASEFOLD0x1000#define
F2FS_FEATURE_SUPPORT0x19B9Thanks,
Quoted 114 lines
Quoted 114 lines
Thanks
Quoted 110 lines
Quoted 110 lines
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0BFFv5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_SUPPORT0x1BFFv5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x1000
#defineF2FS_FEATURE_COMPRESS0x2000
#defineF2FS_FEATURE_SUPPORT0x3BFFf2fs-tools
sb->featuref2fsF2FS_FEATURE_SUPPORT[enable all features in tools]
v1.120x0BFFv5.2no_check-> ok
v1.120x0BFFv5.30x1BFF-> ok
v1.120x0BFFv5.40x3BFF-> okv1.13
0x1BFFv5.2 that's issue we need to fix
v1.130x1BFFv5.30x1BFF-> ok
v1.130x1BFFv5.40x3BFF-> okv1.14
0x3BFFv5.2 that's issue we need to fix
v1.140x3BFFv5.30x1BFF-> fail
v1.140x3BFFv5.40x3BFF-> okOr am I missing something?
Thanks,
Quoted 76 lines
Quoted 31 lines
Then that would be:
kernel tool
v5.2 .. 1.12
#defineF2FS_FEATURE_SUPPORT0x0000v5.3 .. 1.13
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_SUPPORT0x0001v5.4 .. 1.14
#defineF2FS_FEATURE_CASEFOLD0x0001
#defineF2FS_FEATURE_COMPRESS0x0002
#defineF2FS_FEATURE_SUPPORT0x0003f2fs-tools
sb->required_featuresf2fsF2FS_FEATURE_SUPPORTv1.12
0x0000v5.2no_check-> ok
v1.120x0000v5.30x0001-> ok
v1.120x0000v5.40x0003-> okv1.13
0x0001v5.2 that's issue we need to fix
v1.130x0001v5.30x0001-> ok
v1.130x0001v5.40x0003-> okv1.14
0x0003v5.2 that's issue we need to fix
v1.140x0003v5.30x0001-> fail
v1.140x0003v5.40x0003-> okQuoted 43 lines
And all compatible features can be added into sb->feature[_VERITY, ....].
Would that okay to you?
Thanks,
Quoted 37 lines
Quoted 35 lines
Thanks,
Quoted 31 lines
+ ~F2FS_INCOMPAT_FEATURES) {
+ f2fs_info(sbi, "Unsupported feature: %x: supported: %x",
+ le32_to_cpu(raw_super->required_features) ^
+ F2FS_INCOMPAT_FEATURES,
+ F2FS_INCOMPAT_FEATURES);
+ return -EINVAL;
+ }
+
/* Check checksum_offset and crc in superblock */
if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
crc_offset = le32_to_cpu(raw_super->checksum_offset);
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index a2b36b2e286f..4141be3f219c 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -117,7 +117,8 @@ struct f2fs_super_block {
__u8 hot_ext_count; /* # of hot file extension */
__le16 s_encoding; /* Filename charset encoding */
__le16 s_encoding_flags; /* Filename charset encoding flags */
- __u8 reserved[306]; /* valid reserved region */
+ __le32 required_features; /* incompatible features to old kernel */
+ __u8 reserved[302]; /* valid reserved region */
__le32 crc; /* checksum of superblock */
} __packed;--
2.22.0
..
.
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
.
.
.
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel