From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>, zhoudan8 <zhuqiandann@gmail.com>
Cc: zhoudan8 <zhoudan8@xiaomi.com>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed
Date: Mon, 12 Dec 2022 20:38:37 +0800 [thread overview]
Message-ID: <f1aba391-e694-714e-18d8-116e8db9345d@kernel.org> (raw)
In-Reply-To: <Y5OYYJYx9G2LbRmc@google.com>
On 2022/12/10 4:19, Jaegeuk Kim wrote:
> On 12/08, zhoudan8 wrote:
>> In compress_mode=user, f2fs_release_compress_blocks()
>> does not verify whether it has been compressed and
>> sets FI_COMPRESS_RELEASED directly. which will lead to
>> return -EINVAL after calling compress.
>> To fix it,let's do not set FI_COMPRESS_RELEASED if file
>> is not compressed.
>
> Do you mean you want to avoid EINVAL on a file having FI_COMPRESS_RELEASED
> with zero i_compr_blokcs?
>
> I think the current logic is giving the error on a released file already.
IMO, if i_compr_blocks is zero, it's better to return -EINVAL in
f2fs_release_compress_blocks(), as there will be no benefit after the conversion.
Thanks,
>
>>
>> Signed-off-by: zhoudan8 <zhoudan8@xiaomi.com>
>> ---
>> fs/f2fs/file.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 82cda1258227..f32910077df6 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>> ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
>> if (ret)
>> goto out;
>> -
>> - set_inode_flag(inode, FI_COMPRESS_RELEASED);
>> inode->i_ctime = current_time(inode);
>> f2fs_mark_inode_dirty_sync(inode, true);
>>
>> if (!atomic_read(&F2FS_I(inode)->i_compr_blocks))
>> goto out;
>>
>> + set_inode_flag(inode, FI_COMPRESS_RELEASED);
>> f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
>> filemap_invalidate_lock(inode->i_mapping);
>>
>> --
>> 2.38.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>, zhoudan8 <zhuqiandann@gmail.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, zhoudan8 <zhoudan8@xiaomi.com>
Subject: Re: [PATCH] f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed
Date: Mon, 12 Dec 2022 20:38:37 +0800 [thread overview]
Message-ID: <f1aba391-e694-714e-18d8-116e8db9345d@kernel.org> (raw)
In-Reply-To: <Y5OYYJYx9G2LbRmc@google.com>
On 2022/12/10 4:19, Jaegeuk Kim wrote:
> On 12/08, zhoudan8 wrote:
>> In compress_mode=user, f2fs_release_compress_blocks()
>> does not verify whether it has been compressed and
>> sets FI_COMPRESS_RELEASED directly. which will lead to
>> return -EINVAL after calling compress.
>> To fix it,let's do not set FI_COMPRESS_RELEASED if file
>> is not compressed.
>
> Do you mean you want to avoid EINVAL on a file having FI_COMPRESS_RELEASED
> with zero i_compr_blokcs?
>
> I think the current logic is giving the error on a released file already.
IMO, if i_compr_blocks is zero, it's better to return -EINVAL in
f2fs_release_compress_blocks(), as there will be no benefit after the conversion.
Thanks,
>
>>
>> Signed-off-by: zhoudan8 <zhoudan8@xiaomi.com>
>> ---
>> fs/f2fs/file.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 82cda1258227..f32910077df6 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -3451,14 +3451,13 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>> ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
>> if (ret)
>> goto out;
>> -
>> - set_inode_flag(inode, FI_COMPRESS_RELEASED);
>> inode->i_ctime = current_time(inode);
>> f2fs_mark_inode_dirty_sync(inode, true);
>>
>> if (!atomic_read(&F2FS_I(inode)->i_compr_blocks))
>> goto out;
>>
>> + set_inode_flag(inode, FI_COMPRESS_RELEASED);
>> f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
>> filemap_invalidate_lock(inode->i_mapping);
>>
>> --
>> 2.38.1
next prev parent reply other threads:[~2022-12-12 12:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 5:08 [f2fs-dev] [PATCH] f2fs: don't set FI_COMPRESS_RELEASED if file is not compressed zhoudan8
2022-12-08 5:08 ` zhoudan8
2022-12-09 20:19 ` [f2fs-dev] " Jaegeuk Kim
2022-12-09 20:19 ` Jaegeuk Kim
2022-12-12 12:21 ` [f2fs-dev] " zhoudan
2022-12-12 12:21 ` zhoudan
2022-12-12 23:05 ` [f2fs-dev] " Jaegeuk Kim
2022-12-12 23:05 ` Jaegeuk Kim
2022-12-13 2:21 ` [f2fs-dev] " zhoudan
2022-12-13 2:21 ` zhoudan
2022-12-16 11:17 ` [f2fs-dev] " zhou dan
2022-12-16 11:17 ` zhou dan
2023-01-04 2:29 ` [f2fs-dev] " Jaegeuk Kim
2023-01-04 2:29 ` Jaegeuk Kim
2023-01-11 2:47 ` [f2fs-dev] " zhou dan
2023-01-11 2:47 ` zhou dan
2022-12-12 12:38 ` Chao Yu [this message]
2022-12-12 12:38 ` Chao Yu
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=f1aba391-e694-714e-18d8-116e8db9345d@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=zhoudan8@xiaomi.com \
--cc=zhuqiandann@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 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.