aboutsummaryrefslogtreecommitdiffstats
path: root/fs/splice.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-06-01 08:54:11 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-06-08 02:32:38 -0400
commitd366d39885b4a56eb90c7670deb46d82501579ad (patch)
tree1b12e45f308ef4f24cb90dda8bd679ec058dc980 /fs/splice.c
parent85f6038f2170e3335dda09c3dfb0f83110e87019 (diff)
splice: move inode size check into generic_file_splice_read()
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/splice.c')
-rw-r--r--fs/splice.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 12f28281d2b1..228a48799d11 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -478,10 +478,18 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
478{ 478{
479 ssize_t spliced; 479 ssize_t spliced;
480 int ret; 480 int ret;
481 loff_t isize, left;
482
483 isize = i_size_read(in->f_mapping->host);
484 if (unlikely(*ppos >= isize))
485 return 0;
486
487 left = isize - *ppos;
488 if (unlikely(left < len))
489 len = left;
481 490
482 ret = 0; 491 ret = 0;
483 spliced = 0; 492 spliced = 0;
484
485 while (len) { 493 while (len) {
486 ret = __generic_file_splice_read(in, ppos, pipe, len, flags); 494 ret = __generic_file_splice_read(in, ppos, pipe, len, flags);
487 495
@@ -922,7 +930,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
922 struct pipe_inode_info *pipe, size_t len, 930 struct pipe_inode_info *pipe, size_t len,
923 unsigned int flags) 931 unsigned int flags)
924{ 932{
925 loff_t isize, left;
926 int ret; 933 int ret;
927 934
928 if (unlikely(!in->f_op || !in->f_op->splice_read)) 935 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 if (unlikely(ret < 0)) 942 if (unlikely(ret < 0))
936 return ret; 943 return ret;
937 944
938 isize = i_size_read(in->f_mapping->host);
939 if (unlikely(*ppos >= isize))
940 return 0;
941
942 left = isize - *ppos;
943 if (unlikely(left < len))
944 len = left;
945
946 return in->f_op->splice_read(in, ppos, pipe, len, flags); 945 return in->f_op->splice_read(in, ppos, pipe, len, flags);
947} 946}
948 947