From 84a9f618b5b6304401e46935f5aa5bce8d95011c Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Wed, 12 Jul 2023 04:08:06 +0800 Subject: [PATCH] UPSTREAM: f2fs: compress: don't {,de}compress non-full cluster f2fs won't compress non-full cluster in tail of file, let's skip dirtying and rewrite such cluster during f2fs_ioc_{,de}compress_file. Bug: 325092012 Change-Id: I88e6b431b27b4768a312e0977ebe1c9e9cc23600 Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim (cherry picked from commit 025b3602b5fa216fb87bbfa4bff8bb378fe589a0) --- fs/f2fs/file.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c7d9778f3c1c..478ae2c5fb1f 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4170,10 +4170,8 @@ static int f2fs_ioc_decompress_file(struct file *filp) last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); count = last_idx - page_idx; - while (count) { - int len = min(cluster_size, count); - - ret = redirty_blocks(inode, page_idx, len); + while (count && count >= cluster_size) { + ret = redirty_blocks(inode, page_idx, cluster_size); if (ret < 0) break; @@ -4183,8 +4181,8 @@ static int f2fs_ioc_decompress_file(struct file *filp) break; } - count -= len; - page_idx += len; + count -= cluster_size; + page_idx += cluster_size; cond_resched(); if (fatal_signal_pending(current)) { @@ -4250,10 +4248,8 @@ static int f2fs_ioc_compress_file(struct file *filp) last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); count = last_idx - page_idx; - while (count) { - int len = min(cluster_size, count); - - ret = redirty_blocks(inode, page_idx, len); + while (count && count >= cluster_size) { + ret = redirty_blocks(inode, page_idx, cluster_size); if (ret < 0) break; @@ -4263,8 +4259,8 @@ static int f2fs_ioc_compress_file(struct file *filp) break; } - count -= len; - page_idx += len; + count -= cluster_size; + page_idx += cluster_size; cond_resched(); if (fatal_signal_pending(current)) {