aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorFengguang Wu <wfg@mail.ustc.edu.cn>2007-07-19 04:48:05 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:44 -0400
commit431a4820bfcdf7ff530e745230bafb06c9bf2d6d (patch)
tree0b2396609deec8da5697979bce4c8ee18af254e6 /fs
parentc743d96b6d2ff55a94df7b5ac7c74987bb9c343b (diff)
readahead: move synchronous readahead call out of splice loop
Move synchronous page_cache_readahead_ondemand() call out of splice loop. This avoids one pointless page allocation/insertion in case of non-zero ra_pages, or many pointless readahead calls in case of zero ra_pages. Note that if a user sets ra_pages to less than PIPE_BUFFERS=16 pages, he will not get expected readahead behavior anyway. The splice code works in batches of 16 pages, which can be taken as another form of synchronous readahead. Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn> Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/splice.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 722449f7d5d6..421b3b821152 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -290,13 +290,17 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
290 * Lookup the (hopefully) full range of pages we need. 290 * Lookup the (hopefully) full range of pages we need.
291 */ 291 */
292 spd.nr_pages = find_get_pages_contig(mapping, index, nr_pages, pages); 292 spd.nr_pages = find_get_pages_contig(mapping, index, nr_pages, pages);
293 index += spd.nr_pages;
293 294
294 /* 295 /*
295 * If find_get_pages_contig() returned fewer pages than we needed, 296 * If find_get_pages_contig() returned fewer pages than we needed,
296 * allocate the rest and fill in the holes. 297 * readahead/allocate the rest and fill in the holes.
297 */ 298 */
299 if (spd.nr_pages < nr_pages)
300 page_cache_readahead_ondemand(mapping, &in->f_ra, in,
301 NULL, index, nr_pages - spd.nr_pages);
302
298 error = 0; 303 error = 0;
299 index += spd.nr_pages;
300 while (spd.nr_pages < nr_pages) { 304 while (spd.nr_pages < nr_pages) {
301 /* 305 /*
302 * Page could be there, find_get_pages_contig() breaks on 306 * Page could be there, find_get_pages_contig() breaks on
@@ -304,9 +308,6 @@ __generic_file_splice_read(struct file *in, loff_t *ppos,
304 */ 308 */
305 page = find_get_page(mapping, index); 309 page = find_get_page(mapping, index);
306 if (!page) { 310 if (!page) {
307 page_cache_readahead_ondemand(mapping, &in->f_ra, in,
308 NULL, index, nr_pages - spd.nr_pages);
309
310 /* 311 /*
311 * page didn't exist, allocate one. 312 * page didn't exist, allocate one.
312 */ 313 */