f2fs: add no compress extensions support
Subsystems (2)
PATCH 1/1 f2fs: add no compress extensions support
When we create a directory with enable compression, all file write into directory will try to compress.But sometimes we may know, new file cannot meet compression ratio requirements.
We need a nocompress extension to skip those files to avoid unnecessary compress page test.
There are a few limits about no compress extensions:
1. The same extension name cannot not appear in both compress and non-compress extension at the same time.
2. If the compress extension specifies all files, the types specified by the non-compress extension will be treated as special cases and will not be compressed.
3. Don't allow the non-compress extension specifies all files.
--- Documentation/filesystems/f2fs.rst | 9 ++++ fs/f2fs/f2fs.h | 2 + fs/f2fs/namei.c | 19 +++++-- fs/f2fs/super.c | 81 ++++++++++++++++++++++++++++-- 4 files changed, 103 insertions(+), 8 deletions(-)
Documentation/filesystems/f2fs.rst +9 -0
@@ -297,6 +297,15 @@ inlinecrypt When possible, encrypt/decrypt the contents of encrypted Documentation/block/inline-encryption.rst. atgc Enable age-threshold garbage collection, it provides high effectiveness and efficiency on background GC. +nocompress_extension=%s Support adding specified extension, so that f2fs can disable + compression on those corresponding files, just contrary to compression extension. + If you know exactly which files cannot be compressed, you can use this. + The same extension name cannot not appear in both compress and non-compress + extension at the same time. + If the compress extension specifies all files, the types specified by the + non-compress extension will be treated as special cases and will not be + compressed. + Don't allow the non-compress extension specifies all files. ======================== ============================================================ Debugfs Entries
fs/f2fs/f2fs.h +2 -0
@@ -150,8 +150,10 @@ struct f2fs_mount_info {unsigned char compress_level;/* compress level */ bool compress_chksum;/* compressed data chksum */ unsigned char compress_ext_cnt;/* extension count */ +unsigned char nocompress_ext_cnt;/* nocompress extension count */ int compress_mode;/* compression mode */ unsigned char extensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/* extensions */ +unsigned char noextensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/* extensions */ };#define F2FS_FEATURE_ENCRYPT 0x0001
fs/f2fs/namei.c +15 -4
@@ -279,14 +279,16 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, const unsigned char *name) {__u8 (*extlist)[F2FS_EXTENSION_LEN ] = sbi->raw_super->extension_list; +unsigned char (*noext)[F2FS_EXTENSION_LEN ] =F2FS_OPTION (sbi).noextensions;unsigned char (*ext)[F2FS_EXTENSION_LEN ]; -unsigned int ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt;int i, cold_count, hot_count;if (!f2fs_sb_has_compression (sbi) || -is_inode_flag_set (inode,FI_COMPRESSED_FILE ) ||F2FS_I (inode)->i_flags &F2FS_NOCOMP_FL || - !f2fs_may_compress (inode)) + !f2fs_may_compress (inode) || + (!ext_cnt && !noext_cnt))return ;down_read (&sbi->sb_lock);
@@ -303,12 +305,21 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,up_read (&sbi->sb_lock); +for (i =0 ; i < noext_cnt; i++) { +if (is_extension_exist (name, noext[i])) { +f2fs_disable_compressed_file (inode); +return ; + } + } + +if (is_inode_flag_set (inode,FI_COMPRESSED_FILE )) +return ; + ext =F2FS_OPTION (sbi).extensions;for (i =0 ; i < ext_cnt; i++) {if (!is_extension_exist (name, ext[i]))continue ; -set_compress_context (inode);return ; }
fs/f2fs/super.c +77 -4
135 lines not on this page · raw message
--
2.29.0
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 4 lines · Fengnan Chang
When we create a directory with enable compression, all file write into directory will try to compress.But sometimes we may know, new file cannot meet compression ratio requirements.
We need a nocompress extension to skip those files to avoid unnecessary
Quoted 8 lines
compress page test.
There are a few limits about no compress extensions:
1. The same extension name cannot not appear in both compress and non-compress extension at the same time.
2. If the compress extension specifies all files, the types specified by the non-compress extension will be treated as special cases and will not be compressed.
3. Don't allow the non-compress extension specifies all files.
Should add priority here and in doc?
Quoted 14 lines
Signed-off-by Fengnan Chang <[email protected]>--- Documentation/filesystems/f2fs.rst | 9 ++++ fs/f2fs/f2fs.h | 2 + fs/f2fs/namei.c | 19 +++++-- fs/f2fs/super.c | 81 ++++++++++++++++++++++++++++-- 4 files changed, 103 insertions(+), 8 deletions(-)Documentation/filesystems/f2fs.rst +0
-0
Documentation/filesystems/f2fs.rst inlinecrypt When possible, encrypt/decrypt the contents of encrypted · line 303
Quoted 7 lines
Documentation/filesystems/f2fs.rst +4
-0@@ -297,6 +297,15 @@ inlinecrypt When possible, encrypt/decrypt the contents of encrypted Documentation/block/inline-encryption.rst. atgc Enable age-threshold garbage collection, it provides high effectiveness and efficiency on background GC. +nocompress_extension=%s Support adding specified extension, so that f2fs can disable + compression on those corresponding files, just contrary to compression extension. + If you know exactly which files cannot be compressed, you can use this. + The same extension name cannot not appear in both compress and non-compress
unneeded 'not'
Documentation/filesystems/f2fs.rst inlinecrypt When possible, encrypt/decrypt the contents of encrypted · line 308
Quoted 5 lines
Documentation/filesystems/f2fs.rst +5
-0+ extension at the same time. + If the compress extension specifies all files, the types specified by the + non-compress extension will be treated as special cases and will not be + compressed. + Don't allow the non-compress extension specifies all files.
Description should align as other section, and it will be better to let this stay with 'compress_extension', I mean relocate this section after 'compress_extension' one.
Quoted 52 lines
Documentation/filesystems/f2fs.rst +0
-0======================== ============================================================ Debugfs Entriesfs/f2fs/f2fs.h +2
-0@@ -150,8 +150,10 @@ struct f2fs_mount_info {unsigned char compress_level;/* compress level */ bool compress_chksum;/* compressed data chksum */ unsigned char compress_ext_cnt;/* extension count */ +unsigned char nocompress_ext_cnt;/* nocompress extension count */ int compress_mode;/* compression mode */ unsigned char extensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/* extensions */ +unsigned char noextensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/* extensions */ };#define F2FS_FEATURE_ENCRYPT 0x0001fs/f2fs/namei.c +11
-3@@ -279,14 +279,16 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, const unsigned char *name) {__u8 (*extlist)[F2FS_EXTENSION_LEN ] = sbi->raw_super->extension_list; +unsigned char (*noext)[F2FS_EXTENSION_LEN ] =F2FS_OPTION (sbi).noextensions;unsigned char (*ext)[F2FS_EXTENSION_LEN ]; -unsigned int ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt;int i, cold_count, hot_count;if (!f2fs_sb_has_compression (sbi) || -is_inode_flag_set (inode,FI_COMPRESSED_FILE ) ||F2FS_I (inode)->i_flags &F2FS_NOCOMP_FL || - !f2fs_may_compress (inode)) + !f2fs_may_compress (inode) || + (!ext_cnt && !noext_cnt))return ;down_read (&sbi->sb_lock);@@ -303,12 +305,21 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,up_read (&sbi->sb_lock); +for (i =0 ; i < noext_cnt; i++) { +if (is_extension_exist (name, noext[i])) { +f2fs_disable_compressed_file (inode); +return ; + } + }
fs/f2fs/namei.c static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, · line 311
Quoted 10 lines
fs/f2fs/namei.c +4
-1+ +if (is_inode_flag_set (inode,FI_COMPRESSED_FILE )) +return ; + ext =F2FS_OPTION (sbi).extensions;for (i =0 ; i < ext_cnt; i++) {if (!is_extension_exist (name, ext[i]))continue ; -
Unrelated change.
fs/f2fs/super.c enum { · line 156
Quoted 12 lines
fs/f2fs/namei.c +0
-0set_compress_context (inode);return ; }fs/f2fs/super.c +1
-0@@ -153,6 +153,7 @@ enum { Opt_atgc, Opt_gc_merge, Opt_nogc_merge, + Opt_nocompress_extension,
Stay with Opt_compress_extension?
fs/f2fs/super.c static match_table_t f2fs_tokens = { · line 231
Quoted 8 lines
fs/f2fs/super.c +1
-0Opt_err, };@@ -227,6 +228,7 @@ static match_table_t f2fs_tokens = { {Opt_atgc, "atgc"}, {Opt_gc_merge, "gc_merge"}, {Opt_nogc_merge, "nogc_merge"}, + {Opt_nocompress_extension, "nocompress_extension=%s"},
Ditto,
Quoted 58 lines
fs/f2fs/super.c +39
-1{Opt_err, NULL}, };@@ -473,6 +475,43 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb, } #ifdef CONFIG_F2FS_FS_COMPRESSION +/* + * 1. The same extension name cannot not appear in both compress and non-compress extension + * at the same time. + * 2. If the compress extension specifies all files, the types specified by the non-compress + * extension will be treated as special cases and will not be compressed. + * 3. Don't allow the non-compress extension specifies all files. + */ +static int f2fs_test_compress_extension(struct f2fs_sb_info *sbi) +{ + unsigned char (*ext)[F2FS_EXTENSION_LEN]; + unsigned char (*noext)[F2FS_EXTENSION_LEN]; + int ext_cnt, noext_cnt, index = 0, no_index = 0; + + ext = F2FS_OPTION(sbi).extensions; + ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; + noext = F2FS_OPTION(sbi).noextensions; + noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt; + + if (!ext_cnt || !noext_cnt) + return 0; + + for (no_index = 0; no_index < noext_cnt; no_index++) { + if (!strcasecmp("*", noext[no_index])) { + f2fs_info(sbi, "Don't allow the non-compress extension specifies all files"); + return -EINVAL; + } + for (index = 0; index < ext_cnt; index++) { + if (!strcasecmp(ext[index], noext[no_index])) { + f2fs_info(sbi, "Don't allow the same extension %s appear in both compress and non-compress extension", + ext[index]); + return -EINVAL; + } + } + } + return 0; +} + #ifdef CONFIG_F2FS_FS_LZ4 static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char *str) {@@ -546,7 +585,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)substring_t args[MAX_OPT_ARGS ];#ifdef CONFIG_F2FS_FS_COMPRESSION unsigned char (*ext)[F2FS_EXTENSION_LEN ]; -int ext_cnt; +unsigned char (*noext)[F2FS_EXTENSION_LEN ]; +int ext_cnt, noext_cnt;#endif char *p, *name;int arg =0 ;
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 635
Quoted 5 lines
fs/f2fs/super.c +1
-1@@ -592,7 +632,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)break ;case Opt_norecovery:/* this option mounts f2fs with ro */ -set_opt (sbi,NORECOVERY ); +set_opt (sbi,NORECOVERY );
Unneeded change.
Quoted 35 lines
fs/f2fs/super.c +24
-0if (!f2fs_readonly (sb))return -EINVAL ;break ;@@ -1049,6 +1089,30 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)F2FS_OPTION (sbi).compress_ext_cnt++;kfree (name);break ; +case Opt_nocompress_extension: +if (!f2fs_sb_has_compression (sbi)) { +f2fs_info (sbi,"Image doesn't support compression" ); +break ; + } + name =match_strdup (&args[0 ]); +if (!name) +return -ENOMEM ; + + noext =F2FS_OPTION (sbi).noextensions; + noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt; + +if (strlen (name) >=F2FS_EXTENSION_LEN || + noext_cnt >=COMPRESS_EXT_NUM ) { +f2fs_err (sbi, +"invalid extension length/number" ); +kfree (name); +return -EINVAL ; + } + +strcpy (noext[noext_cnt], name); +F2FS_OPTION (sbi).nocompress_ext_cnt++; +kfree (name); +break ;case Opt_compress_chksum:F2FS_OPTION (sbi).compress_chksum = true;break ;
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1139
Quoted 4 lines
fs/f2fs/super.c +1
-0@@ -1072,6 +1136,7 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)case Opt_compress_extension:case Opt_compress_chksum:case Opt_compress_mode: +case Opt_nocompress_extension:
Stay with Opt_compress_extension?
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1124
Quoted 8 lines
fs/f2fs/super.c +0
-1f2fs_info (sbi,"compression options not supported" );break ;#endif @@ -1121,7 +1186,12 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) return -EINVAL; }#endif -
Blank
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1194
Quoted 6 lines
fs/f2fs/super.c +6
-0+#ifdef CONFIG_F2FS_FS_COMPRESSION +if (f2fs_test_compress_extension (sbi)) { +f2fs_err (sbi,"invalid compress or nocompress extension" ); +return -EINVAL ; + } +#endif
Blank
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1667
Quoted 8 lines
fs/f2fs/super.c +0
-1if (F2FS_IO_SIZE_BITS (sbi) && !f2fs_lfs_mode (sbi)) {f2fs_err (sbi,"Should set mode=lfs with %uKB-sized IO" ,F2FS_IO_SIZE_KB (sbi));@@ -1664,7 +1734,10 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,seq_printf (seq,",compress_extension=%s" ,F2FS_OPTION (sbi).extensions[i]); } -
Blank
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1740
Quoted 4 lines
fs/f2fs/super.c +4
-0+for (i =0 ; i <F2FS_OPTION (sbi).nocompress_ext_cnt; i++) { +seq_printf (seq,",nocompress_extension=%s" , +F2FS_OPTION (sbi).noextensions[i]); + }
Blank
Quoted 8 lines
fs/f2fs/super.c +0
-1if (F2FS_OPTION (sbi).compress_chksum)seq_puts (seq,",compress_chksum" ); --2.29.0
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
The modification in set_compress_inode is not unrelated. When a directory is compressed, the file below is compressed too, the modification is try to deal with this.
-----邮件原件-----
发件人: Chao Yu <[email protected]>
发送时间: 2021年4月27日 20:29
收件人: Fengnan Chang <[email protected]>; [email protected]; [email protected]; [email protected] 主题: Re: [f2fs-dev] [PATCH] f2fs: add no compress extensions support
Quoted 4 lines · Fengnan Chang
When we create a directory with enable compression, all file write into directory will try to compress.But sometimes we may know, new file cannot meet compression ratio requirements.
We need a nocompress extension to skip those files to avoid
Quoted 8 lines
unnecessary compress page test.
There are a few limits about no compress extensions:
1. The same extension name cannot not appear in both compress and non-compress extension at the same time.
2. If the compress extension specifies all files, the types specified by the non-compress extension will be treated as special cases and will not be compressed.
3. Don't allow the non-compress extension specifies all files.
Should add priority here and in doc?
Documentation/filesystems/f2fs.rst inlinecrypt When possible,
Quoted 15 lines
Signed-off-by Fengnan Chang <[email protected]>--- Documentation/filesystems/f2fs.rst | 9 ++++ fs/f2fs/f2fs.h | 2 + fs/f2fs/namei.c | 19 +++++-- fs/f2fs/super.c | 81 ++++++++++++++++++++++++++++-- 4 files changed, 103 insertions(+), 8 deletions(-)Documentation/filesystems/f2fs.rst +0
-0@@ -297,6 +297,15 @@ inlinecrypt When possible,
encrypt/decrypt the contents of encrypted
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 298
Quoted 2 lines
Documentation/filesystems/f2fs.rst +0
-0Documentation/block/inline-encryption.rst. atgc Enable age-threshold garbage collection, it
provides high
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 300
Quoted 2 lines
Documentation/filesystems/f2fs.rst +1
-0effectiveness and efficiency on background GC. +nocompress_extension=%s Support adding specified extension, so that
f2fs can disable
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 301
Quoted 1 line
Documentation/filesystems/f2fs.rst +1
-0+ compression on those corresponding files, just contrary to
compression extension.
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 302
Quoted 1 line
Documentation/filesystems/f2fs.rst +1
-0+ If you know exactly which files cannot be compressed, you can
use this.
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 304
Quoted 2 lines
Documentation/filesystems/f2fs.rst +2
-0+ The same extension name cannot not appear in both +compress and non-compress
unneeded 'not'
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 306
Quoted 2 lines
Documentation/filesystems/f2fs.rst +2
-0+ extension at the same time. + If the compress extension specifies all files, the types
specified by the
Documentation/filesystems/f2fs.rst inlinecrypt When possible, · line 307
Quoted 1 line
Documentation/filesystems/f2fs.rst +1
-0+ non-compress extension will be treated as special cases and
will not be
Documentation/filesystems/f2fs.rst inlinecrypt When possible, encrypt/decrypt the contents of encrypted · line 308
Quoted 2 lines
Documentation/filesystems/f2fs.rst +2
-0+ compressed. + Don't allow the non-compress extension specifies all files.
Description should align as other section, and it will be better to let this stay with 'compress_extension', I mean relocate this section after 'compress_extension' one.
fs/f2fs/f2fs.h struct f2fs_mount_info { · line 153
Quoted 13 lines
Documentation/filesystems/f2fs.rst +0
-0====================================================================================
Debugfs Entries
fs/f2fs/f2fs.h index renamed from fs/f2fs/f2fs.h +0
-0
87d734f5589d..3d5d28a2568f100644fs/f2fs/f2fs.h +1
-0@@ -150,8 +150,10 @@ struct f2fs_mount_info {unsigned char compress_level;/* compress level */ bool compress_chksum;/* compressed data chksum */ unsigned char compress_ext_cnt;/* extension count */ +unsigned char nocompress_ext_cnt;/* nocompress
extension count */
fs/f2fs/f2fs.h struct f2fs_mount_info { · line 155
Quoted 2 lines
fs/f2fs/f2fs.h +0
-0int compress_mode;/* compression mode */ unsigned char extensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/*
extensions */
fs/f2fs/namei.c static void set_compress_inode(struct f2fs_sb_info
Quoted 11 lines
fs/f2fs/f2fs.h +2
-0+unsigned char noextensions[COMPRESS_EXT_NUM ][F2FS_EXTENSION_LEN ];/* +extensions */ };#define F2FS_FEATURE_ENCRYPT 0x0001fs/f2fs/namei.c index renamed from fs/f2fs/namei.c +0
-0
405d85dbf9f1..ab9370c3886f100644fs/f2fs/namei.c +0
-0@@ -279,14 +279,16 @@ static void set_compress_inode(struct f2fs_sb_info
*sbi, struct inode *inode,
Quoted 32 lines
fs/f2fs/namei.c +12
-3const unsigned char *name) {__u8 (*extlist)[F2FS_EXTENSION_LEN ] = sbi->raw_super->extension_list; +unsigned char (*noext)[F2FS_EXTENSION_LEN ] = +F2FS_OPTION (sbi).noextensions;unsigned char (*ext)[F2FS_EXTENSION_LEN ]; -unsigned int ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; +unsigned char noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt;int i, cold_count, hot_count;if (!f2fs_sb_has_compression (sbi) || -is_inode_flag_set (inode,FI_COMPRESSED_FILE ) ||F2FS_I (inode)->i_flags &F2FS_NOCOMP_FL || - !f2fs_may_compress (inode)) + !f2fs_may_compress (inode) || + (!ext_cnt && !noext_cnt))return ;down_read (&sbi->sb_lock);@@ -303,12 +305,21 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, up_read(&sbi->sb_lock); +for (i =0 ; i < noext_cnt; i++) { +if (is_extension_exist (name, noext[i])) { +f2fs_disable_compressed_file (inode); +return ; + } + }
fs/f2fs/namei.c static void set_compress_inode(struct · line 312
Quoted 10 lines
fs/f2fs/namei.c +4
-1+ +if (is_inode_flag_set (inode,FI_COMPRESSED_FILE )) +return ; + ext =F2FS_OPTION (sbi).extensions;for (i =0 ; i < ext_cnt; i++) {if (!is_extension_exist (name, ext[i]))continue ; -
Unrelated change.
fs/f2fs/super.c enum { · line 156
Quoted 12 lines
fs/f2fs/namei.c +0
-0set_compress_context (inode);return ;}fs/f2fs/super.c index renamed from fs/f2fs/super.c +0
-0
5020152aa8fc..04410a3831a2100644fs/f2fs/super.c +1
-0@@ -153,6 +153,7 @@ enum { Opt_atgc, Opt_gc_merge, Opt_nogc_merge, + Opt_nocompress_extension,
Stay with Opt_compress_extension?
fs/f2fs/super.c static match_table_t f2fs_tokens = { · line 231
Quoted 8 lines
fs/f2fs/super.c +1
-0Opt_err, };@@ -227,6 +228,7 @@ static match_table_t f2fs_tokens = { {Opt_atgc, "atgc"}, {Opt_gc_merge, "gc_merge"}, {Opt_nogc_merge, "nogc_merge"}, + {Opt_nocompress_extension, "nocompress_extension=%s"},
Ditto,
fs/f2fs/super.c static int f2fs_set_test_dummy_encryption(struct
Quoted 4 lines
fs/f2fs/super.c +0
-0{Opt_err, NULL}, };@@ -473,6 +475,43 @@ static int f2fs_set_test_dummy_encryption(struct
super_block *sb,
Quoted 18 lines
fs/f2fs/super.c +15
-0}#ifdef CONFIG_F2FS_FS_COMPRESSION +/* +* 1. The same extension name cannot not appear in both compress and +non-compress extension +* at the same time. +* 2. If the compress extension specifies all files, the types +specified by the non-compress +* extension will be treated as special cases and will not be compressed. +* 3. Don't allow the non-compress extension specifies all files. +*/ +static int f2fs_test_compress_extension (struct f2fs_sb_info *sbi) { +unsigned char (*ext)[F2FS_EXTENSION_LEN ]; +unsigned char (*noext)[F2FS_EXTENSION_LEN ]; +int ext_cnt, noext_cnt, index =0 , no_index =0 ; + + ext =F2FS_OPTION (sbi).extensions;
fs/f2fs/super.c static int f2fs_set_test_dummy_encryption(struct super_block *sb,
Quoted 10 lines
fs/f2fs/super.c +10
-0+ ext_cnt =F2FS_OPTION (sbi).compress_ext_cnt; + noext =F2FS_OPTION (sbi).noextensions; + noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt; + +if (!ext_cnt || !noext_cnt) +return 0 ; + +for (no_index =0 ; no_index < noext_cnt; no_index++) { +if (!strcasecmp ("*" , noext[no_index])) { + f2fs_info(sbi, "Don't allow the non-compress
extension specifies all files");
fs/f2fs/super.c static int f2fs_set_test_dummy_encryption(struct super_block *sb,
Quoted 5 lines
fs/f2fs/super.c +5
-0+return -EINVAL ; + } +for (index =0 ; index < ext_cnt; index++) { +if (!strcasecmp (ext[index], noext[no_index])) { + f2fs_info(sbi, "Don't allow the same
extension %s appear in both compress and non-compress extension",
fs/f2fs/super.c static int f2fs_set_test_dummy_encryption(struct super_block *sb,
Quoted 10 lines
fs/f2fs/super.c +8
-0+ ext[index]); +return -EINVAL ; + } + } + } +return 0 ; +} +#ifdef CONFIG_F2FS_FS_LZ4 static int f2fs_set_lz4hc_level(struct f2fs_sb_info *sbi, const char
*str)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char
Quoted 2 lines
fs/f2fs/super.c +0
-0{@@ -546,7 +585,8 @@ static int parse_options(struct super_block *sb, char
*options, bool is_remount)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char
Quoted 10 lines
fs/f2fs/super.c +2
-1substring_t args[MAX_OPT_ARGS ];#ifdef CONFIG_F2FS_FS_COMPRESSION unsigned char (*ext)[F2FS_EXTENSION_LEN ]; -int ext_cnt; +unsigned char (*noext)[F2FS_EXTENSION_LEN ]; +int ext_cnt, noext_cnt;#endif char *p, *name;int arg =0 ;@@ -592,7 +632,7 @@ static int parse_options(struct super_block *sb, char
*options, bool is_remount)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 635
Quoted 5 lines
fs/f2fs/super.c +1
-1break ;case Opt_norecovery:/* this option mounts f2fs with ro */ -set_opt (sbi,NORECOVERY ); +set_opt (sbi,NORECOVERY );
Unneeded change.
fs/f2fs/super.c static int parse_options(struct super_block *sb,
Quoted 4 lines
fs/f2fs/super.c +0
-0if (!f2fs_readonly (sb))return -EINVAL ;break ;@@ -1049,6 +1089,30 @@ static int parse_options(struct super_block *sb,
char *options, bool is_remount)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount)
Quoted 6 lines
fs/f2fs/super.c +3
-0F2FS_OPTION (sbi).compress_ext_cnt++;kfree (name);break ; +case Opt_nocompress_extension: +if (!f2fs_sb_has_compression (sbi)) { + f2fs_info(sbi, "Image doesn't support
compression");
fs/f2fs/super.c static int parse_options(struct super_block *sb,
Quoted 25 lines
fs/f2fs/super.c +21
-0+break ; + } + name =match_strdup (&args[0 ]); +if (!name) +return -ENOMEM ; + + noext =F2FS_OPTION (sbi).noextensions; + noext_cnt =F2FS_OPTION (sbi).nocompress_ext_cnt; + +if (strlen (name) >=F2FS_EXTENSION_LEN || + noext_cnt >=COMPRESS_EXT_NUM ) { +f2fs_err (sbi, +"invalid extension length/number" ); +kfree (name); +return -EINVAL ; + } + +strcpy (noext[noext_cnt], name); +F2FS_OPTION (sbi).nocompress_ext_cnt++; +kfree (name); +break ;case Opt_compress_chksum:F2FS_OPTION (sbi).compress_chksum = true;break ;@@ -1072,6 +1136,7 @@ static int parse_options(struct super_block *sb,
char *options, bool is_remount)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1139
Quoted 4 lines
fs/f2fs/super.c +1
-0case Opt_compress_extension:case Opt_compress_chksum:case Opt_compress_mode: +case Opt_nocompress_extension:
Stay with Opt_compress_extension?
fs/f2fs/super.c static int parse_options(struct super_block *sb,
Quoted 4 lines
fs/f2fs/super.c +0
-0f2fs_info (sbi,"compression options not supported" );break ;#endif @@ -1121,7 +1186,12 @@ static int parse_options(struct super_block *sb,
char *options, bool is_remount)
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1124
Quoted 4 lines
fs/f2fs/super.c +0
-1return -EINVAL; }#endif -
Blank
fs/f2fs/super.c static int parse_options(struct super_block *sb, char *options, bool is_remount) · line 1194
Quoted 6 lines
fs/f2fs/super.c +6
-0+#ifdef CONFIG_F2FS_FS_COMPRESSION +if (f2fs_test_compress_extension (sbi)) { +f2fs_err (sbi,"invalid compress or nocompress extension" ); +return -EINVAL ; + } +#endif
Blank
fs/f2fs/super.c static inline void
Quoted 4 lines
fs/f2fs/super.c +0
-0if (F2FS_IO_SIZE_BITS (sbi) && !f2fs_lfs_mode (sbi)) {f2fs_err (sbi,"Should set mode=lfs with %uKB-sized IO" ,F2FS_IO_SIZE_KB (sbi));@@ -1664,7 +1734,10 @@ static inline void
f2fs_show_compress_options(struct seq_file *seq,
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1667
Quoted 4 lines
fs/f2fs/super.c +0
-1seq_printf (seq,",compress_extension=%s" ,F2FS_OPTION (sbi).extensions[i]); } -
Blank
fs/f2fs/super.c static inline void f2fs_show_compress_options(struct seq_file *seq, · line 1740
Quoted 4 lines
fs/f2fs/super.c +4
-0+for (i =0 ; i <F2FS_OPTION (sbi).nocompress_ext_cnt; i++) { +seq_printf (seq,",nocompress_extension=%s" , +F2FS_OPTION (sbi).noextensions[i]); + }
Blank
Quoted 8 lines
fs/f2fs/super.c +0
-1if (F2FS_OPTION (sbi).compress_chksum)seq_puts (seq,",compress_chksum" ); --2.29.0
Quoted 6 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel