summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2023-09-04 18:12:42 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2023-09-12 23:49:34 +0300
commit943f7c6f987f4a2bd081e76cf68d4c089dc66c65 (patch)
tree6e88731d6a0c5719d7543e35a70c8d3169616b40 /fs/f2fs
parenta4639380bbe66172df329f8b54aa7d2e943f0f64 (diff)
downloadlinux-943f7c6f987f4a2bd081e76cf68d4c089dc66c65.tar.xz
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. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/data.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index cd9cedc35d7f..96342aba8022 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -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))