mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: do f2fs_zero_post_eof_page for all the time
@ 2026-10-28  5:06 Jaegeuk Kim
  2026-10-28  8:32 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2026-10-28  5:06 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim, stable

This fixes xfstests/generic/794, since the issue is not related to the
posix=strict mode only.

Cc: stable@kernel.org
Fixes: 5eced87b7d19 ("f2fs: fix to zero post-EOF data when extending file size")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/file.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 8b4a7a9d7dbe..823df06ae0f2 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -74,15 +74,10 @@ static int f2fs_zero_post_eof_page(struct inode *inode,
 					loff_t new_size, bool lock, bool writeback)
 {
 	loff_t old_size = i_size_read(inode);
-	bool strict =
-		F2FS_OPTION(F2FS_I_SB(inode)).fsync_mode == FSYNC_MODE_STRICT;
 
 	if (old_size >= new_size)
 		return 0;
 
-	if (!strict && mapping_empty(inode->i_mapping))
-		return 0;
-
 	if (lock)
 		filemap_invalidate_lock(inode->i_mapping);
 	/* zero or drop pages only in range of [old_size, new_size] */
@@ -90,14 +85,9 @@ static int f2fs_zero_post_eof_page(struct inode *inode,
 	if (lock)
 		filemap_invalidate_unlock(inode->i_mapping);
 
-	if (!writeback || !strict)
+	if (!writeback)
 		return 0;
-	/*
-	 * In fsync_mode=strict, when we expand an unaligned EOF size, we
-	 * should zero post EOF data and writeback the data immediately,
-	 * so that it can avoid exposing stale data after metadata flush
-	 * and POR.
-	 */
+
 	return do_zero_post_eof_page(inode, new_size);
 }
 
-- 
2.56.0.307.g5fe7bd680c-goog


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

* Re: [f2fs-dev] [PATCH] f2fs: do f2fs_zero_post_eof_page for all the time
  2026-10-28  5:06 [PATCH] f2fs: do f2fs_zero_post_eof_page for all the time Jaegeuk Kim
@ 2026-10-28  8:32 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2026-10-28  8:32 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel; +Cc: chao, stable

On 10/28/26 13:06, Jaegeuk Kim via Linux-f2fs-devel wrote:
> This fixes xfstests/generic/794, since the issue is not related to the
> posix=strict mode only.

Jaegeuk,

Actually, I fixed this only in fsync_mode=strict because I don't see such
scenario (described in original patch) in Android:

    Steps of generic/794:
    1. write 4096 bytes to file w/ 0x5a
    2. use fiemap to get PBA of first block in file
    3. truncate file to 4080
    4. umount; write 4096 bytes to file w/ 0x5a directly via PBA; mount
    5. extend filesize via
       a) append 4096 from offset 4096, or
       b) truncate 8192, or
       c) fallocate 4096 from offset 4096
    6. verify the gap is zeroed in memory [4080,4096)
    7. sync range 4096 from offset 4096; shutdown -f (flush meta before shutdown)
    8. umount; mount; verify [4080,4096) is zeroed or not.

Maybe we should only enable fsync_mode=strict for 794 to let it pass?

Thanks,

> 
> Cc: stable@kernel.org
> Fixes: 5eced87b7d19 ("f2fs: fix to zero post-EOF data when extending file size")
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/file.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 8b4a7a9d7dbe..823df06ae0f2 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -74,15 +74,10 @@ static int f2fs_zero_post_eof_page(struct inode *inode,
>  					loff_t new_size, bool lock, bool writeback)
>  {
>  	loff_t old_size = i_size_read(inode);
> -	bool strict =
> -		F2FS_OPTION(F2FS_I_SB(inode)).fsync_mode == FSYNC_MODE_STRICT;
>  
>  	if (old_size >= new_size)
>  		return 0;
>  
> -	if (!strict && mapping_empty(inode->i_mapping))
> -		return 0;
> -
>  	if (lock)
>  		filemap_invalidate_lock(inode->i_mapping);
>  	/* zero or drop pages only in range of [old_size, new_size] */
> @@ -90,14 +85,9 @@ static int f2fs_zero_post_eof_page(struct inode *inode,
>  	if (lock)
>  		filemap_invalidate_unlock(inode->i_mapping);
>  
> -	if (!writeback || !strict)
> +	if (!writeback)
>  		return 0;
> -	/*
> -	 * In fsync_mode=strict, when we expand an unaligned EOF size, we
> -	 * should zero post EOF data and writeback the data immediately,
> -	 * so that it can avoid exposing stale data after metadata flush
> -	 * and POR.
> -	 */
> +
>  	return do_zero_post_eof_page(inode, new_size);
>  }
>  


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

end of thread, other threads:[~2026-10-28  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28  5:06 [PATCH] f2fs: do f2fs_zero_post_eof_page for all the time Jaegeuk Kim
2026-10-28  8:32 ` [f2fs-dev] " Chao Yu

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

all inboxes | Powered by JetHome®