summaryrefslogtreecommitdiff
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2024-06-27 15:17:11 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2024-08-15 15:26:39 +0000
commit96cfeb0389530ae32ade8a48ae3ae1ac3b6c009d (patch)
tree956171639692abec381b50914d500f99b47af262 /fs/f2fs/file.c
parentaaf8c0b9ae042494cb4585883b15c1332de77840 (diff)
f2fs: fix to wait dio completion
It should wait all existing dio write IOs before block removal, otherwise, previous direct write IO may overwrite data in the block which may be reused by other inode. Cc: stable@vger.kernel.org Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index e3bea575ddc3..67e5c6060403 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1055,6 +1055,13 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return err;
}
+ /*
+ * wait for inflight dio, blocks should be removed after
+ * IO completion.
+ */
+ if (attr->ia_size < old_size)
+ inode_dio_wait(inode);
+
f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
filemap_invalidate_lock(inode->i_mapping);
@@ -1891,6 +1898,12 @@ static long f2fs_fallocate(struct file *file, int mode,
if (ret)
goto out;
+ /*
+ * wait for inflight dio, blocks should be removed after IO
+ * completion.
+ */
+ inode_dio_wait(inode);
+
if (mode & FALLOC_FL_PUNCH_HOLE) {
if (offset >= inode->i_size)
goto out;