From d49b7e61ea0374b909e243a104d4e0e81ac73142 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 20 Apr 2006 13:05:48 +0200 Subject: [PATCH] --- yaml --- r: 26060 b: refs/heads/master c: 82aa5d6183667aa2a5f3c61e390934b0273d2ad7 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/splice.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 4f74b464f88f..fec43209a12a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a0aa7f68afeeb92f6274b395177c20e617c8ed2d +refs/heads/master: 82aa5d6183667aa2a5f3c61e390934b0273d2ad7 diff --git a/trunk/fs/splice.c b/trunk/fs/splice.c index 22fac87e90b3..0559e7577a04 100644 --- a/trunk/fs/splice.c +++ b/trunk/fs/splice.c @@ -275,6 +275,15 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, error = 0; bytes = 0; for (i = 0; i < nr_pages; i++, index++) { + unsigned int this_len; + + if (!len) + break; + + /* + * this_len is the max we'll use from this page + */ + this_len = min(len, PAGE_CACHE_SIZE - loff); find_page: /* * lookup the page for this index @@ -366,11 +375,13 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, * force quit after adding this page */ nr_pages = i; + this_len = min(this_len, loff); } } fill_it: pages[i] = page; - bytes += PAGE_CACHE_SIZE - loff; + bytes += this_len; + len -= this_len; loff = 0; }