7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joanne Chang [ Upstream commit 2eebc31ae5f53e1066bb6238c8087c23b688ad17 ] Commit a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file") updated f2fs_should_update_outplace() to always return true for compressed files. However, this function is also called during f2fs_ioc_set_pin_file() validation, so pinning an empty file with compression enabled now fails with -EINVAL before the compression flag can be stripped. Fix this by guarding the f2fs_compressed_file(inode) check with fio in f2fs_should_update_outplace(). This preserves forced OPU for actual compressed writes (fio != NULL), while allowing f2fs_ioc_set_pin_file() (fio == NULL) to proceed to f2fs_disable_compressed_file(inode). Cc: stable@kernel.org Fixes: a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file") Assisted-by: LLM Signed-off-by: Joanne Chang Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index c9a1bb07a5b32..d8965229e3e7a 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2913,7 +2913,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio) * If IO comes from compressed write path and fallback to raw write, * force out‑place to prevent metadata‑data inconsistency. */ - if (f2fs_compressed_file(inode)) + if (fio && f2fs_compressed_file(inode)) return true; /* swap file is migrating in aligned write mode */ -- 2.53.0