From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 5/6] f2fs: fix to restrict condition of compress inode conversion
Date: Tue, 12 Dec 2023 14:21:48 -0800 [thread overview]
Message-ID: <ZXjc_I6__dijbwvN@google.com> (raw)
In-Reply-To: <5884e300-5384-4a49-9f8d-8cced50f4e6d@kernel.org>
On 12/12, Chao Yu wrote:
> On 2023/12/12 6:11, Jaegeuk Kim wrote:
> > On 12/10, Chao Yu wrote:
> > > This patch adds i_size check during compress inode conversion in order
> > > to avoid .page_mkwrite races w/ conversion.
> >
> > Which race condition do you see?
>
> Something like:
>
> - f2fs_setflags_common
> - check S_ISREG && F2FS_HAS_BLOCKS
> - mkwrite
> - f2fs_get_block_locked
> : update metadata in old inode's disk layout
Don't we need to prevent setting this for mmapped file?
> - set_compress_context
>
> Thanks,
>
> >
> > >
> > > Fixes: 4c8ff7095bef ("f2fs: support data compression")
> > > Signed-off-by: Chao Yu <chao@kernel.org>
> > > ---
> > > fs/f2fs/f2fs.h | 8 +++++++-
> > > fs/f2fs/file.c | 5 ++---
> > > 2 files changed, 9 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > > index 65294e3b0bef..c9b8a1953913 100644
> > > --- a/fs/f2fs/f2fs.h
> > > +++ b/fs/f2fs/f2fs.h
> > > @@ -4397,13 +4397,19 @@ static inline int set_compress_context(struct inode *inode)
> > > #endif
> > > }
> > > +static inline bool inode_has_data(struct inode *inode)
> > > +{
> > > + return (S_ISREG(inode->i_mode) &&
> > > + (F2FS_HAS_BLOCKS(inode) || i_size_read(inode)));
> > > +}
> > > +
> > > static inline bool f2fs_disable_compressed_file(struct inode *inode)
> > > {
> > > struct f2fs_inode_info *fi = F2FS_I(inode);
> > > if (!f2fs_compressed_file(inode))
> > > return true;
> > > - if (S_ISREG(inode->i_mode) && F2FS_HAS_BLOCKS(inode))
> > > + if (inode_has_data(inode))
> > > return false;
> > > fi->i_flags &= ~F2FS_COMPR_FL;
> > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > > index 1a3c29a9a6a0..8af4b29c3e1a 100644
> > > --- a/fs/f2fs/file.c
> > > +++ b/fs/f2fs/file.c
> > > @@ -1922,8 +1922,7 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
> > > f2fs_down_write(&F2FS_I(inode)->i_sem);
> > > if (!f2fs_may_compress(inode) ||
> > > - (S_ISREG(inode->i_mode) &&
> > > - F2FS_HAS_BLOCKS(inode))) {
> > > + inode_has_data(inode)) {
> > > f2fs_up_write(&F2FS_I(inode)->i_sem);
> > > return -EINVAL;
> > > }
> > > @@ -3996,7 +3995,7 @@ static int f2fs_ioc_set_compress_option(struct file *filp, unsigned long arg)
> > > goto out;
> > > }
> > > - if (F2FS_HAS_BLOCKS(inode)) {
> > > + if (inode_has_data(inode)) {
> > > ret = -EFBIG;
> > > goto out;
> > > }
> > > --
> > > 2.40.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-12-12 22:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-10 11:35 [f2fs-dev] [PATCH 1/6] f2fs: fix to tag gcing flag on page during block migration Chao Yu
2023-12-10 11:35 ` [f2fs-dev] [PATCH 2/6] f2fs: fix to wait on block writeback for post_read case Chao Yu
2023-12-10 11:35 ` [f2fs-dev] [PATCH 3/6] f2fs: fix to check compress file in f2fs_move_file_range() Chao Yu
2023-12-10 11:35 ` [f2fs-dev] [PATCH 4/6] f2fs: don't set FI_PREALLOCATED_ALL for partial write Chao Yu
2023-12-11 22:08 ` Jaegeuk Kim
2023-12-10 11:35 ` [f2fs-dev] [PATCH 5/6] f2fs: fix to restrict condition of compress inode conversion Chao Yu
2023-12-11 22:11 ` Jaegeuk Kim
2023-12-12 1:05 ` Chao Yu
2023-12-12 22:21 ` Jaegeuk Kim [this message]
2023-12-28 15:33 ` Chao Yu
2024-01-02 22:54 ` Jaegeuk Kim
2024-01-11 3:07 ` Chao Yu
2023-12-10 11:35 ` [f2fs-dev] [PATCH 6/6] f2fs: fix to update iostat correctly in f2fs_filemap_fault() Chao Yu
2023-12-14 20:50 ` [f2fs-dev] [PATCH 1/6] f2fs: fix to tag gcing flag on page during block migration patchwork-bot+f2fs
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=ZXjc_I6__dijbwvN@google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).