Skip to content

Commit

Permalink
splice: Make splice from an O_DIRECT fd use copy_splice_read()
Browse files Browse the repository at this point in the history
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 <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian 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.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
David Howells authored and Jens Axboe committed May 24, 2023
1 parent 123856f commit aa3dbde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ long vfs_splice_read(struct file *in, loff_t *ppos,

if (unlikely(!in->f_op->splice_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);
}
EXPORT_SYMBOL_GPL(vfs_splice_read);
Expand Down

0 comments on commit aa3dbde

Please sign in to comment.