Commit d366d398 authored by Jens Axboe's avatar Jens Axboe

splice: move inode size check into generic_file_splice_read()

Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 85f6038f
...@@ -478,10 +478,18 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, ...@@ -478,10 +478,18 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
{ {
ssize_t spliced; ssize_t spliced;
int ret; int ret;
loff_t isize, left;
isize = i_size_read(in->f_mapping->host);
if (unlikely(*ppos >= isize))
return 0;
left = isize - *ppos;
if (unlikely(left < len))
len = left;
ret = 0; ret = 0;
spliced = 0; spliced = 0;
while (len) { while (len) {
ret = __generic_file_splice_read(in, ppos, pipe, len, flags); ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
...@@ -922,7 +930,6 @@ static long do_splice_to(struct file *in, loff_t *ppos, ...@@ -922,7 +930,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe, size_t len, struct pipe_inode_info *pipe, size_t len,
unsigned int flags) unsigned int flags)
{ {
loff_t isize, left;
int ret; int ret;
if (unlikely(!in->f_op || !in->f_op->splice_read)) if (unlikely(!in->f_op || !in->f_op->splice_read))
...@@ -935,14 +942,6 @@ static long do_splice_to(struct file *in, loff_t *ppos, ...@@ -935,14 +942,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
if (unlikely(ret < 0)) if (unlikely(ret < 0))
return ret; return ret;
isize = i_size_read(in->f_mapping->host);
if (unlikely(*ppos >= isize))
return 0;
left = isize - *ppos;
if (unlikely(left < len))
len = left;
return in->f_op->splice_read(in, ppos, pipe, len, flags); return in->f_op->splice_read(in, ppos, pipe, len, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment