Skip to contentSkip to conversation

f2fs: allow pinning empty compressed files

PATCH Applied Joanne Chang via Linux-f2fs-devel 1 participant 6 messages Oct 9 – Oct 13 F2FS file system

lore
Share & tools
lore
#0 lore raw

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).

Fixes a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")
Assisted-by LLM
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
index 2613e8821af6..1d071e7cb1c2 100644
@@ -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
#1 lore raw
Quoted 6 lines · Joanne Chang

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.

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 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).

Fixes a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")
Assisted-by LLM
---
  fs/f2fs/data.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index 2613e8821af6..1d071e7cb1c2 100644

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

#2 lore raw
Quoted 11 lines · Chao Yu
Quoted 6 lines · Joanne Chang

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.

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

#3 lore raw
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") 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.

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 calls f2fs_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

author Reviewed-by Chao Yu on v1 1/1
#4 lore raw
In reply to Joanne Chang via Linux-f2fs-devel
Quoted 7 lines · Joanne Chang

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.

Quoted 5 lines

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).

Quoted 3 lines
Fixes a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")
Assisted-by LLM

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#5 lore raw
In reply to Joanne Chang via 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") 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.

[...]

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