Skip to content

Commit 025b360

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 3a2c0e5 commit 025b360

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

fs/f2fs/file.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,10 +4092,8 @@ static int f2fs_ioc_decompress_file(struct file *filp)
40924092
last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
40934093

40944094
count = last_idx - page_idx;
4095-
while (count) {
4096-
int len = min(cluster_size, count);
4097-
4098-
ret = redirty_blocks(inode, page_idx, len);
4095+
while (count && count >= cluster_size) {
4096+
ret = redirty_blocks(inode, page_idx, cluster_size);
40994097
if (ret < 0)
41004098
break;
41014099

@@ -4105,8 +4103,8 @@ static int f2fs_ioc_decompress_file(struct file *filp)
41054103
break;
41064104
}
41074105

4108-
count -= len;
4109-
page_idx += len;
4106+
count -= cluster_size;
4107+
page_idx += cluster_size;
41104108

41114109
cond_resched();
41124110
if (fatal_signal_pending(current)) {
@@ -4172,10 +4170,8 @@ static int f2fs_ioc_compress_file(struct file *filp)
41724170
last_idx = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
41734171

41744172
count = last_idx - page_idx;
4175-
while (count) {
4176-
int len = min(cluster_size, count);
4177-
4178-
ret = redirty_blocks(inode, page_idx, len);
4173+
while (count && count >= cluster_size) {
4174+
ret = redirty_blocks(inode, page_idx, cluster_size);
41794175
if (ret < 0)
41804176
break;
41814177

@@ -4185,8 +4181,8 @@ static int f2fs_ioc_compress_file(struct file *filp)
41854181
break;
41864182
}
41874183

4188-
count -= len;
4189-
page_idx += len;
4184+
count -= cluster_size;
4185+
page_idx += cluster_size;
41904186

41914187
cond_resched();
41924188
if (fatal_signal_pending(current)) {

0 commit comments

Comments
 (0)