diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-11-12 14:31:16 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2021-12-04 10:53:33 -0800 |
commit | d4dd19ec1ea0cf6532d65709325c42b1398614a8 (patch) | |
tree | 399db103c398219451cf13c22ff3bf6639dd439d /fs/f2fs/data.c | |
parent | b31bf0f96e71a2c81d2122c3fecdb91f8e215c20 (diff) | |
download | linux-stable-d4dd19ec1ea0cf6532d65709325c42b1398614a8.tar.gz linux-stable-d4dd19ec1ea0cf6532d65709325c42b1398614a8.tar.bz2 linux-stable-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/data.c')
-rw-r--r-- | fs/f2fs/data.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3db0f3049b90..9c867de1ec29 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1543,8 +1543,11 @@ next_block: flag != F2FS_GET_BLOCK_DIO); err = __allocate_data_block(&dn, map->m_seg_type); - if (!err) + if (!err) { + if (flag == F2FS_GET_BLOCK_PRE_DIO) + file_need_truncate(inode); set_inode_flag(inode, FI_APPEND_WRITE); + } } if (err) goto sync_out; |