Skip to contentSkip to conversation

f2fs: compress: fix to avoid fragment w/ OPU during f2fs_ioc_compress_file()

PATCH Applied Chao Yu 2 participants 2 messages Sep 4, 2023 – Sep 20, 2023 F2FS file system

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: compress: fix to avoid fragment w/ OPU during f2fs_ioc_compress_file()

If file has both cold and compress flag, during f2fs_ioc_compress_file(), f2fs will trigger IPU for non-compress cluster and OPU for compress cluster, so that, data of the file may be fragmented.

Fix it by always triggering OPU for IOs from user mode compression.

---
 fs/f2fs/data.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/data.c +5 -0
index 2a38d2cc2140..d4b59c57d827 100644
@@ -2665,6 +2665,11 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
 		return true;
 	if (f2fs_is_atomic_file(inode))
 		return true;
+	/* rewrite low ratio compress data w/ OPU mode to avoid fragmentation */
+	if (f2fs_compressed_file(inode) &&
+		F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER &&
+		is_inode_flag_set(inode, FI_ENABLE_COMPRESS))
+		return true;
 
 	/* swap file is migrating in aligned write mode */
 	if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
Signature · 1 line
2.40.1
#1 lore raw
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

Quoted 9 lines · On Mon, 4 Sep 2023 23:12:42 +0800 you wrote:

If file has both cold and compress flag, during f2fs_ioc_compress_file(), f2fs will trigger IPU for non-compress cluster and OPU for compress cluster, so that, data of the file may be fragmented.

Fix it by always triggering OPU for IOs from user mode compression.

[...]

Here is the summary with links:
- [f2fs-dev] f2fs: compress: fix to avoid fragment w/ OPU during f2fs_ioc_compress_file()

    https://git.kernel.org/jaegeuk/f2fs/c/943f7c6f987f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html