* [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support @ 2021-04-14 9:47 Fengnan Chang 2021-04-15 1:31 ` Chao Yu 0 siblings, 1 reply; 8+ messages in thread From: Fengnan Chang @ 2021-04-14 9:47 UTC (permalink / raw) To: jaegeuk, chao; +Cc: Fengnan Chang, linux-f2fs-devel 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. Signed-off-by: Fengnan Chang <changfengnan@vivo.com> --- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/namei.c | 12 +++++++++++- fs/f2fs/super.c | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 87d734f5589d..3d5d28a2568f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -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 diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 405d85dbf9f1..09b76a7f048a 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -280,15 +280,25 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, { __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; unsigned char (*ext)[F2FS_EXTENSION_LEN]; + unsigned char (*noext)[F2FS_EXTENSION_LEN]; unsigned int ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; + unsigned int 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)) return; + if (is_inode_flag_set(inode, FI_COMPRESSED_FILE)) { + noext = F2FS_OPTION(sbi).noextensions; + for (i = 0; i < noext_cnt; i++) { + if (is_extension_exist(name, noext[i])) + f2fs_disable_compressed_file(inode); + } + return; + } + down_read(&sbi->sb_lock); cold_count = le32_to_cpu(sbi->raw_super->extension_count); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 5020152aa8fc..b5a9ba8ea869 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -153,6 +153,7 @@ enum { Opt_atgc, Opt_gc_merge, Opt_nogc_merge, + Opt_nocompress_extension, Opt_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"}, {Opt_err, NULL}, }; @@ -546,7 +548,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; @@ -1049,6 +1052,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; @@ -1072,6 +1099,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: f2fs_info(sbi, "compression options not supported"); break; #endif @@ -1664,7 +1692,10 @@ static inline void f2fs_show_compress_options(struct seq_file *seq, seq_printf(seq, ",compress_extension=%s", F2FS_OPTION(sbi).extensions[i]); } - + for (i = 0; i < F2FS_OPTION(sbi).nocompress_ext_cnt; i++) { + seq_printf(seq, ",nocompress_extension=%s", + F2FS_OPTION(sbi).noextensions[i]); + } if (F2FS_OPTION(sbi).compress_chksum) seq_puts(seq, ",compress_chksum"); -- 2.29.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support 2021-04-14 9:47 [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support Fengnan Chang @ 2021-04-15 1:31 ` Chao Yu 2021-04-15 1:56 ` [f2fs-dev] 答复: " changfengnan 0 siblings, 1 reply; 8+ messages in thread From: Chao Yu @ 2021-04-15 1:31 UTC (permalink / raw) To: Fengnan Chang; +Cc: jaegeuk, linux-f2fs-devel Hi Fengnan, On 2021/4/14 17:47, Fengnan Chang wrote: > 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. Could you please elaborate your detail usage scenario? something like in which directory, what kind of specified extension do you want to disable? It's a bit complicated for below cases: compress_extension = "abc" and nocompress_extension = "abc" or compress_extension = "*" and nocompress_extension = "abc" or compress_extension = "abc" and nocompress_extension = "*" Thanks, > > Signed-off-by: Fengnan Chang <changfengnan@vivo.com> > --- > fs/f2fs/f2fs.h | 2 ++ > fs/f2fs/namei.c | 12 +++++++++++- > fs/f2fs/super.c | 35 +++++++++++++++++++++++++++++++++-- > 3 files changed, 46 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 87d734f5589d..3d5d28a2568f 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -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 > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 405d85dbf9f1..09b76a7f048a 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -280,15 +280,25 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, > { > __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; > unsigned char (*ext)[F2FS_EXTENSION_LEN]; > + unsigned char (*noext)[F2FS_EXTENSION_LEN]; > unsigned int ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; > + unsigned int 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)) > return; > > + if (is_inode_flag_set(inode, FI_COMPRESSED_FILE)) { > + noext = F2FS_OPTION(sbi).noextensions; > + for (i = 0; i < noext_cnt; i++) { > + if (is_extension_exist(name, noext[i])) > + f2fs_disable_compressed_file(inode); > + } > + return; > + } > + > down_read(&sbi->sb_lock); > > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 5020152aa8fc..b5a9ba8ea869 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -153,6 +153,7 @@ enum { > Opt_atgc, > Opt_gc_merge, > Opt_nogc_merge, > + Opt_nocompress_extension, > Opt_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"}, > {Opt_err, NULL}, > }; > > @@ -546,7 +548,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; > @@ -1049,6 +1052,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; > @@ -1072,6 +1099,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: > f2fs_info(sbi, "compression options not supported"); > break; > #endif > @@ -1664,7 +1692,10 @@ static inline void f2fs_show_compress_options(struct seq_file *seq, > seq_printf(seq, ",compress_extension=%s", > F2FS_OPTION(sbi).extensions[i]); > } > - > + for (i = 0; i < F2FS_OPTION(sbi).nocompress_ext_cnt; i++) { > + seq_printf(seq, ",nocompress_extension=%s", > + F2FS_OPTION(sbi).noextensions[i]); > + } > if (F2FS_OPTION(sbi).compress_chksum) > seq_puts(seq, ",compress_chksum"); > > -- > 2.29.0 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > . > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support 2021-04-15 1:31 ` Chao Yu @ 2021-04-15 1:56 ` changfengnan 2021-04-17 2:43 ` Chao Yu 0 siblings, 1 reply; 8+ messages in thread From: changfengnan @ 2021-04-15 1:56 UTC (permalink / raw) To: 'Chao Yu'; +Cc: jaegeuk, linux-f2fs-devel For example, when we enables compression of the entire mounted directory, and the mounted directory used by applications, the applications may write some files that have been compressed, such as tar files and zip files, we want avoid duplicate compressions for these. As for the complex, ambiguous cases you point out, we might add some legitimacy checks. -----邮件原件----- 发件人: Chao Yu <yuchao0@huawei.com> 发送时间: 2021年4月15日 9:32 收件人: Fengnan Chang <changfengnan@vivo.com> 抄送: jaegeuk@kernel.org; chao@kernel.org; linux-f2fs-devel@lists.sourceforge.net 主题: Re: [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support Hi Fengnan, On 2021/4/14 17:47, Fengnan Chang wrote: > 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. Could you please elaborate your detail usage scenario? something like in which directory, what kind of specified extension do you want to disable? It's a bit complicated for below cases: compress_extension = "abc" and nocompress_extension = "abc" or compress_extension = "*" and nocompress_extension = "abc" or compress_extension = "abc" and nocompress_extension = "*" Thanks, > > Signed-off-by: Fengnan Chang <changfengnan@vivo.com> > --- > fs/f2fs/f2fs.h | 2 ++ > fs/f2fs/namei.c | 12 +++++++++++- > fs/f2fs/super.c | 35 +++++++++++++++++++++++++++++++++-- > 3 files changed, 46 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index > 87d734f5589d..3d5d28a2568f 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -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 > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index > 405d85dbf9f1..09b76a7f048a 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -280,15 +280,25 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, > { > __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; > unsigned char (*ext)[F2FS_EXTENSION_LEN]; > + unsigned char (*noext)[F2FS_EXTENSION_LEN]; > unsigned int ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; > + unsigned int 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)) > return; > > + if (is_inode_flag_set(inode, FI_COMPRESSED_FILE)) { > + noext = F2FS_OPTION(sbi).noextensions; > + for (i = 0; i < noext_cnt; i++) { > + if (is_extension_exist(name, noext[i])) > + f2fs_disable_compressed_file(inode); > + } > + return; > + } > + > down_read(&sbi->sb_lock); > > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index > 5020152aa8fc..b5a9ba8ea869 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -153,6 +153,7 @@ enum { > Opt_atgc, > Opt_gc_merge, > Opt_nogc_merge, > + Opt_nocompress_extension, > Opt_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"}, > {Opt_err, NULL}, > }; > > @@ -546,7 +548,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; > @@ -1049,6 +1052,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; > @@ -1072,6 +1099,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: > f2fs_info(sbi, "compression options not supported"); > break; > #endif > @@ -1664,7 +1692,10 @@ static inline void f2fs_show_compress_options(struct seq_file *seq, > seq_printf(seq, ",compress_extension=%s", > F2FS_OPTION(sbi).extensions[i]); > } > - > + for (i = 0; i < F2FS_OPTION(sbi).nocompress_ext_cnt; i++) { > + seq_printf(seq, ",nocompress_extension=%s", > + F2FS_OPTION(sbi).noextensions[i]); > + } > if (F2FS_OPTION(sbi).compress_chksum) > seq_puts(seq, ",compress_chksum"); > > -- > 2.29.0 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > . > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support 2021-04-15 1:56 ` [f2fs-dev] 答复: " changfengnan @ 2021-04-17 2:43 ` Chao Yu 2021-04-17 7:02 ` [f2fs-dev] =?y?q?Re=3A=20=5Bf2fs-dev=5D=20=E7=AD=94=E5=A4=8D=3A=20=20=5BRFC=20PATCH=5D=20f2fs=3A=20add=20no=20compress=20extensions=20support?= Fengnan Chang 0 siblings, 1 reply; 8+ messages in thread From: Chao Yu @ 2021-04-17 2:43 UTC (permalink / raw) To: changfengnan; +Cc: jaegeuk, linux-f2fs-devel On 2021/4/15 9:56, changfengnan@vivo.com wrote: > For example, when we enables compression of the entire mounted directory, > and the mounted directory used by applications, the applications may write > some > files that have been compressed, such as tar files and zip files, we want > avoid duplicate compressions for these. Yes, except that, another concern is we should figure out the access model of file, in order to avoid read/write amplification after compression. So, in your case, how do you plan to handle file which has bad compression or has random access model, but the file has no extension name? > > As for the complex, ambiguous cases you point out, we might add some > legitimacy checks. I'm not against this patch, but could you please consider more about semantics conflict in between existed compress options and the new one? Thanks, > > -----邮件原件----- > 发件人: Chao Yu <yuchao0@huawei.com> > 发送时间: 2021年4月15日 9:32 > 收件人: Fengnan Chang <changfengnan@vivo.com> > 抄送: jaegeuk@kernel.org; chao@kernel.org; > linux-f2fs-devel@lists.sourceforge.net > 主题: Re: [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support > > Hi Fengnan, > > On 2021/4/14 17:47, Fengnan Chang wrote: >> 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. > > Could you please elaborate your detail usage scenario? something like in > which directory, what kind of specified extension do you want to disable? > > It's a bit complicated for below cases: > compress_extension = "abc" and nocompress_extension = "abc" or > compress_extension = "*" and nocompress_extension = "abc" or > compress_extension = "abc" and nocompress_extension = "*" > > Thanks, > >> >> Signed-off-by: Fengnan Chang <changfengnan@vivo.com> >> --- >> fs/f2fs/f2fs.h | 2 ++ >> fs/f2fs/namei.c | 12 +++++++++++- >> fs/f2fs/super.c | 35 +++++++++++++++++++++++++++++++++-- >> 3 files changed, 46 insertions(+), 3 deletions(-) >> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index >> 87d734f5589d..3d5d28a2568f 100644 >> --- a/fs/f2fs/f2fs.h >> +++ b/fs/f2fs/f2fs.h >> @@ -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 >> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index >> 405d85dbf9f1..09b76a7f048a 100644 >> --- a/fs/f2fs/namei.c >> +++ b/fs/f2fs/namei.c >> @@ -280,15 +280,25 @@ static void set_compress_inode(struct f2fs_sb_info > *sbi, struct inode *inode, >> { >> __u8 (*extlist)[F2FS_EXTENSION_LEN] = > sbi->raw_super->extension_list; >> unsigned char (*ext)[F2FS_EXTENSION_LEN]; >> + unsigned char (*noext)[F2FS_EXTENSION_LEN]; >> unsigned int ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; >> + unsigned int 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)) >> return; >> >> + if (is_inode_flag_set(inode, FI_COMPRESSED_FILE)) { >> + noext = F2FS_OPTION(sbi).noextensions; >> + for (i = 0; i < noext_cnt; i++) { >> + if (is_extension_exist(name, noext[i])) >> + f2fs_disable_compressed_file(inode); >> + } >> + return; >> + } >> + >> down_read(&sbi->sb_lock); >> >> cold_count = le32_to_cpu(sbi->raw_super->extension_count); >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index >> 5020152aa8fc..b5a9ba8ea869 100644 >> --- a/fs/f2fs/super.c >> +++ b/fs/f2fs/super.c >> @@ -153,6 +153,7 @@ enum { >> Opt_atgc, >> Opt_gc_merge, >> Opt_nogc_merge, >> + Opt_nocompress_extension, >> Opt_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"}, >> {Opt_err, NULL}, >> }; >> >> @@ -546,7 +548,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; >> @@ -1049,6 +1052,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; >> @@ -1072,6 +1099,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: >> f2fs_info(sbi, "compression options not supported"); >> break; >> #endif >> @@ -1664,7 +1692,10 @@ static inline void > f2fs_show_compress_options(struct seq_file *seq, >> seq_printf(seq, ",compress_extension=%s", >> F2FS_OPTION(sbi).extensions[i]); >> } >> - >> + for (i = 0; i < F2FS_OPTION(sbi).nocompress_ext_cnt; i++) { >> + seq_printf(seq, ",nocompress_extension=%s", >> + F2FS_OPTION(sbi).noextensions[i]); >> + } >> if (F2FS_OPTION(sbi).compress_chksum) >> seq_puts(seq, ",compress_chksum"); >> >> -- >> 2.29.0 >> >> >> >> _______________________________________________ >> Linux-f2fs-devel mailing list >> Linux-f2fs-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel >> . >> > > > . > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* [f2fs-dev] =?y?q?Re=3A=20=5Bf2fs-dev=5D=20=E7=AD=94=E5=A4=8D=3A=20=20=5BRFC=20PATCH=5D=20f2fs=3A=20add=20no=20compress=20extensions=20support?= 2021-04-17 2:43 ` Chao Yu @ 2021-04-17 7:02 ` Fengnan Chang 2021-04-19 16:22 ` [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support Jaegeuk Kim 0 siblings, 1 reply; 8+ messages in thread From: Fengnan Chang @ 2021-04-17 7:02 UTC (permalink / raw) To: yuchao0; +Cc: jaegeuk, changfengnan, linux-f2fs-devel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=y, Size: 794 bytes --] In this patch, we cannot handle files without extensions. At the moment there is just a rough idea,test a portion of the data to decide whether to compress it before performing a full compression. It may need more test. Any other suggestions? In my consider, the non-compress flag has a higher priority than the compressed flag. 1. the same extension name cannot not appear in both compress and non-compress extension at the same time, check this in mount process. 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. If the non-compress extension specifies all files, should not specifies any compress extension, check in mount process too. Any other suggestions? Thanks. [-- Attachment #2: Type: text/plain, Size: 0 bytes --] [-- Attachment #3: Type: text/plain, Size: 179 bytes --] _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support 2021-04-17 7:02 ` [f2fs-dev] =?y?q?Re=3A=20=5Bf2fs-dev=5D=20=E7=AD=94=E5=A4=8D=3A=20=20=5BRFC=20PATCH=5D=20f2fs=3A=20add=20no=20compress=20extensions=20support?= Fengnan Chang @ 2021-04-19 16:22 ` Jaegeuk Kim 2021-04-20 2:08 ` [f2fs-dev] 答复: " changfengnan 0 siblings, 1 reply; 8+ messages in thread From: Jaegeuk Kim @ 2021-04-19 16:22 UTC (permalink / raw) To: Fengnan Chang; +Cc: changfengnan, linux-f2fs-devel On 04/17, Fengnan Chang wrote: > In this patch, we cannot handle files without extensions. At the moment there is just a rough idea,test a portion of the data to decide whether to compress it before performing a full compression. It may need more test. Any other suggestions? > > In my consider, the non-compress flag has a higher priority than the compressed flag. > 1. the same extension name cannot not appear in both compress and non-compress extension at the same time, check this in mount process. > 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. If the non-compress extension specifies all files, should not specifies any compress extension, check in mount process too. Do we need to support * for non-compress? > > Any other suggestions? So, what could the priority for all the below combinations? E.g., comp_extention, no_comp_extention, dir_flag, comp_file_flag, no_comp_file_flag. Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* [f2fs-dev] 答复: 答复: [RFC PATCH] f2fs: add no compress extensions support 2021-04-19 16:22 ` [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support Jaegeuk Kim @ 2021-04-20 2:08 ` changfengnan 2021-04-21 13:06 ` changfengnan 0 siblings, 1 reply; 8+ messages in thread From: changfengnan @ 2021-04-20 2:08 UTC (permalink / raw) To: 'Jaegeuk Kim', 'Fengnan Chang'; +Cc: linux-f2fs-devel It seems that we don't need to support * for non-compress. For now, if one file match comp_extention, the dir flag not work, but we can still use comp_file_flag and no_comp_file_flag. So the priority is: dir_flag < comp_extention < comp_file_flag, no_comp_file_flag. after add no_comp_extention flag, the priority should be: dir_flag < comp_extention < no_comp_extention < comp_file_flag, no_comp_file_flag. -----邮件原件----- 发件人: Jaegeuk Kim <jaegeuk@kernel.org> 发送时间: 2021年4月20日 0:23 收件人: Fengnan Chang <fengnanchang@gmail.com> 抄送: yuchao0@huawei.com; changfengnan@vivo.com; linux-f2fs-devel@lists.sourceforge.net 主题: Re: [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support On 04/17, Fengnan Chang wrote: > In this patch, we cannot handle files without extensions. At the moment > there is just a rough idea,test a portion of the data to decide whether > to compress it before performing a full compression. It may need more > test. Any other suggestions? > > In my consider, the non-compress flag has a higher priority than the > compressed flag. > 1. the same extension name cannot not appear in both compress and > non-compress extension at the same time, check this in mount process. > 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. If the non-compress extension specifies all files, should not specifies > any compress extension, check in mount process too. Do we need to support * for non-compress? > > Any other suggestions? So, what could the priority for all the below combinations? E.g., comp_extention, no_comp_extention, dir_flag, comp_file_flag, no_comp_file_flag. Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* [f2fs-dev] 答复: 答复: [RFC PATCH] f2fs: add no compress extensions support 2021-04-20 2:08 ` [f2fs-dev] 答复: " changfengnan @ 2021-04-21 13:06 ` changfengnan 0 siblings, 0 replies; 8+ messages in thread From: changfengnan @ 2021-04-21 13:06 UTC (permalink / raw) To: 'Jaegeuk Kim', 'Fengnan Chang'; +Cc: linux-f2fs-devel If there are no further comments, I will issue a formal patch later. -----邮件原件----- 发件人: changfengnan@vivo.com <changfengnan@vivo.com> 发送时间: 2021年4月20日 10:08 收件人: 'Jaegeuk Kim' <jaegeuk@kernel.org>; 'Fengnan Chang' <fengnanchang@gmail.com> 抄送: yuchao0@huawei.com; linux-f2fs-devel@lists.sourceforge.net 主题: 答复: [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support It seems that we don't need to support * for non-compress. For now, if one file match comp_extention, the dir flag not work, but we can still use comp_file_flag and no_comp_file_flag. So the priority is: dir_flag < comp_extention < comp_file_flag, no_comp_file_flag. after add no_comp_extention flag, the priority should be: dir_flag < comp_extention < no_comp_extention < comp_file_flag, no_comp_file_flag. -----邮件原件----- 发件人: Jaegeuk Kim <jaegeuk@kernel.org> 发送时间: 2021年4月20日 0:23 收件人: Fengnan Chang <fengnanchang@gmail.com> 抄送: yuchao0@huawei.com; changfengnan@vivo.com; linux-f2fs-devel@lists.sourceforge.net 主题: Re: [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support On 04/17, Fengnan Chang wrote: > In this patch, we cannot handle files without extensions. At the > moment there is just a rough idea,test a portion of the data to decide > whether to compress it before performing a full compression. It may > need more test. Any other suggestions? > > In my consider, the non-compress flag has a higher priority than the > compressed flag. > 1. the same extension name cannot not appear in both compress and > non-compress extension at the same time, check this in mount process. > 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. If the non-compress extension specifies all files, should not > specifies any compress extension, check in mount process too. Do we need to support * for non-compress? > > Any other suggestions? So, what could the priority for all the below combinations? E.g., comp_extention, no_comp_extention, dir_flag, comp_file_flag, no_comp_file_flag. Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-04-21 13:06 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-14 9:47 [f2fs-dev] [RFC PATCH] f2fs: add no compress extensions support Fengnan Chang 2021-04-15 1:31 ` Chao Yu 2021-04-15 1:56 ` [f2fs-dev] 答复: " changfengnan 2021-04-17 2:43 ` Chao Yu 2021-04-17 7:02 ` [f2fs-dev] =?y?q?Re=3A=20=5Bf2fs-dev=5D=20=E7=AD=94=E5=A4=8D=3A=20=20=5BRFC=20PATCH=5D=20f2fs=3A=20add=20no=20compress=20extensions=20support?= Fengnan Chang 2021-04-19 16:22 ` [f2fs-dev] 答复: [RFC PATCH] f2fs: add no compress extensions support Jaegeuk Kim 2021-04-20 2:08 ` [f2fs-dev] 答复: " changfengnan 2021-04-21 13:06 ` changfengnan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.