Skip to content

Commit

Permalink
splice: move inode size check into generic_file_splice_read()
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Jens Axboe committed Jun 8, 2007
1 parent 85f6038 commit d366d39
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,18 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
{
ssize_t spliced;
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;
spliced = 0;

while (len) {
ret = __generic_file_splice_read(in, ppos, pipe, len, flags);

Expand Down Expand Up @@ -922,7 +930,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe, size_t len,
unsigned int flags)
{
loff_t isize, left;
int ret;

if (unlikely(!in->f_op || !in->f_op->splice_read))
Expand All @@ -935,14 +942,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
if (unlikely(ret < 0))
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);
}

Expand Down

0 comments on commit d366d39

Please sign in to comment.