Message ID | 20230606203645.3926651-1-jaegeuk@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3665352vqr; Tue, 6 Jun 2023 13:59:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56iZVIzH+ZtFRMYbso37+BfzmAOR3Gdi93Fi90Cq6hNA03YoVwxGEMgO11jezlBcra41A/ X-Received: by 2002:a17:90a:f518:b0:255:cddf:a0c8 with SMTP id cs24-20020a17090af51800b00255cddfa0c8mr2858147pjb.41.1686085163440; Tue, 06 Jun 2023 13:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686085163; cv=none; d=google.com; s=arc-20160816; b=AaDkkPpzHC/E0C98BlvcmcoUEqb+WdW0fyytUE5TCBkAsEXlzOB/PdW2AAjdj9UXjr yYbCEXVvfYHBJ5uMFoq9OBTd0G6WGBvPGw/dsbqopO9274t6cxRElE2W6U/lKsnsZNzk BV6AjauLTAu+AFmbD27/HldElZrMotUodqq30aFJljwzzW+3aOWh0YYN8SffnPBX/e3P z2YL/iBJS+XZZQKEp74LebTmGZcULoI8wGRJvWMeBdY2vN2NA3oh5VqvFsTjmpCyrkFx Z6UuOfT79p7q/11maqja4bLQHNfcjhKjE4OWBIo7HpyphVkyhRtEPCAWVhZfllhZHVcF wswA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bZlwSCjTyONyM6BfdlEEszOvDKo4//CkyOFwKo/Rm5w=; b=AZ33/gvzIaIpk/PIY/Vyrgd742gETihNgE1C6N6g9suVMotnCZU//h4OLcvooJE4AT r7+8Lu409hoMG3AVLTlid/vfOfAd7rg1HzX5mj3n6sftKr6Uaq9T76cSo/J/9/BXqZKj sbOIWL7wqJznPU3Q6iS/oS1BaePYBxm5auozeIWTrL+Yxwt/Wwvsqli9mjNivWt2I1pK Pa4+XdFD2+IifuSihlhNnvIkixxd4sVim+f2zHjTzcYpjimp0DgkHfXSHaUcGXwwE0Rk mjf+bYR1TmjYExyE8GShmGFLJ3448OZUcR97tbJ/oCj8NmCFhzc1sawotttQY1rx0gFq UkeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=grmxwQPi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id co10-20020a17090afe8a00b0025339314a7bsi9526317pjb.79.2023.06.06.13.59.10; Tue, 06 Jun 2023 13:59:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=grmxwQPi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232511AbjFFUgx (ORCPT <rfc822;xxoosimple@gmail.com> + 99 others); Tue, 6 Jun 2023 16:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjFFUgu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 6 Jun 2023 16:36:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC5C91A7 for <linux-kernel@vger.kernel.org>; Tue, 6 Jun 2023 13:36:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E6E66380A for <linux-kernel@vger.kernel.org>; Tue, 6 Jun 2023 20:36:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B52A6C433D2; Tue, 6 Jun 2023 20:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686083808; bh=0cYUz6iSpj0eGwIL3jk2KHuInnAfLbouhLwJjaUDn/U=; h=From:To:Cc:Subject:Date:From; b=grmxwQPihJZONINOr57RH3NFIbNisnRHwKJOkoK1+XFzKQ9/U8SF/YIRWEKwBCVNK KYuGs7WfGbxp9X+IqWMqiRBsXKGhAO8uFUzWX3sZ79ppoEH9pypErF1/wXxfbWF9mf gqQtV/VZE143HcdJwoHokLSMb8ZmUjZnzSy1ZhINqnH0NxOPgDLhoOkX5NpI4mIkKZ WccMw5QkjpTROKGyDNqBMXYB8OX7Qu1IcNssR3BVROAaCW3RiFWUf8QUWczS1fgUz2 xZVBmhQnXAKOOWJpg/vys8Jl4FlzELW6Hfr+i7wPT4BGjk/mjIoAM59IEXZFknDB1B Y2QAwpiuFRmig== From: Jaegeuk Kim <jaegeuk@kernel.org> To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim <jaegeuk@kernel.org> Subject: [PATCH] f2fs: compress tmp files given extension Date: Tue, 6 Jun 2023 13:36:45 -0700 Message-ID: <20230606203645.3926651-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767988436053866508?= X-GMAIL-MSGID: =?utf-8?q?1767988436053866508?= |
Series |
f2fs: compress tmp files given extension
|
|
Commit Message
Jaegeuk Kim
June 6, 2023, 8:36 p.m. UTC
Let's compress tmp files for the given extension list.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/namei.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 2023/6/7 4:36, Jaegeuk Kim wrote: > Let's compress tmp files for the given extension list. Could you please check below commit? IIRC, it was introduce to avoid compressing file which has unpredictable tmp file, e.g. foo.sox. Could you please describe the case you encounter? commit 4a67d9b07ac8dce7f1034e0d887f2f4ee00fe118 Author: Chao Yu <chao@kernel.org> Date: Tue May 18 17:54:58 2021 +0800 f2fs: compress: fix to disallow temp extension This patch restricts to configure compress extension as format of: [filename + '.' + extension] rather than: [filename + '.' + extension + (optional: '.' + temp extension)] in order to avoid to enable compression incorrectly: 1. compress_extension=so 2. touch file.soa 3. touch file.so.tmp Thanks, > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > --- > fs/f2fs/namei.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 3e35eb7dbb8f..cdc94c8e60f7 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -161,7 +161,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Compress wanting extension. */ > for (i = 0; i < ext_cnt; i++) { > - if (is_extension_exist(name, ext[i], false)) { > + if (is_extension_exist(name, ext[i], true)) { > set_compress_context(inode); > return; > }
On 06/12, Chao Yu wrote: > On 2023/6/7 4:36, Jaegeuk Kim wrote: > > Let's compress tmp files for the given extension list. > > Could you please check below commit? IIRC, it was introduce to avoid compressing > file which has unpredictable tmp file, e.g. foo.sox. > > Could you please describe the case you encounter? I don't know what I need to describe more tho, looking at how to compress abc.so.tmp and abc.so, given compress_extension=so. So, your concern is somehow abc.soa? If so, we need to fix is_extension_exist. Will check what's going on here. > > commit 4a67d9b07ac8dce7f1034e0d887f2f4ee00fe118 > Author: Chao Yu <chao@kernel.org> > Date: Tue May 18 17:54:58 2021 +0800 > > f2fs: compress: fix to disallow temp extension > > This patch restricts to configure compress extension as format of: > > [filename + '.' + extension] > > rather than: > > [filename + '.' + extension + (optional: '.' + temp extension)] > > in order to avoid to enable compression incorrectly: > > 1. compress_extension=so > 2. touch file.soa > 3. touch file.so.tmp > > Thanks, > > > > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > > --- > > fs/f2fs/namei.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > > index 3e35eb7dbb8f..cdc94c8e60f7 100644 > > --- a/fs/f2fs/namei.c > > +++ b/fs/f2fs/namei.c > > @@ -161,7 +161,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Compress wanting extension. */ > > for (i = 0; i < ext_cnt; i++) { > > - if (is_extension_exist(name, ext[i], false)) { > > + if (is_extension_exist(name, ext[i], true)) { > > set_compress_context(inode); > > return; > > }
On 2023/6/12 23:36, Jaegeuk Kim wrote: > On 06/12, Chao Yu wrote: >> On 2023/6/7 4:36, Jaegeuk Kim wrote: >>> Let's compress tmp files for the given extension list. >> >> Could you please check below commit? IIRC, it was introduce to avoid compressing >> file which has unpredictable tmp file, e.g. foo.sox. >> >> Could you please describe the case you encounter? > > I don't know what I need to describe more tho, looking at how to compress Oh, I just like to know which case you want to cover: foo.so.tmp or foo.sotmp. > abc.so.tmp and abc.so, given compress_extension=so. Copied. > > So, your concern is somehow abc.soa? If so, we need to fix is_extension_exist. Yes, is_extension_exist(, true) accepts optional '.' while parsing file extension. [filename + '.' + extension + (optional: '.' + temp extension)] It is used to support parsing common prefix for cold file's extension, we can add a parameter for is_extension_exist() to disable prefix parsing for compress file extension? const char *media_ext_lists[] = { /* common prefix */ "mp", // Covers mp3, mp4, mpeg, mpg "wm", // Covers wma, wmb, wmv "og", // Covers oga, ogg, ogm, ogv "jp", // Covers jpg, jpeg, jp2 ... } Thanks, > Will check what's going on here. > >> >> commit 4a67d9b07ac8dce7f1034e0d887f2f4ee00fe118 >> Author: Chao Yu <chao@kernel.org> >> Date: Tue May 18 17:54:58 2021 +0800 >> >> f2fs: compress: fix to disallow temp extension >> >> This patch restricts to configure compress extension as format of: >> >> [filename + '.' + extension] >> >> rather than: >> >> [filename + '.' + extension + (optional: '.' + temp extension)] >> >> in order to avoid to enable compression incorrectly: >> >> 1. compress_extension=so >> 2. touch file.soa >> 3. touch file.so.tmp >> >> Thanks, >> >>> >>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> >>> --- >>> fs/f2fs/namei.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c >>> index 3e35eb7dbb8f..cdc94c8e60f7 100644 >>> --- a/fs/f2fs/namei.c >>> +++ b/fs/f2fs/namei.c >>> @@ -161,7 +161,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, >>> /* Compress wanting extension. */ >>> for (i = 0; i < ext_cnt; i++) { >>> - if (is_extension_exist(name, ext[i], false)) { >>> + if (is_extension_exist(name, ext[i], true)) { >>> set_compress_context(inode); >>> return; >>> }
Let's compress tmp files for the given extension list.
This patch does not change the previous behavior, but allow the cases as below.
Extention example: "ext"
- abc.ext : allow
- abc.ext.abc : allow
- abc.extm : not allow
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Change log from v1:
- refactor to allow abc.ext.dontcare only
fs/f2fs/namei.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 3e35eb7dbb8f..49573ef4115d 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -23,7 +23,7 @@
#include <trace/events/f2fs.h>
static inline bool is_extension_exist(const unsigned char *s, const char *sub,
- bool tmp_ext)
+ bool tmp_ext, bool tmp_dot)
{
size_t slen = strlen(s);
size_t sublen = strlen(sub);
@@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub,
for (i = 1; i < slen - sublen; i++) {
if (s[i] != '.')
continue;
- if (!strncasecmp(s + i + 1, sub, sublen))
- return true;
+ if (!strncasecmp(s + i + 1, sub, sublen)) {
+ if (!tmp_dot)
+ return true;
+ if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.')
+ return true;
+ }
}
return false;
@@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = cold_count; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], false))
+ if (is_extension_exist(name, extlist[i], false, false))
break;
f2fs_up_read(&sbi->sb_lock);
if (i < (cold_count + hot_count))
@@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
/* Don't compress unallowed extension. */
for (i = 0; i < noext_cnt; i++)
- if (is_extension_exist(name, noext[i], false))
+ if (is_extension_exist(name, noext[i], false, false))
return;
/* Compress wanting extension. */
for (i = 0; i < ext_cnt; i++) {
- if (is_extension_exist(name, ext[i], false)) {
+ if (is_extension_exist(name, ext[i], true, true)) {
set_compress_context(inode);
return;
}
@@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = 0; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], true))
+ if (is_extension_exist(name, extlist[i], true, false))
break;
f2fs_up_read(&sbi->sb_lock);
On 2023/6/14 6:14, Jaegeuk Kim wrote: > Let's compress tmp files for the given extension list. > > This patch does not change the previous behavior, but allow the cases as below. > > Extention example: "ext" > > - abc.ext : allow > - abc.ext.abc : allow > - abc.extm : not allow > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > --- > > Change log from v1: > - refactor to allow abc.ext.dontcare only > > fs/f2fs/namei.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 3e35eb7dbb8f..49573ef4115d 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -23,7 +23,7 @@ > #include <trace/events/f2fs.h> > > static inline bool is_extension_exist(const unsigned char *s, const char *sub, > - bool tmp_ext) > + bool tmp_ext, bool tmp_dot) > { > size_t slen = strlen(s); > size_t sublen = strlen(sub); > @@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub, > for (i = 1; i < slen - sublen; i++) { > if (s[i] != '.') > continue; > - if (!strncasecmp(s + i + 1, sub, sublen)) > - return true; > + if (!strncasecmp(s + i + 1, sub, sublen)) { > + if (!tmp_dot) > + return true; > + if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.') Do you mean? if (i == slen - sublen - 1 && s[i + 1 + sublen] == '.') > + return true; > + } > } > > return false; > @@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = cold_count; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], false)) > + if (is_extension_exist(name, extlist[i], false, false)) Parameters should be consistent w/ the one in set_file_temperature()? if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); > if (i < (cold_count + hot_count)) > @@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Don't compress unallowed extension. */ > for (i = 0; i < noext_cnt; i++) > - if (is_extension_exist(name, noext[i], false)) > + if (is_extension_exist(name, noext[i], false, false)) is_extension_exist(name, noext[i], true, true) ? Thanks, > return; > > /* Compress wanting extension. */ > for (i = 0; i < ext_cnt; i++) { > - if (is_extension_exist(name, ext[i], false)) { > + if (is_extension_exist(name, ext[i], true, true)) { > set_compress_context(inode); > return; > } > @@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = 0; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], true)) > + if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); >
On 06/20, Chao Yu wrote: > On 2023/6/14 6:14, Jaegeuk Kim wrote: > > Let's compress tmp files for the given extension list. > > > > This patch does not change the previous behavior, but allow the cases as below. > > > > Extention example: "ext" > > > > - abc.ext : allow > > - abc.ext.abc : allow > > - abc.extm : not allow > > > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > > --- > > > > Change log from v1: > > - refactor to allow abc.ext.dontcare only > > > > fs/f2fs/namei.c | 18 +++++++++++------- > > 1 file changed, 11 insertions(+), 7 deletions(-) > > > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > > index 3e35eb7dbb8f..49573ef4115d 100644 > > --- a/fs/f2fs/namei.c > > +++ b/fs/f2fs/namei.c > > @@ -23,7 +23,7 @@ > > #include <trace/events/f2fs.h> > > static inline bool is_extension_exist(const unsigned char *s, const char *sub, > > - bool tmp_ext) > > + bool tmp_ext, bool tmp_dot) > > { > > size_t slen = strlen(s); > > size_t sublen = strlen(sub); > > @@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub, > > for (i = 1; i < slen - sublen; i++) { > > if (s[i] != '.') > > continue; > > - if (!strncasecmp(s + i + 1, sub, sublen)) > > - return true; > > + if (!strncasecmp(s + i + 1, sub, sublen)) { > > + if (!tmp_dot) > > + return true; > > + if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.') > > Do you mean? > > if (i == slen - sublen - 1 && s[i + 1 + sublen] == '.') I don't think so. > > > + return true; > > + } > > } > > return false; > > @@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > > hot_count = sbi->raw_super->hot_ext_count; > > for (i = cold_count; i < cold_count + hot_count; i++) > > - if (is_extension_exist(name, extlist[i], false)) > > + if (is_extension_exist(name, extlist[i], false, false)) > > Parameters should be consistent w/ the one in set_file_temperature()? > > if (is_extension_exist(name, extlist[i], true, false)) > > > break; > > f2fs_up_read(&sbi->sb_lock); > > if (i < (cold_count + hot_count)) > > @@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Don't compress unallowed extension. */ > > for (i = 0; i < noext_cnt; i++) > > - if (is_extension_exist(name, noext[i], false)) > > + if (is_extension_exist(name, noext[i], false, false)) > > is_extension_exist(name, noext[i], true, true) ? > > Thanks, > > > return; > > /* Compress wanting extension. */ > > for (i = 0; i < ext_cnt; i++) { > > - if (is_extension_exist(name, ext[i], false)) { > > + if (is_extension_exist(name, ext[i], true, true)) { > > set_compress_context(inode); > > return; > > } > > @@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode, > > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > > hot_count = sbi->raw_super->hot_ext_count; > > for (i = 0; i < cold_count + hot_count; i++) > > - if (is_extension_exist(name, extlist[i], true)) > > + if (is_extension_exist(name, extlist[i], true, false)) > > break; > > f2fs_up_read(&sbi->sb_lock);
Let's compress tmp files for the given extension list.
This patch does not change the previous behavior, but allow the cases as below.
Extention example: "ext"
- abc.ext : allow
- abc.ext.abc : allow
- abc.extm : not allow
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Change log from v2:
- fix parameters
Change log from v1:
- refactor to allow abc.ext.dontcare only
fs/f2fs/namei.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 3e35eb7dbb8f..80806ce1289f 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -23,7 +23,7 @@
#include <trace/events/f2fs.h>
static inline bool is_extension_exist(const unsigned char *s, const char *sub,
- bool tmp_ext)
+ bool tmp_ext, bool tmp_dot)
{
size_t slen = strlen(s);
size_t sublen = strlen(sub);
@@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub,
for (i = 1; i < slen - sublen; i++) {
if (s[i] != '.')
continue;
- if (!strncasecmp(s + i + 1, sub, sublen))
- return true;
+ if (!strncasecmp(s + i + 1, sub, sublen)) {
+ if (!tmp_dot)
+ return true;
+ if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.')
+ return true;
+ }
}
return false;
@@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = cold_count; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], false))
+ if (is_extension_exist(name, extlist[i], true, false))
break;
f2fs_up_read(&sbi->sb_lock);
if (i < (cold_count + hot_count))
@@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
/* Don't compress unallowed extension. */
for (i = 0; i < noext_cnt; i++)
- if (is_extension_exist(name, noext[i], false))
+ if (is_extension_exist(name, noext[i], true, false))
return;
/* Compress wanting extension. */
for (i = 0; i < ext_cnt; i++) {
- if (is_extension_exist(name, ext[i], false)) {
+ if (is_extension_exist(name, ext[i], true, true)) {
set_compress_context(inode);
return;
}
@@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = 0; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], true))
+ if (is_extension_exist(name, extlist[i], true, false))
break;
f2fs_up_read(&sbi->sb_lock);
On 2023/6/22 15:12, Jaegeuk Kim wrote: > Let's compress tmp files for the given extension list. > > This patch does not change the previous behavior, but allow the cases as below. > > Extention example: "ext" > > - abc.ext : allow > - abc.ext.abc : allow > - abc.extm : not allow > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> > --- > Change log from v2: > - fix parameters > > Change log from v1: > - refactor to allow abc.ext.dontcare only > > fs/f2fs/namei.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c > index 3e35eb7dbb8f..80806ce1289f 100644 > --- a/fs/f2fs/namei.c > +++ b/fs/f2fs/namei.c > @@ -23,7 +23,7 @@ > #include <trace/events/f2fs.h> > > static inline bool is_extension_exist(const unsigned char *s, const char *sub, > - bool tmp_ext) > + bool tmp_ext, bool tmp_dot) > { > size_t slen = strlen(s); > size_t sublen = strlen(sub); > @@ -49,8 +49,12 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub, > for (i = 1; i < slen - sublen; i++) { > if (s[i] != '.') > continue; > - if (!strncasecmp(s + i + 1, sub, sublen)) > - return true; > + if (!strncasecmp(s + i + 1, sub, sublen)) { > + if (!tmp_dot) > + return true; > + if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.') > + return true; > + } > } > > return false; > @@ -148,7 +152,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = cold_count; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], false)) > + if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); > if (i < (cold_count + hot_count)) > @@ -156,12 +160,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, > > /* Don't compress unallowed extension. */ > for (i = 0; i < noext_cnt; i++) > - if (is_extension_exist(name, noext[i], false)) > + if (is_extension_exist(name, noext[i], true, false)) is_extension_exist(name, ext[i], true, true) ? Thanks, > return; > > /* Compress wanting extension. */ > for (i = 0; i < ext_cnt; i++) { > - if (is_extension_exist(name, ext[i], false)) { > + if (is_extension_exist(name, ext[i], true, true)) { > set_compress_context(inode); > return; > } > @@ -189,7 +193,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode, > cold_count = le32_to_cpu(sbi->raw_super->extension_count); > hot_count = sbi->raw_super->hot_ext_count; > for (i = 0; i < cold_count + hot_count; i++) > - if (is_extension_exist(name, extlist[i], true)) > + if (is_extension_exist(name, extlist[i], true, false)) > break; > f2fs_up_read(&sbi->sb_lock); >
Let's compress tmp files for the given extension list.
This patch does not change the previous behavior, but allow the cases as below.
Extention example: "ext"
- abc.ext : allow
- abc.ext.abc : allow
- abc.extm : not allow
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
Change log from v3:
- split temparature and compress extensions
Change log from v2:
- fix parameters
Change log from v1:
- refactor to allow abc.ext.dontcare only
fs/f2fs/namei.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 3e35eb7dbb8f..ff89de115272 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -23,7 +23,7 @@
#include <trace/events/f2fs.h>
static inline bool is_extension_exist(const unsigned char *s, const char *sub,
- bool tmp_ext)
+ bool tmp_ext, bool tmp_dot)
{
size_t slen = strlen(s);
size_t sublen = strlen(sub);
@@ -49,13 +49,27 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub,
for (i = 1; i < slen - sublen; i++) {
if (s[i] != '.')
continue;
- if (!strncasecmp(s + i + 1, sub, sublen))
- return true;
+ if (!strncasecmp(s + i + 1, sub, sublen)) {
+ if (!tmp_dot)
+ return true;
+ if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.')
+ return true;
+ }
}
return false;
}
+static inline bool is_temperature_extension(const unsigned char *s, const char *sub)
+{
+ return is_extension_exist(s, sub, true, false);
+}
+
+static inline bool is_compress_extension(const unsigned char *s, const char *sub)
+{
+ return is_extension_exist(s, sub, true, true);
+}
+
int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
bool hot, bool set)
{
@@ -148,7 +162,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = cold_count; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], false))
+ if (is_temperature_extension(name, extlist[i]))
break;
f2fs_up_read(&sbi->sb_lock);
if (i < (cold_count + hot_count))
@@ -156,12 +170,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
/* Don't compress unallowed extension. */
for (i = 0; i < noext_cnt; i++)
- if (is_extension_exist(name, noext[i], false))
+ if (is_compress_extension(name, noext[i]))
return;
/* Compress wanting extension. */
for (i = 0; i < ext_cnt; i++) {
- if (is_extension_exist(name, ext[i], false)) {
+ if (is_compress_extension(name, ext[i])) {
set_compress_context(inode);
return;
}
@@ -189,7 +203,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = 0; i < cold_count + hot_count; i++)
- if (is_extension_exist(name, extlist[i], true))
+ if (is_temperature_extension(name, extlist[i]))
break;
f2fs_up_read(&sbi->sb_lock);
On 2023/6/24 3:15, Jaegeuk Kim wrote: > Let's compress tmp files for the given extension list. > > This patch does not change the previous behavior, but allow the cases as below. > > Extention example: "ext" > > - abc.ext : allow > - abc.ext.abc : allow > - abc.extm : not allow > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Reviewed-by: Chao Yu <chao@kernel.org> Thanks,
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 3e35eb7dbb8f..cdc94c8e60f7 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -161,7 +161,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, /* Compress wanting extension. */ for (i = 0; i < ext_cnt; i++) { - if (is_extension_exist(name, ext[i], false)) { + if (is_extension_exist(name, ext[i], true)) { set_compress_context(inode); return; }