All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: stable@kernel.org, qiwenjie@xiaomi.com,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid stale FI_COMPRESS_RELEASED on release failure
Date: Mon, 3 Aug 2026 16:31:46 +0800	[thread overview]
Message-ID: <fbd2bbbb-4131-4cc5-ba7d-4e77b7bf8517@kernel.org> (raw)
In-Reply-To: <20260724135026.500859-1-qiwenjie@xiaomi.com>

On 7/24/26 21:50, Wenjie Qi wrote:
> F2FS_IOC_RELEASE_COMPRESS_BLOCKS sets FI_COMPRESS_RELEASED before walking
> data nodes. If release_compress_blocks() fails before freeing any reserved
> block, the inode keeps the flag while i_compr_blocks is still non-zero.
> 
> Then F2FS_IOC_RESERVE_COMPRESS_BLOCKS returns success with zero reserved
> blocks, and regular writes keep failing with -EPERM.
> 
> Set the flag only after the ioctl succeeds, or after it has actually
> released some blocks. This preserves the existing partial-release error
> handling and leaves a failed zero-release attempt unchanged.
> 
> Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> QEMU fault-injection test with FAULT_BLKADDR_VALIDITY:
> - before: release failed with -EFSCORRUPTED, reserve returned 0 blocks,
>    and pwrite kept failing with -EPERM after remount.
> - after: release still failed, reserve returned -EINVAL, and pwrite succeeded.
> - normal release/reserve still released and reserved 192 blocks.
> 
>   fs/f2fs/file.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index c54897a25981..dca1722f92b3 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3916,10 +3916,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>   		goto out;
>   	}
>   
> -	set_inode_flag(inode, FI_COMPRESS_RELEASED);
> -	inode_set_ctime_current(inode);
> -	f2fs_mark_inode_dirty_sync(inode, true);
> -
>   	f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
>   	filemap_invalidate_lock(inode->i_mapping);
>   
> @@ -3963,6 +3959,12 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>   
>   	filemap_invalidate_unlock(inode->i_mapping);
>   	f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
> +
> +	if (ret >= 0 || released_blocks) {

We will set FI_COMPRESS_RELEASED if ret < 0 and released_blocks > 0?

Thanks,

> +		set_inode_flag(inode, FI_COMPRESS_RELEASED);
> +		inode_set_ctime_current(inode);
> +		f2fs_mark_inode_dirty_sync(inode, true);
> +	}
>   out:
>   	if (released_blocks)
>   		f2fs_update_time(sbi, REQ_TIME);



_______________________________________________
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: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com,
	stable@kernel.org
Subject: Re: [PATCH] f2fs: avoid stale FI_COMPRESS_RELEASED on release failure
Date: Mon, 3 Aug 2026 16:31:46 +0800	[thread overview]
Message-ID: <fbd2bbbb-4131-4cc5-ba7d-4e77b7bf8517@kernel.org> (raw)
In-Reply-To: <20260724135026.500859-1-qiwenjie@xiaomi.com>

On 7/24/26 21:50, Wenjie Qi wrote:
> F2FS_IOC_RELEASE_COMPRESS_BLOCKS sets FI_COMPRESS_RELEASED before walking
> data nodes. If release_compress_blocks() fails before freeing any reserved
> block, the inode keeps the flag while i_compr_blocks is still non-zero.
> 
> Then F2FS_IOC_RESERVE_COMPRESS_BLOCKS returns success with zero reserved
> blocks, and regular writes keep failing with -EPERM.
> 
> Set the flag only after the ioctl succeeds, or after it has actually
> released some blocks. This preserves the existing partial-release error
> handling and leaves a failed zero-release attempt unchanged.
> 
> Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPRESS_BLOCKS")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> QEMU fault-injection test with FAULT_BLKADDR_VALIDITY:
> - before: release failed with -EFSCORRUPTED, reserve returned 0 blocks,
>    and pwrite kept failing with -EPERM after remount.
> - after: release still failed, reserve returned -EINVAL, and pwrite succeeded.
> - normal release/reserve still released and reserved 192 blocks.
> 
>   fs/f2fs/file.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index c54897a25981..dca1722f92b3 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3916,10 +3916,6 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>   		goto out;
>   	}
>   
> -	set_inode_flag(inode, FI_COMPRESS_RELEASED);
> -	inode_set_ctime_current(inode);
> -	f2fs_mark_inode_dirty_sync(inode, true);
> -
>   	f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
>   	filemap_invalidate_lock(inode->i_mapping);
>   
> @@ -3963,6 +3959,12 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg)
>   
>   	filemap_invalidate_unlock(inode->i_mapping);
>   	f2fs_up_write(&fi->i_gc_rwsem[WRITE]);
> +
> +	if (ret >= 0 || released_blocks) {

We will set FI_COMPRESS_RELEASED if ret < 0 and released_blocks > 0?

Thanks,

> +		set_inode_flag(inode, FI_COMPRESS_RELEASED);
> +		inode_set_ctime_current(inode);
> +		f2fs_mark_inode_dirty_sync(inode, true);
> +	}
>   out:
>   	if (released_blocks)
>   		f2fs_update_time(sbi, REQ_TIME);


  reply	other threads:[~2026-08-03  8:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 13:50 [PATCH] f2fs: avoid stale FI_COMPRESS_RELEASED on release failure Wenjie Qi
2026-07-24 13:50 ` [f2fs-dev] " Wenjie Qi
2026-08-03  8:31 ` Chao Yu via Linux-f2fs-devel [this message]
2026-08-03  8:31   ` Chao Yu
2026-08-03  9:38   ` Wenjie Qi
2026-08-03  9:38     ` [f2fs-dev] " Wenjie Qi

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=fbd2bbbb-4131-4cc5-ba7d-4e77b7bf8517@kernel.org \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiwenjie@xiaomi.com \
    --cc=qwjhust@gmail.com \
    --cc=stable@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 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.