From: Chao Yu <chao@kernel.org>
To: Sheng Yong <shengyong@oppo.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: fix to enable compress for newly created file if extension matches
Date: Wed, 9 Nov 2022 21:57:14 +0800 [thread overview]
Message-ID: <2a474126-ae64-ac31-9ba4-8d6b68f31bd6@kernel.org> (raw)
In-Reply-To: <20221109110148.3674340-1-shengyong@oppo.com>
On 2022/11/9 19:01, Sheng Yong wrote:
> If compress_extension is set, and a newly created file matches the
> extension, the file could be marked as compression file. However,
> if inline_data is also enabled, there is no chance to check its
> extension since f2fs_should_compress() always returns false.
>
> So if a new file is created (its inode has I_NEW flag and must have
> no pin/atomic/swap flag), instead of calling f2fs_should_compress(),
> checking its file type is enough here.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
> ---
> fs/f2fs/namei.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index e104409c3a0e5..99dbd051ae0ba 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -295,9 +295,14 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
>
> if (!f2fs_sb_has_compression(sbi) ||
> F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
> - !f2fs_may_compress(inode) ||
> (!ext_cnt && !noext_cnt))
> return;
> + if (inode->i_state & I_NEW) {
> + if (!S_ISREG(inode->i_mode))
> + return;
> + } else if (!f2fs_may_compress(inode)) {
> + return;
> + }
How about moving set_compress_inode() into f2fs_new_inode()?
if (f2fs_sb_has_compression(sbi)) {
/* Inherit the compression flag in directory */
if ((F2FS_I(dir)->i_flags & F2FS_COMPR_FL) &&
f2fs_may_compress(inode))
set_compress_context(inode);
set_compress_inode(sbi, inode, name);
}
/* Should enable inline_data after compression set */
if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode))
set_inode_flag(inode, FI_INLINE_DATA);
>
> f2fs_down_read(&sbi->sb_lock);
>
> --
> 2.25.1
next prev parent reply other threads:[~2022-11-09 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 11:01 Sheng Yong
2022-11-09 13:57 ` Chao Yu [this message]
2022-11-10 2:32 ` Sheng Yong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2a474126-ae64-ac31-9ba4-8d6b68f31bd6@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=shengyong@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®