Skip to content

Commit f81302d

Browse files
chaseyugregkh
authored andcommitted
f2fs: fix to wait dio completion
commit 96cfeb0389530ae32ade8a48ae3ae1ac3b6c009d upstream. 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]> Signed-off-by: Alva Lan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1dc81fb commit f81302d

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
@@ -1048,6 +1048,13 @@ int f2fs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
10481048
return err;
10491049
}
10501050

1051+
/*
1052+
* wait for inflight dio, blocks should be removed after
1053+
* IO completion.
1054+
*/
1055+
if (attr->ia_size < old_size)
1056+
inode_dio_wait(inode);
1057+
10511058
f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
10521059
filemap_invalidate_lock(inode->i_mapping);
10531060

@@ -1880,6 +1887,12 @@ static long f2fs_fallocate(struct file *file, int mode,
18801887
if (ret)
18811888
goto out;
18821889

1890+
/*
1891+
* wait for inflight dio, blocks should be removed after IO
1892+
* completion.
1893+
*/
1894+
inode_dio_wait(inode);
1895+
18831896
if (mode & FALLOC_FL_PUNCH_HOLE) {
18841897
if (offset >= inode->i_size)
18851898
goto out;

0 commit comments

Comments
 (0)