fuse: use copy_splice_read() for FOPEN_DIRECT_IO splice read
Subsystems (2)
PATCH v2 1/1 fuse: use copy_splice_read() for FOPEN_DIRECT_IO splice read
When FOPEN_DIRECT_IO is set, fuse_splice_read() calls filemap_splice_read(), which populates the pipe with pages from the fuse inode's page cache.
This is incorrect for files opened with FOPEN_DIRECT_IO, where reads should fetch fresh data from the server rather than using cached (and potentially stale) data.
Use copy_splice_read() instead, which will invoke ->read_iter() on each splice read, sending a FUSE_READ to the server every time.
We do not need to add checking for O_DIRECT since this is already handled at the vfs layer in do_splice_read().
---
v1 -> v2:
- Reword commit message to be more accurate, per Amir's feedback
v1: https://lore.kernel.org/fuse-devel/[email protected]/
--- fs/fuse/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/fuse/file.c +3 -1
@@ -1858,7 +1858,9 @@ static ssize_t fuse_splice_read(struct file *in, loff_t *ppos,struct fuse_file *ff = in->private_data;/* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ -if (fuse_file_passthrough (ff) && !(ff->open_flags &FOPEN_DIRECT_IO )) +if (ff->open_flags &FOPEN_DIRECT_IO ) +return copy_splice_read (in, ppos, pipe, len, flags); +else if (fuse_file_passthrough (ff))return fuse_passthrough_splice_read (in, ppos, pipe, len, flags);else return filemap_splice_read (in, ppos, pipe, len, flags);
Signature · 1 line
2.52.0