summaryrefslogtreecommitdiff
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2020-03-18 11:22:59 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2020-05-08 16:55:56 +0300
commit3265d3db1f16395cfc6b8ea9b31b4001d98d05ef (patch)
treeb6ed34cd7bde862ad9061b811749a7abded16439 /fs/f2fs/file.c
parentb5f4684b5f5fe6ea3c0d57acf5acdf8e8fbfe503 (diff)
downloadlinux-3265d3db1f16395cfc6b8ea9b31b4001d98d05ef.tar.xz
f2fs: support partial truncation on compressed inode
Supports to truncate compressed/normal cluster partially on compressed inode. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index a0a4413d6083..175c66190087 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -647,9 +647,6 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
return 0;
}
- if (f2fs_compressed_file(inode))
- return 0;
-
page = f2fs_get_lock_data_page(inode, index, true);
if (IS_ERR(page))
return PTR_ERR(page) == -ENOENT ? 0 : PTR_ERR(page);
@@ -665,7 +662,7 @@ truncate_out:
return 0;
}
-static int do_truncate_blocks(struct inode *inode, u64 from, bool lock)
+int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct dnode_of_data dn;
@@ -733,7 +730,9 @@ free_partial:
int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
{
u64 free_from = from;
+ int err;
+#ifdef CONFIG_F2FS_FS_COMPRESSION
/*
* for compressed file, only support cluster size
* aligned truncation.
@@ -748,8 +747,18 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
free_from++;
free_from <<= cluster_shift;
}
+#endif
+
+ err = f2fs_do_truncate_blocks(inode, free_from, lock);
+ if (err)
+ return err;
+
+#ifdef CONFIG_F2FS_FS_COMPRESSION
+ if (from != free_from)
+ err = f2fs_truncate_partial_cluster(inode, from, lock);
+#endif
- return do_truncate_blocks(inode, free_from, lock);
+ return err;
}
int f2fs_truncate(struct inode *inode)