f2fs: compress: fix to update isize when overwriting compressed file
authorChao Yu <yuchao0@huawei.com>
Fri, 24 Jul 2020 10:21:36 +0000 (18:21 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 26 Jul 2020 15:19:06 +0000 (08:19 -0700)
We missed to update isize of compressed file in write_end() with
below case:

cluster size is 16KB

- write 14KB data from offset 0
- overwrite 16KB data from offset 0

Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 3b8409ce24f25452ed978b5b4019d5388d428dc1..bc89bc987513ec63b5f0467293f014a704aa07e7 100644 (file)
@@ -3470,6 +3470,10 @@ static int f2fs_write_end(struct file *file,
        if (f2fs_compressed_file(inode) && fsdata) {
                f2fs_compress_write_end(inode, fsdata, page->index, copied);
                f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
+
+               if (pos + copied > i_size_read(inode) &&
+                               !f2fs_verity_in_progress(inode))
+                       f2fs_i_size_write(inode, pos + copied);
                return copied;
        }
 #endif