linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()
       [not found] <20230520000049.2226926-1-dhowells@redhat.com>
@ 2023-05-20  0:00 ` David Howells
  2023-05-20  4:11   ` Christoph Hellwig
                     ` (3 more replies)
  2023-05-20  0:00 ` [PATCH v21 18/30] ext4: Provide a splice-read stub David Howells
  1 sibling, 4 replies; 10+ messages in thread
From: David Howells @ 2023-05-20  0:00 UTC (permalink / raw)
  To: Jens Axboe, Al Viro, Christoph Hellwig
  Cc: David Howells, Matthew Wilcox, Jan Kara, Jeff Layton,
	David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe, Hillf Danton,
	Christian Brauner, Linus Torvalds, linux-fsdevel, linux-block,
	linux-kernel, linux-mm, Christoph Hellwig, linux-erofs,
	linux-ext4, linux-xfs

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 <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: linux-erofs@lists.ozlabs.org
cc: linux-ext4@vger.kernel.org
cc: linux-xfs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-mm@kvack.org
---

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);
 }


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v21 18/30] ext4: Provide a splice-read stub
       [not found] <20230520000049.2226926-1-dhowells@redhat.com>
  2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
@ 2023-05-20  0:00 ` David Howells
  2023-05-20  4:12   ` Christoph Hellwig
  1 sibling, 1 reply; 10+ messages in thread
From: David Howells @ 2023-05-20  0:00 UTC (permalink / raw)
  To: Jens Axboe, Al Viro, Christoph Hellwig
  Cc: David Howells, Matthew Wilcox, Jan Kara, Jeff Layton,
	David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe, Hillf Danton,
	Christian Brauner, Linus Torvalds, linux-fsdevel, linux-block,
	linux-kernel, linux-mm, Christoph Hellwig, Theodore Ts'o,
	Andreas Dilger, linux-ext4

Provide a splice_read stub for Ext4.  This does the inode shutdown check
before proceeding.  Splicing from DAX files and O_DIRECT fds is handled by
the caller.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Jens Axboe <axboe@kernel.dk>
cc: "Theodore Ts'o" <tytso@mit.edu>
cc: Andreas Dilger <adilger.kernel@dilger.ca>
cc: linux-ext4@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-block@vger.kernel.org
cc: linux-mm@kvack.org
---
 fs/ext4/file.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index d101b3b0c7da..9f8bbd9d131c 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -147,6 +147,17 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	return generic_file_read_iter(iocb, to);
 }
 
+static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos,
+				     struct pipe_inode_info *pipe,
+				     size_t len, unsigned int flags)
+{
+	struct inode *inode = file_inode(in);
+
+	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+		return -EIO;
+	return generic_file_splice_read(in, ppos, pipe, len, flags);
+}
+
 /*
  * Called when an inode is released. Note that this is different
  * from ext4_file_open: open gets called at every open, but release
@@ -957,7 +968,7 @@ const struct file_operations ext4_file_operations = {
 	.release	= ext4_release_file,
 	.fsync		= ext4_sync_file,
 	.get_unmapped_area = thp_get_unmapped_area,
-	.splice_read	= generic_file_splice_read,
+	.splice_read	= ext4_file_splice_read,
 	.splice_write	= iter_file_splice_write,
 	.fallocate	= ext4_fallocate,
 };


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()
  2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
@ 2023-05-20  4:11   ` Christoph Hellwig
  2023-05-20  9:41   ` Christian Brauner
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-20  4:11 UTC (permalink / raw)
  To: David Howells
  Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	linux-erofs, linux-ext4, linux-xfs

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 18/30] ext4: Provide a splice-read stub
  2023-05-20  0:00 ` [PATCH v21 18/30] ext4: Provide a splice-read stub David Howells
@ 2023-05-20  4:12   ` Christoph Hellwig
  2023-05-20  7:21     ` David Howells
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-20  4:12 UTC (permalink / raw)
  To: David Howells
  Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	Theodore Ts'o, Andreas Dilger, linux-ext4

On Sat, May 20, 2023 at 01:00:37AM +0100, David Howells wrote:
> Provide a splice_read stub for Ext4.  This does the inode shutdown check
> before proceeding.  Splicing from DAX files and O_DIRECT fds is handled by
> the caller.

Not sure I'd call this a stub, but then again I'm not a native speaker.

The patch itself looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 18/30] ext4: Provide a splice-read stub
  2023-05-20  4:12   ` Christoph Hellwig
@ 2023-05-20  7:21     ` David Howells
  2023-05-20  9:01       ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: David Howells @ 2023-05-20  7:21 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dhowells, Jens Axboe, Al Viro, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	Theodore Ts'o, Andreas Dilger, linux-ext4

Christoph Hellwig <hch@infradead.org> wrote:

> Not sure I'd call this a stub, but then again I'm not a native speaker.

"Wrapper"?

David


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 18/30] ext4: Provide a splice-read stub
  2023-05-20  7:21     ` David Howells
@ 2023-05-20  9:01       ` Christoph Hellwig
  2023-05-21  0:26         ` Theodore Ts'o
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-20  9:01 UTC (permalink / raw)
  To: David Howells
  Cc: Christoph Hellwig, Jens Axboe, Al Viro, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	Theodore Ts'o, Andreas Dilger, linux-ext4

On Sat, May 20, 2023 at 08:21:44AM +0100, David Howells wrote:
> Christoph Hellwig <hch@infradead.org> wrote:
> 
> > Not sure I'd call this a stub, but then again I'm not a native speaker.
> 
> "Wrapper"?

That's what I'd call it, yes.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()
  2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
  2023-05-20  4:11   ` Christoph Hellwig
@ 2023-05-20  9:41   ` Christian Brauner
  2023-05-21  0:28   ` Theodore Ts'o
  2023-05-21 14:55   ` Gao Xiang
  3 siblings, 0 replies; 10+ messages in thread
From: Christian Brauner @ 2023-05-20  9:41 UTC (permalink / raw)
  To: David Howells
  Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Linus Torvalds, linux-fsdevel, linux-block,
	linux-kernel, linux-mm, Christoph Hellwig, linux-erofs,
	linux-ext4, linux-xfs

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 <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-ext4@vger.kernel.org
> cc: linux-xfs@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> cc: linux-block@vger.kernel.org
> cc: linux-mm@kvack.org
> ---

Fwiw, O_DIRECT and DAX could've just been folded into one patch imho.
Reviewed-by: Christian Brauner <brauner@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 18/30] ext4: Provide a splice-read stub
  2023-05-20  9:01       ` Christoph Hellwig
@ 2023-05-21  0:26         ` Theodore Ts'o
  0 siblings, 0 replies; 10+ messages in thread
From: Theodore Ts'o @ 2023-05-21  0:26 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: David Howells, Jens Axboe, Al Viro, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	Andreas Dilger, linux-ext4

On Sat, May 20, 2023 at 02:01:47AM -0700, Christoph Hellwig wrote:
> On Sat, May 20, 2023 at 08:21:44AM +0100, David Howells wrote:
> > Christoph Hellwig <hch@infradead.org> wrote:
> > 
> > > Not sure I'd call this a stub, but then again I'm not a native speaker.
> > 
> > "Wrapper"?
> 
> That's what I'd call it, yes.

Agreed, "wrapper" is a better term.

Other than that,

Acked-by: Theodore Ts'o <tytso@mit.edu>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()
  2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
  2023-05-20  4:11   ` Christoph Hellwig
  2023-05-20  9:41   ` Christian Brauner
@ 2023-05-21  0:28   ` Theodore Ts'o
  2023-05-21 14:55   ` Gao Xiang
  3 siblings, 0 replies; 10+ messages in thread
From: Theodore Ts'o @ 2023-05-21  0:28 UTC (permalink / raw)
  To: David Howells
  Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
	Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
	Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
	linux-block, linux-kernel, linux-mm, Christoph Hellwig,
	linux-erofs, linux-ext4, linux-xfs

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 <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-ext4@vger.kernel.org

Reviewed-by: Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read()
  2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
                     ` (2 preceding siblings ...)
  2023-05-21  0:28   ` Theodore Ts'o
@ 2023-05-21 14:55   ` Gao Xiang
  3 siblings, 0 replies; 10+ messages in thread
From: Gao Xiang @ 2023-05-21 14:55 UTC (permalink / raw)
  To: David Howells, Jens Axboe, Al Viro, Christoph Hellwig
  Cc: linux-erofs, linux-block, Hillf Danton, Jan Kara, linux-xfs,
	David Hildenbrand, Linus Torvalds, Jeff Layton, Christian Brauner,
	Matthew Wilcox, linux-kernel, linux-mm, Jason Gunthorpe,
	linux-fsdevel, linux-ext4, Logan Gunthorpe, Christoph Hellwig



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 <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-ext4@vger.kernel.org
> cc: linux-xfs@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> cc: linux-block@vger.kernel.org
> cc: linux-mm@kvack.org

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Thanks,
Gao Xiang


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-05-21 14:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230520000049.2226926-1-dhowells@redhat.com>
2023-05-20  0:00 ` [PATCH v21 08/30] splice: Make splice from a DAX file use copy_splice_read() David Howells
2023-05-20  4:11   ` Christoph Hellwig
2023-05-20  9:41   ` Christian Brauner
2023-05-21  0:28   ` Theodore Ts'o
2023-05-21 14:55   ` Gao Xiang
2023-05-20  0:00 ` [PATCH v21 18/30] ext4: Provide a splice-read stub David Howells
2023-05-20  4:12   ` Christoph Hellwig
2023-05-20  7:21     ` David Howells
2023-05-20  9:01       ` Christoph Hellwig
2023-05-21  0:26         ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).