f2fs: allow pinning empty compressed files
PATCH 1/1 f2fs: allow pinning empty compressed files
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).
--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
@@ -3150,7 +3150,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 */
Signature · 8 lines
2.56.0.170.g584c36229d-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 6 lines · Joanne Chang
Commit
a64a3fec11e7("f2fs: force out-place update for all writes on compressed file") updatedf2fs_should_update_outplace()to always return true for compressed files. However, this function is also called duringf2fs_ioc_set_pin_file()validation, so pinning an empty file with compression enabled now fails with-EINVALbefore the compression flag can be stripped.
Joanne,
Thanks for the patch.
But, I think it's as expected, we force compressed file to OPU, and pinfile to IPU, it's conflict.
Let me know if I missed something.
Thanks,
Quoted 18 lines
Fix this by guarding the
f2fs_compressed_file(inode)check with fio inf2fs_should_update_outplace(). This preserves forced OPU for actual compressed writes (fio != NULL), while allowingf2fs_ioc_set_pin_file()(fio == NULL) to proceed tof2fs_disable_compressed_file(inode).Fixes a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")Assisted-by LLMSigned-off-by Joanne Chang <[email protected]>--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/data.c +0
-0
fs/f2fs/data.c bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio) · line 3156
Quoted 8 lines
fs/f2fs/data.c +1
-1@@ -3150,7 +3150,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 */
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 11 lines · Chao Yu
Quoted 6 lines · Joanne Chang
Commit
a64a3fec11e7("f2fs: force out-place update for all writes on compressed file") updatedf2fs_should_update_outplace()to always return true for compressed files. However, this function is also called duringf2fs_ioc_set_pin_file()validation, so pinning an empty file with compression enabled now fails with-EINVALbefore the compression flag can be stripped.But, I think it's as expected, we force compressed file to OPU, and pinfile to IPU, it's conflict.
Thank you for reviewing the patch. I understand that compressed files cannot be pinned because compressed files need OPU.
The case I want to check is pinning a compressed file with no blocks. f2fs_ioc_set_pin_file() only allows pinning files with no blocks, and also calls f2fs_disable_compressed_file() to clear the compression flag, so there is no conflict with IPU for such a file. If I understand correctly, this is allowed on zoned devices as the f2fs_should_update_outplace() check is skipped there.
Best regards,
Joanne
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 13 lines · Joanne Chang
Quoted 11 lines · Chao Yu
Quoted 6 lines · Joanne Chang
Commit
a64a3fec11e7("f2fs: force out-place update for all writes on compressed file") updatedf2fs_should_update_outplace()to always return true for compressed files. However, this function is also called duringf2fs_ioc_set_pin_file()validation, so pinning an empty file with compression enabled now fails with-EINVALbefore the compression flag can be stripped.But, I think it's as expected, we force compressed file to OPU, and pinfile to IPU, it's conflict.
Quoted 6 lines
Thank you for reviewing the patch. I understand that compressed files cannot be pinned because compressed files need OPU.
The case I want to check is pinning a compressed file with no blocks.
f2fs_ioc_set_pin_file()only allows pinning files with no blocks, and also callsf2fs_disable_compressed_file()to clear the compression flag,
Ah, okay, I missed to check f2fs_disable_compressed_file() logic below f2fs_should_update_outplace(), thanks for the explanation.
Thanks,
Quoted 6 lines
so there is no conflict with IPU for such a file. If I understand correctly, this is allowed on zoned devices as the
f2fs_should_update_outplace()check is skipped there.Best regards,
Joanne
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 7 lines · Joanne Chang
Commit
a64a3fec11e7("f2fs: force out-place update for all writes on compressed file") updatedf2fs_should_update_outplace()to always return true for compressed files. However, this function is also called duringf2fs_ioc_set_pin_file()validation, so pinning an empty file with compression enabled now fails with-EINVALbefore the compression flag can be stripped.
Quoted 5 lines
Fix this by guarding the
f2fs_compressed_file(inode)check with fio inf2fs_should_update_outplace(). This preserves forced OPU for actual compressed writes (fio != NULL), while allowingf2fs_ioc_set_pin_file()(fio == NULL) to proceed tof2fs_disable_compressed_file(inode).
Quoted 3 lines
Fixes a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")Assisted-by LLMSigned-off-by Joanne Chang <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Fri, 9 Oct 2026 09:53:31 +0000 you wrote:
Commit
a64a3fec11e7("f2fs: force out-place update for all writes on compressed file") updatedf2fs_should_update_outplace()to always return true for compressed files. However, this function is also called duringf2fs_ioc_set_pin_file()validation, so pinning an empty file with compression enabled now fails with-EINVALbefore the compression flag can be stripped.[...]
Here is the summary with links:
- [f2fs-dev,v1] f2fs: allow pinning empty compressed files
https://git.kernel.org/jaegeuk/f2fs/c/2eebc31ae5f5
You are awesome, thank you!
Signature · 10 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel