[PATCH 0/3] f2fs: add per-file out-place update control

From: Jeuk Kim

Date: Fri Aug 28 2026 - 03:20:36 EST


F2FS currently has only filesystem-wide controls for its update policy.
Both "mode=lfs" and ipu_policy affect every file in the filesystem, so
there is no way to force OPU for a selected file while leaving unrelated
files under the normal adaptive policy. This series adds a persistent
per-file OPU override.

Patch 1 fixes write tracking for pinned direct I/O in LFS mode. Pinned
files still overwrite in place, so FI_UPDATE_WRITE must be set to ensure
that fdatasync() flushes the device cache.

Patch 2 fixes a regression in the existing LFS-mode direct-I/O path.
Since commit 351bc761338d ("f2fs: optimize f2fs DIO overwrites"), an
O_DIRECT overwrite of an already mapped range can reuse the existing
physical block even in LFS mode. Restore OPU for those overwrites before
extending the same path to per-file OPU in patch 3.

Patch 3 adds F2FS_IOC_{SET,GET}_OPU_FILE and stores the per-file policy
in a new F2FS_OPU_FL bit in the inode's on-disk i_flags word. A
runtime-only inode flag would lose the setting on inode eviction.

There is no free bit in i_inline or i_advise, and extending extra_attr
would require a larger i_extra_isize, which cannot be assumed for existing
inodes. Store the policy in an unused i_flags bit instead, avoiding an
inode layout change and allowing the policy to be set on existing files.

Comments on the per-file interface and the use of an i_flags bit for the
persistent policy would be appreciated.

Jeuk Kim (3):
f2fs: set FI_UPDATE_WRITE for in-place direct writes to pinned files
f2fs: fix in-place direct I/O overwrites in LFS mode
f2fs: add ioctl to force out-place-update per file

fs/f2fs/data.c | 36 ++++++++++++------
fs/f2fs/f2fs.h | 16 ++++++++
fs/f2fs/file.c | 80 ++++++++++++++++++++++++++++++++++-----
include/uapi/linux/f2fs.h | 2 +
4 files changed, 113 insertions(+), 21 deletions(-)

--
2.43.0