* [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes
@ 2026-10-15 16:17 Daeho Jeong
2026-10-19 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
2026-10-20 9:15 ` Chao Yu
0 siblings, 2 replies; 3+ messages in thread
From: Daeho Jeong @ 2026-10-15 16:17 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong
From: Daeho Jeong <daehojeong@google.com>
truncate_inode_pages_final() is meant to be called from ->evict_inode.
It sets AS_EXITING on the mapping, and nothing ever clears it, to tell
the VM that the inode is going away.
f2fs calls it in two places where the inode stays live:
- F2FS_IOC_START_ATOMIC_REPLACE uses it to drop the page cache of the
original inode before setting i_size to 0. The atomic write then
goes on through this inode.
- f2fs_abort_atomic_write() uses it to drop the uncommitted data. It
is called on eviction, but also on the last writer's close in
f2fs_release_file(), from f2fs_file_flush() when the atomic writer
exits, from F2FS_IOC_ABORT_ATOMIC_WRITE and when
F2FS_IOC_COMMIT_ATOMIC_WRITE fails.
Other processes may still have the file open or mapped in all of these
cases. The mapping then stays marked as exiting for as long as the
inode is in memory. This stops reclaim from storing workingset shadow
entries for it and breaks any code that assumes an exiting mapping has
no users left.
All we need in both places is to drop the page cache, so use
truncate_inode_pages(mapping, 0) instead. The eviction path is not
affected, because f2fs_pre_evict_inode() still calls
truncate_inode_pages_final() after f2fs_abort_atomic_write().
Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
Fixes: 41e8f85a75fc ("f2fs: introduce F2FS_IOC_START_ATOMIC_REPLACE")
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
fs/f2fs/file.c | 2 +-
fs/f2fs/segment.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7020b3e8940..1e6f1f02357 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2466,7 +2466,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
fi->original_i_size = isize;
if (truncate) {
set_inode_flag(inode, FI_ATOMIC_REPLACE);
- truncate_inode_pages_final(inode->i_mapping);
+ truncate_inode_pages(inode->i_mapping, 0);
f2fs_i_size_write(inode, 0);
isize = 0;
}
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 794e0d99fc7..781995fedcc 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -194,7 +194,7 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean)
return;
if (clean)
- truncate_inode_pages_final(inode->i_mapping);
+ truncate_inode_pages(inode->i_mapping, 0);
release_atomic_write_cnt(inode);
clear_inode_flag(inode, FI_ATOMIC_COMMITTED);
--
2.56.0.385.gd3acb90ef8-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes
2026-10-15 16:17 [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes Daeho Jeong
@ 2026-10-19 15:40 ` patchwork-bot+f2fs
2026-10-20 9:15 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2026-10-19 15:40 UTC (permalink / raw)
To: Daeho Jeong; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, daehojeong
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Thu, 15 Oct 2026 16:17:14 +0000 you wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> truncate_inode_pages_final() is meant to be called from ->evict_inode.
> It sets AS_EXITING on the mapping, and nothing ever clears it, to tell
> the VM that the inode is going away.
>
> f2fs calls it in two places where the inode stays live:
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: don't use truncate_inode_pages_final() on live inodes
https://git.kernel.org/jaegeuk/f2fs/c/256d5e27eda8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes
2026-10-15 16:17 [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes Daeho Jeong
2026-10-19 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
@ 2026-10-20 9:15 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-10-20 9:15 UTC (permalink / raw)
To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team
Cc: chao, Daeho Jeong
On 10/16/26 00:17, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> truncate_inode_pages_final() is meant to be called from ->evict_inode.
> It sets AS_EXITING on the mapping, and nothing ever clears it, to tell
> the VM that the inode is going away.
>
> f2fs calls it in two places where the inode stays live:
>
> - F2FS_IOC_START_ATOMIC_REPLACE uses it to drop the page cache of the
> original inode before setting i_size to 0. The atomic write then
> goes on through this inode.
>
> - f2fs_abort_atomic_write() uses it to drop the uncommitted data. It
> is called on eviction, but also on the last writer's close in
> f2fs_release_file(), from f2fs_file_flush() when the atomic writer
> exits, from F2FS_IOC_ABORT_ATOMIC_WRITE and when
> F2FS_IOC_COMMIT_ATOMIC_WRITE fails.
>
> Other processes may still have the file open or mapped in all of these
> cases. The mapping then stays marked as exiting for as long as the
> inode is in memory. This stops reclaim from storing workingset shadow
> entries for it and breaks any code that assumes an exiting mapping has
> no users left.
>
> All we need in both places is to drop the page cache, so use
> truncate_inode_pages(mapping, 0) instead. The eviction path is not
> affected, because f2fs_pre_evict_inode() still calls
> truncate_inode_pages_final() after f2fs_abort_atomic_write().
>
Cc: stable@kernel.org
> Fixes: 3db1de0e582c ("f2fs: change the current atomic write way")
> Fixes: 41e8f85a75fc ("f2fs: introduce F2FS_IOC_START_ATOMIC_REPLACE")
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-20 9:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 16:17 [PATCH] f2fs: don't use truncate_inode_pages_final() on live inodes Daeho Jeong
2026-10-19 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
2026-10-20 9:15 ` 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®