mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
fuse: write back dirty pages before direct write in direct_io_relax mode
In direct_io_relax mode, there can be shared mmaped files and thus dirty pages in its page cache. Therefore those dirty pages should be written back to backend before direct io to avoid data loss. Signed-off-by: Hao Xu <howeyxu@tencent.com> Reviewed-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
e78662e818
commit
b5a2a3a0b7
@ -1448,6 +1448,13 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
|
||||
if (!ia)
|
||||
return -ENOMEM;
|
||||
|
||||
if (fopen_direct_io && fc->direct_io_relax) {
|
||||
res = filemap_write_and_wait_range(mapping, pos, pos + count - 1);
|
||||
if (res) {
|
||||
fuse_io_free(ia);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
if (!cuse && fuse_range_is_writeback(inode, idx_from, idx_to)) {
|
||||
if (!write)
|
||||
inode_lock(inode);
|
||||
|
Loading…
Reference in New Issue
Block a user