|
23 | 23 | #include <linux/slab.h>
|
24 | 24 | #include <linux/uaccess.h>
|
25 | 25 | #include <linux/uio.h>
|
| 26 | +#include <linux/splice.h> |
26 | 27 |
|
27 | 28 | #include <linux/coda.h>
|
28 | 29 | #include "coda_psdev.h"
|
@@ -94,6 +95,32 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
|
94 | 95 | return ret;
|
95 | 96 | }
|
96 | 97 |
|
| 98 | +static ssize_t |
| 99 | +coda_file_splice_read(struct file *coda_file, loff_t *ppos, |
| 100 | + struct pipe_inode_info *pipe, |
| 101 | + size_t len, unsigned int flags) |
| 102 | +{ |
| 103 | + struct inode *coda_inode = file_inode(coda_file); |
| 104 | + struct coda_file_info *cfi = coda_ftoc(coda_file); |
| 105 | + struct file *in = cfi->cfi_container; |
| 106 | + loff_t ki_pos = *ppos; |
| 107 | + ssize_t ret; |
| 108 | + |
| 109 | + ret = venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), |
| 110 | + &cfi->cfi_access_intent, |
| 111 | + len, ki_pos, CODA_ACCESS_TYPE_READ); |
| 112 | + if (ret) |
| 113 | + goto finish_read; |
| 114 | + |
| 115 | + ret = vfs_splice_read(in, ppos, pipe, len, flags); |
| 116 | + |
| 117 | +finish_read: |
| 118 | + venus_access_intent(coda_inode->i_sb, coda_i2f(coda_inode), |
| 119 | + &cfi->cfi_access_intent, |
| 120 | + len, ki_pos, CODA_ACCESS_TYPE_READ_FINISH); |
| 121 | + return ret; |
| 122 | +} |
| 123 | + |
97 | 124 | static void
|
98 | 125 | coda_vm_open(struct vm_area_struct *vma)
|
99 | 126 | {
|
@@ -302,5 +329,5 @@ const struct file_operations coda_file_operations = {
|
302 | 329 | .open = coda_open,
|
303 | 330 | .release = coda_release,
|
304 | 331 | .fsync = coda_fsync,
|
305 |
| - .splice_read = generic_file_splice_read, |
| 332 | + .splice_read = coda_file_splice_read, |
306 | 333 | };
|
0 commit comments