Skip to content

Commit aa3dbde

Browse files
dhowellsaxboe
authored andcommitted
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: David Howells <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Christian Brauner <[email protected]> cc: Al Viro <[email protected]> cc: Jens Axboe <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 123856f commit aa3dbde

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/splice.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos,
907907

908908
if (unlikely(!in->f_op->splice_read))
909909
return warn_unsupported(in, "read");
910+
/*
911+
* O_DIRECT doesn't deal with the pagecache, so we allocate a buffer,
912+
* copy into it and splice that into the pipe.
913+
*/
914+
if ((in->f_flags & O_DIRECT))
915+
return copy_splice_read(in, ppos, pipe, len, flags);
910916
return in->f_op->splice_read(in, ppos, pipe, len, flags);
911917
}
912918
EXPORT_SYMBOL_GPL(vfs_splice_read);

0 commit comments

Comments
 (0)