Skip to content

Commit 6bbf64b

Browse files
dhowellsaxboe
authored andcommitted
orangefs: Provide a splice-read wrapper
Provide a splice_read wrapper for ocfs2. This increments the read stats and then locks the inode across the call to filemap_splice_read() and a revalidation of the mapping. Splicing from direct I/O is done by the caller. Signed-off-by: David Howells <[email protected]> cc: Christoph Hellwig <[email protected]> cc: Al Viro <[email protected]> cc: Jens Axboe <[email protected]> cc: Mike Marshall <[email protected]> cc: Martin Brandenburg <[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 94aca68 commit 6bbf64b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

fs/orangefs/file.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,26 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb,
337337
return ret;
338338
}
339339

340+
static ssize_t orangefs_file_splice_read(struct file *in, loff_t *ppos,
341+
struct pipe_inode_info *pipe,
342+
size_t len, unsigned int flags)
343+
{
344+
struct inode *inode = file_inode(in);
345+
ssize_t ret;
346+
347+
orangefs_stats.reads++;
348+
349+
down_read(&inode->i_rwsem);
350+
ret = orangefs_revalidate_mapping(inode);
351+
if (ret)
352+
goto out;
353+
354+
ret = filemap_splice_read(in, ppos, pipe, len, flags);
355+
out:
356+
up_read(&inode->i_rwsem);
357+
return ret;
358+
}
359+
340360
static ssize_t orangefs_file_write_iter(struct kiocb *iocb,
341361
struct iov_iter *iter)
342362
{
@@ -556,7 +576,7 @@ const struct file_operations orangefs_file_operations = {
556576
.lock = orangefs_lock,
557577
.mmap = orangefs_file_mmap,
558578
.open = generic_file_open,
559-
.splice_read = generic_file_splice_read,
579+
.splice_read = orangefs_file_splice_read,
560580
.splice_write = iter_file_splice_write,
561581
.flush = orangefs_flush,
562582
.release = orangefs_file_release,

0 commit comments

Comments
 (0)