public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <niuzhiguo84@gmail.com>
Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/2] f2fs: fix to relocate check condition in f2fs_fallocate()
Date: Sun, 7 Apr 2024 15:29:21 +0800	[thread overview]
Message-ID: <6a50a23e-8975-43cb-9496-38b6a083c703@kernel.org> (raw)
In-Reply-To: <CAHJ8P3LdZXLc2rqeYjvymgYHr2+YLuJ0sLG9DdsJZmwO7deuhw@mail.gmail.com>

On 2024/4/7 10:11, Zhiguo Niu wrote:
> On Wed, Apr 3, 2024 at 10:26 PM Chao Yu <chao@kernel.org> wrote:
>>
>> compress and pinfile flag should be checked after inode lock held to
>> avoid race condition, fix it.
>>
>> Fixes: 4c8ff7095bef ("f2fs: support data compression")
>> Fixes: 5fed0be8583f ("f2fs: do not allow partial truncation on pinned file")
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>>   fs/f2fs/file.c | 20 +++++++++++---------
>>   1 file changed, 11 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 148bfe3effdf..83a807e25e31 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -1820,15 +1820,6 @@ static long f2fs_fallocate(struct file *file, int mode,
>>                  (mode & (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE)))
>>                  return -EOPNOTSUPP;
>>
>> -       /*
>> -        * Pinned file should not support partial truncation since the block
>> -        * can be used by applications.
>> -        */
>> -       if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
>> -               (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
>> -                       FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE)))
>> -               return -EOPNOTSUPP;
>> -
>>          if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE |
>>                          FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE |
>>                          FALLOC_FL_INSERT_RANGE))
>> @@ -1836,6 +1827,17 @@ static long f2fs_fallocate(struct file *file, int mode,
>>
>>          inode_lock(inode);
>>
>> +       /*
>> +        * Pinned file should not support partial truncation since the block
>> +        * can be used by applications.
>> +        */
>> +       if ((f2fs_compressed_file(inode) || f2fs_is_pinned_file(inode)) &&
>> +               (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
>> +                       FALLOC_FL_ZERO_RANGE | FALLOC_FL_INSERT_RANGE))) {
>> +               ret = -EOPNOTSUPP;
>> +               goto out;
>> +       }
>> +
> Dear Chao,
> I see  the judgment code "if(!f2fs_compressed_file(inode))" also is
> before inode_lock in functions
> f2fs_ioc_decompress_file/f2fs_ioc_compress_file/f2fs_reserve_compress_blocks/f2fs_release_compress_blocks.
> should they are changed together?

Zhiguo,

Thanks for noticing that, I've submitted separated patches for fixing
because those bugs were introduced by separated commits.

Thanks,

> thanks!
>>          ret = file_modified(file);
>>          if (ret)
>>                  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

  reply	other threads:[~2024-04-07  7:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 14:24 [PATCH 1/2] f2fs: fix to relocate check condition in f2fs_fallocate() Chao Yu
2024-04-03 14:24 ` [PATCH 2/2] f2fs: fix to check pinfile flag in f2fs_move_file_range() Chao Yu
2024-04-07  2:11 ` [f2fs-dev] [PATCH 1/2] f2fs: fix to relocate check condition in f2fs_fallocate() Zhiguo Niu
2024-04-07  7:29   ` Chao Yu [this message]
2024-04-07  8:29     ` Zhiguo Niu
2024-04-14 15:32 ` 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=6a50a23e-8975-43cb-9496-38b6a083c703@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niuzhiguo84@gmail.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