diff mbox series

[v21,18/30] ext4: Provide a splice-read stub

Message ID 20230520000049.2226926-19-dhowells@redhat.com (mailing list archive)
State New
Headers show
Series splice: Kill ITER_PIPE | expand

Commit Message

David Howells May 20, 2023, midnight UTC
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(-)

Comments

Christoph Hellwig May 20, 2023, 4:12 a.m. UTC | #1
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>
David Howells May 20, 2023, 7:21 a.m. UTC | #2
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
Christoph Hellwig May 20, 2023, 9:01 a.m. UTC | #3
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.
Theodore Ts'o May 21, 2023, 12:26 a.m. UTC | #4
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>
diff mbox series

Patch

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