diff options
author | Hao Xu <[email protected]> | 2023-08-01 16:06:47 +0800 |
---|---|---|
committer | Miklos Szeredi <[email protected]> | 2023-08-16 12:39:24 +0200 |
commit | b5a2a3a0b77668257fa72ee6bc0eac90493f13c1 (patch) | |
tree | 1af722dccb880d15708a07661c475eff695c828b | |
parent | e78662e818f9478e70912cc2970ca632ec9f3635 (diff) |
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 <[email protected]>
Reviewed-by: Jiachen Zhang <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
-rw-r--r-- | fs/fuse/file.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e6034ce698e9..1cdb6327511e 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -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); |