From: David Howells Date: Mon, 22 May 2023 13:49:54 +0000 (+0100) Subject: splice: Make splice from an O_DIRECT fd use copy_splice_read() X-Git-Tag: v6.6.7~2609^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa3dbde878961dd333cdd3c326b93e6c84a23ed4;p=platform%2Fkernel%2Flinux-starfive.git 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 Reviewed-by: Christoph Hellwig Reviewed-by: Christian Brauner cc: Al Viro cc: Jens Axboe 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 --- diff --git a/fs/splice.c b/fs/splice.c index fe3309f..76126b1 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -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);