public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
@ 2023-04-25 16:47 Yangtao Li
  2023-04-27  9:46 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Yangtao Li @ 2023-04-25 16:47 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, Daeho Jeong
  Cc: Yangtao Li, Qi Han, linux-f2fs-devel, linux-kernel

If a file has FI_COMPRESS_RELEASED, all writes for it should not be
allowed.

Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
Signed-off-by: Qi Han <hanqi@vivo.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/file.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5ac53d2627d2..46c62923f096 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2593,6 +2593,11 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
 
 	inode_lock(inode);
 
+	if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+		inode_unlock(inode);
+		return -EINVAL;
+	}
+
 	/* if in-place-update policy is enabled, don't waste time here */
 	set_inode_flag(inode, FI_OPU_WRITE);
 	if (f2fs_should_update_inplace(inode, NULL)) {
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
  2023-04-25 16:47 [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED Yangtao Li
@ 2023-04-27  9:46 ` Chao Yu
  2023-04-27 16:21   ` Jaegeuk Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2023-04-27  9:46 UTC (permalink / raw)
  To: Yangtao Li, Jaegeuk Kim, Daeho Jeong
  Cc: Qi Han, linux-f2fs-devel, linux-kernel

On 2023/4/26 0:47, Yangtao Li wrote:
> If a file has FI_COMPRESS_RELEASED, all writes for it should not be
> allowed.
> 
> Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
> Signed-off-by: Qi Han <hanqi@vivo.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Oh, I just see v2.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
  2023-04-27  9:46 ` Chao Yu
@ 2023-04-27 16:21   ` Jaegeuk Kim
  2023-04-28  1:03     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2023-04-27 16:21 UTC (permalink / raw)
  To: Chao Yu; +Cc: Yangtao Li, Daeho Jeong, Qi Han, linux-f2fs-devel, linux-kernel

On 04/27, Chao Yu wrote:
> On 2023/4/26 0:47, Yangtao Li wrote:
> > If a file has FI_COMPRESS_RELEASED, all writes for it should not be
> > allowed.
> > 
> > Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
> > Signed-off-by: Qi Han <hanqi@vivo.com>
> > Signed-off-by: Yangtao Li <frank.li@vivo.com>
> 
> Oh, I just see v2.
> 
> Reviewed-by: Chao Yu <chao@kernel.org>

Applied with using goto for code consistency.

+       if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
+               err = -EINVAL;
+               goto unlock_out;
+       }
+
        /* if in-place-update policy is enabled, don't waste time here */
        set_inode_flag(inode, FI_OPU_WRITE);
        if (f2fs_should_update_inplace(inode, NULL)) {
@@ -2712,6 +2717,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
        clear_inode_flag(inode, FI_SKIP_WRITES);
 out:
        clear_inode_flag(inode, FI_OPU_WRITE);
+unlock_out:
        inode_unlock(inode);
        if (!err)
                range->len = (u64)total << PAGE_SHIFT;

> 
> Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED
  2023-04-27 16:21   ` Jaegeuk Kim
@ 2023-04-28  1:03     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-04-28  1:03 UTC (permalink / raw)
  To: Jaegeuk Kim
  Cc: Yangtao Li, Daeho Jeong, Qi Han, linux-f2fs-devel, linux-kernel

On 2023/4/28 0:21, Jaegeuk Kim wrote:
> On 04/27, Chao Yu wrote:
>> On 2023/4/26 0:47, Yangtao Li wrote:
>>> If a file has FI_COMPRESS_RELEASED, all writes for it should not be
>>> allowed.
>>>
>>> Fixes: 5fdb322ff2c2 ("f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE")
>>> Signed-off-by: Qi Han <hanqi@vivo.com>
>>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>>
>> Oh, I just see v2.
>>
>> Reviewed-by: Chao Yu <chao@kernel.org>
> 
> Applied with using goto for code consistency.

It makes sense,

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
> +       if (is_inode_flag_set(inode, FI_COMPRESS_RELEASED)) {
> +               err = -EINVAL;
> +               goto unlock_out;
> +       }
> +
>          /* if in-place-update policy is enabled, don't waste time here */
>          set_inode_flag(inode, FI_OPU_WRITE);
>          if (f2fs_should_update_inplace(inode, NULL)) {
> @@ -2712,6 +2717,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
>          clear_inode_flag(inode, FI_SKIP_WRITES);
>   out:
>          clear_inode_flag(inode, FI_OPU_WRITE);
> +unlock_out:
>          inode_unlock(inode);
>          if (!err)
>                  range->len = (u64)total << PAGE_SHIFT;
> 
>>
>> Thanks,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-28  1:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-25 16:47 [PATCH v2] f2fs: do not allow to defragment files have FI_COMPRESS_RELEASED Yangtao Li
2023-04-27  9:46 ` Chao Yu
2023-04-27 16:21   ` Jaegeuk Kim
2023-04-28  1:03     ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox