Skip to content

Commit c829d0b

Browse files
dhowellsaxboe
authored andcommitted
9p: Add splice_read wrapper
Add a splice_read wrapper for 9p. We should use copy_splice_read() if 9PL_DIRECT is set and filemap_splice_read() otherwise. Note that this doesn't seem to be particularly related to O_DIRECT. Signed-off-by: David Howells <[email protected]> cc: Christoph Hellwig <[email protected]> cc: Al Viro <[email protected]> cc: Jens Axboe <[email protected]> cc: Dominique Martinet <[email protected]> cc: Eric Van Hensbergen <[email protected]> cc: Latchesar Ionkov <[email protected]> cc: Christian Schoenebeck <[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 67178fd commit c829d0b

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

fs/9p/vfs_file.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,28 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
374374
return ret;
375375
}
376376

377+
/*
378+
* v9fs_file_splice_read - splice-read from a file
379+
* @in: The 9p file to read from
380+
* @ppos: Where to find/update the file position
381+
* @pipe: The pipe to splice into
382+
* @len: The maximum amount of data to splice
383+
* @flags: SPLICE_F_* flags
384+
*/
385+
static ssize_t v9fs_file_splice_read(struct file *in, loff_t *ppos,
386+
struct pipe_inode_info *pipe,
387+
size_t len, unsigned int flags)
388+
{
389+
struct p9_fid *fid = in->private_data;
390+
391+
p9_debug(P9_DEBUG_VFS, "fid %d count %zu offset %lld\n",
392+
fid->fid, len, *ppos);
393+
394+
if (fid->mode & P9L_DIRECT)
395+
return copy_splice_read(in, ppos, pipe, len, flags);
396+
return filemap_splice_read(in, ppos, pipe, len, flags);
397+
}
398+
377399
/**
378400
* v9fs_file_write_iter - write to a file
379401
* @iocb: The operation parameters
@@ -569,7 +591,7 @@ const struct file_operations v9fs_file_operations = {
569591
.release = v9fs_dir_release,
570592
.lock = v9fs_file_lock,
571593
.mmap = generic_file_readonly_mmap,
572-
.splice_read = generic_file_splice_read,
594+
.splice_read = v9fs_file_splice_read,
573595
.splice_write = iter_file_splice_write,
574596
.fsync = v9fs_file_fsync,
575597
};
@@ -583,7 +605,7 @@ const struct file_operations v9fs_file_operations_dotl = {
583605
.lock = v9fs_file_lock_dotl,
584606
.flock = v9fs_file_flock_dotl,
585607
.mmap = v9fs_file_mmap,
586-
.splice_read = generic_file_splice_read,
608+
.splice_read = v9fs_file_splice_read,
587609
.splice_write = iter_file_splice_write,
588610
.fsync = v9fs_file_fsync_dotl,
589611
};

0 commit comments

Comments
 (0)