2023-05-20 00:03:54

by David Howells

[permalink] [raw]
Subject: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()

Make a read splice from a DAX file go directly to copy_splice_read() to do
the reading as filemap_splice_read() is unlikely to find any pagecache to
splice.

I think this affects only erofs, Ext2, Ext4, fuse and XFS.

Signed-off-by: David Howells <[email protected]>
cc: Christoph Hellwig <[email protected]>
cc: Al Viro <[email protected]>
cc: Jens Axboe <[email protected]>
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
---

Notes:
ver #21)
- Don't need #ifdef CONFIG_FS_DAX as IS_DAX() is false if !CONFIG_FS_DAX.
- Needs to be in vfs_splice_read(), not generic_file_splice_read().

fs/splice.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index 76126b1aafcb..8268248df3a9 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -908,10 +908,10 @@ 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.
+ * O_DIRECT and DAX don'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))
+ if ((in->f_flags & O_DIRECT) || IS_DAX(in->f_mapping->host))
return copy_splice_read(in, ppos, pipe, len, flags);
return in->f_op->splice_read(in, ppos, pipe, len, flags);
}



2023-05-20 09:48:19

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()

On Sat, May 20, 2023 at 01:00:27AM +0100, David Howells wrote:
> Make a read splice from a DAX file go directly to copy_splice_read() to do
> the reading as filemap_splice_read() is unlikely to find any pagecache to
> splice.
>
> I think this affects only erofs, Ext2, Ext4, fuse and XFS.
>
> Signed-off-by: David Howells <[email protected]>
> cc: Christoph Hellwig <[email protected]>
> cc: Al Viro <[email protected]>
> cc: Jens Axboe <[email protected]>
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> ---

Fwiw, O_DIRECT and DAX could've just been folded into one patch imho.
Reviewed-by: Christian Brauner <[email protected]>

2023-05-21 00:29:34

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()

On Sat, May 20, 2023 at 01:00:27AM +0100, David Howells wrote:
> Make a read splice from a DAX file go directly to copy_splice_read() to do
> the reading as filemap_splice_read() is unlikely to find any pagecache to
> splice.
>
> I think this affects only erofs, Ext2, Ext4, fuse and XFS.
>
> Signed-off-by: David Howells <[email protected]>
> cc: Christoph Hellwig <[email protected]>
> cc: Al Viro <[email protected]>
> cc: Jens Axboe <[email protected]>
> cc: [email protected]
> cc: [email protected]

Reviewed-by: Theodore Ts'o <[email protected]>

2023-05-21 15:13:56

by Gao Xiang

[permalink] [raw]
Subject: Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()



On 2023/5/20 17:00, David Howells wrote:
> Make a read splice from a DAX file go directly to copy_splice_read() to do
> the reading as filemap_splice_read() is unlikely to find any pagecache to
> splice.
>
> I think this affects only erofs, Ext2, Ext4, fuse and XFS.
>
> Signed-off-by: David Howells <[email protected]>
> cc: Christoph Hellwig <[email protected]>
> cc: Al Viro <[email protected]>
> cc: Jens Axboe <[email protected]>
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]
> cc: [email protected]

Reviewed-by: Gao Xiang <[email protected]>

Thanks,
Gao Xiang