Skip to content

Commit fa6c46e

Browse files
dhowellsaxboe
authored andcommitted
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]>
1 parent 390df3b commit fa6c46e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

fs/ext4/file.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
147147
return generic_file_read_iter(iocb, to);
148148
}
149149

150+
static ssize_t ext4_file_splice_read(struct file *in, loff_t *ppos,
151+
struct pipe_inode_info *pipe,
152+
size_t len, unsigned int flags)
153+
{
154+
struct inode *inode = file_inode(in);
155+
156+
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
157+
return -EIO;
158+
return generic_file_splice_read(in, ppos, pipe, len, flags);
159+
}
160+
150161
/*
151162
* Called when an inode is released. Note that this is different
152163
* from ext4_file_open: open gets called at every open, but release
@@ -957,7 +968,7 @@ const struct file_operations ext4_file_operations = {
957968
.release = ext4_release_file,
958969
.fsync = ext4_sync_file,
959970
.get_unmapped_area = thp_get_unmapped_area,
960-
.splice_read = generic_file_splice_read,
971+
.splice_read = ext4_file_splice_read,
961972
.splice_write = iter_file_splice_write,
962973
.fallocate = ext4_fallocate,
963974
};

0 commit comments

Comments
 (0)