Skip to content

Commit b5a2a3a

Browse files
Hao XuMiklos Szeredi
authored andcommitted
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>
1 parent e78662e commit b5a2a3a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/fuse/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,6 +1448,13 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
14481448
if (!ia)
14491449
return -ENOMEM;
14501450

1451+
if (fopen_direct_io && fc->direct_io_relax) {
1452+
res = filemap_write_and_wait_range(mapping, pos, pos + count - 1);
1453+
if (res) {
1454+
fuse_io_free(ia);
1455+
return res;
1456+
}
1457+
}
14511458
if (!cuse && fuse_range_is_writeback(inode, idx_from, idx_to)) {
14521459
if (!write)
14531460
inode_lock(inode);

0 commit comments

Comments
 (0)