]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] splice: fix smaller sized splice reads
authorJens Axboe <axboe@suse.de>
Thu, 20 Apr 2006 11:05:48 +0000 (13:05 +0200)
committerJens Axboe <axboe@suse.de>
Thu, 20 Apr 2006 11:05:48 +0000 (13:05 +0200)
Signed-off-by: Jens Axboe <axboe@suse.de>
fs/splice.c

index 22fac87e90b3d8cc5e87851355c35187f191f2c4..0559e7577a04164ececffdcdbd57089d980dd586 100644 (file)
@@ -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 @@ readpage:
                                 * 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;
        }