f2fs: should not truncate blocks during roll-forward recovery
authorJaegeuk Kim <jaegeuk@kernel.org>
Thu, 21 Apr 2022 23:47:02 +0000 (16:47 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 22 Apr 2022 01:57:09 +0000 (18:57 -0700)
If the file preallocated blocks and fsync'ed, we should not truncate them during
roll-forward recovery which will recover i_size correctly back.

Fixes: d4dd19ec1ea0 ("f2fs: do not expose unwritten blocks to user by DIO")
Cc: <stable@vger.kernel.org> # 5.17+
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/inode.c

index 71f232dcf3c20665a0dea421797f598a2d77a067..83639238a1fe9ed4225cba8642963b70d29b05ab 100644 (file)
@@ -550,7 +550,8 @@ make_now:
        }
        f2fs_set_inode_flags(inode);
 
-       if (file_should_truncate(inode)) {
+       if (file_should_truncate(inode) &&
+                       !is_sbi_flag_set(sbi, SBI_POR_DOING)) {
                ret = f2fs_truncate(inode);
                if (ret)
                        goto bad_inode;