diff options
author | David Howells <[email protected]> | 2023-05-22 14:50:05 +0100 |
---|---|---|
committer | Jens Axboe <[email protected]> | 2023-05-24 08:42:16 -0600 |
commit | fa6c46e7c271f155c9ba3ba3457175c0a71eb918 (patch) | |
tree | 1ea158279201d369ba7f814c361e250907bb45ee | |
parent | 390df3b830e758e970a0ba928a97f8bbd5385f0c (diff) |
ext4: Provide a splice-read wrapper
Provide a splice_read wrapper 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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Acked-by: Theodore Ts'o <[email protected]>
cc: Al Viro <[email protected]>
cc: Jens Axboe <[email protected]>
cc: Andreas Dilger <[email protected]>
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r-- | fs/ext4/file.c | 13 |
1 files changed, 12 insertions, 1 deletions
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, }; |