diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index e3bea575ddc3537b606b57067d0c140e63e4bb5e..67e5c6060403dfb6698330cede59180078bce927 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;