Skip to content

Commit d4120d8

Browse files
dhowellsaxboe
authored andcommitted
overlayfs: Implement splice-read
Implement splice-read for overlayfs by passing the request down a layer rather than going through generic_file_splice_read() which is going to be changed to assume that ->read_folio() is present on buffered files. Signed-off-by: David Howells <[email protected]> Acked-by: Christian Brauner <[email protected]> cc: Christoph Hellwig <[email protected]> cc: Jens Axboe <[email protected]> cc: Al Viro <[email protected]> cc: John Hubbard <[email protected]> cc: David Hildenbrand <[email protected]> cc: Matthew Wilcox <[email protected]> cc: Miklos Szeredi <[email protected]> cc: Amir Goldstein <[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 bd194b1 commit d4120d8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

fs/overlayfs/file.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,27 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
419419
return ret;
420420
}
421421

422+
static ssize_t ovl_splice_read(struct file *in, loff_t *ppos,
423+
struct pipe_inode_info *pipe, size_t len,
424+
unsigned int flags)
425+
{
426+
const struct cred *old_cred;
427+
struct fd real;
428+
ssize_t ret;
429+
430+
ret = ovl_real_fdget(in, &real);
431+
if (ret)
432+
return ret;
433+
434+
old_cred = ovl_override_creds(file_inode(in)->i_sb);
435+
ret = vfs_splice_read(real.file, ppos, pipe, len, flags);
436+
revert_creds(old_cred);
437+
ovl_file_accessed(in);
438+
439+
fdput(real);
440+
return ret;
441+
}
442+
422443
/*
423444
* Calling iter_file_splice_write() directly from overlay's f_op may deadlock
424445
* due to lock order inversion between pipe->mutex in iter_file_splice_write()
@@ -695,7 +716,7 @@ const struct file_operations ovl_file_operations = {
695716
.fallocate = ovl_fallocate,
696717
.fadvise = ovl_fadvise,
697718
.flush = ovl_flush,
698-
.splice_read = generic_file_splice_read,
719+
.splice_read = ovl_splice_read,
699720
.splice_write = ovl_splice_write,
700721

701722
.copy_file_range = ovl_copy_file_range,

0 commit comments

Comments
 (0)