Commit aa3dbde8 authored by David Howells's avatar David Howells Committed by Jens Axboe

splice: Make splice from an O_DIRECT fd use copy_splice_read()

Make a read splice from a file descriptor that's open O_DIRECT use
copy_splice_read() to do the reading as filemap_splice_read() is unlikely
to find any pagecache to splice.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: linux-fsdevel@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-mm@kvack.org
Link: https://lore.kernel.org/r/20230522135018.2742245-8-dhowells@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 123856f0
...@@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos, ...@@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos,
if (unlikely(!in->f_op->splice_read)) if (unlikely(!in->f_op->splice_read))
return warn_unsupported(in, "read"); return warn_unsupported(in, "read");
/*
* O_DIRECT doesn't deal with the pagecache, so we allocate a buffer,
* copy into it and splice that into the pipe.
*/
if ((in->f_flags & O_DIRECT))
return copy_splice_read(in, ppos, pipe, len, flags);
return in->f_op->splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags);
} }
EXPORT_SYMBOL_GPL(vfs_splice_read); EXPORT_SYMBOL_GPL(vfs_splice_read);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment