summaryrefslogtreecommitdiff
path: root/fs/f2fs
diff options
context:
space:
mode:
authorFengnan Chang <changfengnan@vivo.com>2021-08-09 10:21:04 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2021-08-17 11:59:04 -0700
commit4a4fc043f594d39edc976a3a3dce7c40ebb86f3f (patch)
tree4acf61f6f0d861fbfbff8fa2202d1915a7a38c00 /fs/f2fs
parent1927ccdb79906e04c760ed7429c30a5c8054d1a7 (diff)
f2fs: compress: allow write compress released file after truncate to zero
For compressed file, after release compress blocks, don't allow write direct, but we should allow write direct after truncate to zero. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Fengnan Chang <changfengnan@vivo.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7d8ee60f6c1f..d4fc5e0d2ffe 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -753,6 +753,14 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
return err;
#ifdef CONFIG_F2FS_FS_COMPRESSION
+ /*
+ * For compressed file, after release compress blocks, don't allow write
+ * direct, but we should allow write direct after truncate to zero.
+ */
+ if (f2fs_compressed_file(inode) && !free_from
+ && is_inode_flag_set(inode, FI_COMPRESS_RELEASED))
+ clear_inode_flag(inode, FI_COMPRESS_RELEASED);
+
if (from != free_from) {
err = f2fs_truncate_partial_cluster(inode, from, lock);
if (err)