Skip to content

Commit 96cfeb0

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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: [email protected] Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent aaf8c0b commit 96cfeb0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/f2fs/file.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,13 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
10551055
return err;
10561056
}
10571057

1058+
/*
1059+
* wait for inflight dio, blocks should be removed after
1060+
* IO completion.
1061+
*/
1062+
if (attr->ia_size < old_size)
1063+
inode_dio_wait(inode);
1064+
10581065
f2fs_down_write(&fi->i_gc_rwsem[WRITE]);
10591066
filemap_invalidate_lock(inode->i_mapping);
10601067

@@ -1891,6 +1898,12 @@ static long f2fs_fallocate(struct file *file, int mode,
18911898
if (ret)
18921899
goto out;
18931900

1901+
/*
1902+
* wait for inflight dio, blocks should be removed after IO
1903+
* completion.
1904+
*/
1905+
inode_dio_wait(inode);
1906+
18941907
if (mode & FALLOC_FL_PUNCH_HOLE) {
18951908
if (offset >= inode->i_size)
18961909
goto out;

0 commit comments

Comments
 (0)