diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-11-12 23:31:16 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-12-04 19:53:33 +0100 |
commit | d4dd19ec1ea0cf6532d65709325c42b1398614a8 (patch) | |
tree | 399db103c398219451cf13c22ff3bf6639dd439d /fs/f2fs/inode.c | |
parent | f2fs: reduce indentation in f2fs_file_write_iter() (diff) | |
download | linux-d4dd19ec1ea0cf6532d65709325c42b1398614a8.tar.xz linux-d4dd19ec1ea0cf6532d65709325c42b1398614a8.zip |
f2fs: do not expose unwritten blocks to user by DIO
DIO preallocates physical blocks before writing data, but if an error occurrs
or power-cut happens, we can see block contents from the disk. This patch tries
to fix it by 1) turning to buffered writes for DIO into holes, 2) truncating
unwritten blocks from error or power-cut.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/inode.c')
-rw-r--r-- | fs/f2fs/inode.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 0f8b2df3e1e0..6998eb1d6bdb 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -544,6 +544,14 @@ make_now: goto bad_inode; } f2fs_set_inode_flags(inode); + + if (file_should_truncate(inode)) { + ret = f2fs_truncate(inode); + if (ret) + goto bad_inode; + file_dont_truncate(inode); + } + unlock_new_inode(inode); trace_f2fs_iget(inode); return inode; |