diff options
author | Fengguang Wu <wfg@mail.ustc.edu.cn> | 2007-07-19 01:48:05 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 10:04:44 -0700 |
commit | 431a4820bfcdf7ff530e745230bafb06c9bf2d6d (patch) | |
tree | 0b2396609deec8da5697979bce4c8ee18af254e6 /fs | |
parent | c743d96b6d2ff55a94df7b5ac7c74987bb9c343b (diff) | |
download | linux-431a4820bfcdf7ff530e745230bafb06c9bf2d6d.tar.gz linux-431a4820bfcdf7ff530e745230bafb06c9bf2d6d.tar.bz2 linux-431a4820bfcdf7ff530e745230bafb06c9bf2d6d.zip |
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.c | 11 |
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, * Lookup the (hopefully) full range of pages we need. */ spd.nr_pages = find_get_pages_contig(mapping, index, nr_pages, pages); + index += spd.nr_pages; /* * If find_get_pages_contig() returned fewer pages than we needed, - * allocate the rest and fill in the holes. + * readahead/allocate the rest and fill in the holes. */ + if (spd.nr_pages < nr_pages) + page_cache_readahead_ondemand(mapping, &in->f_ra, in, + NULL, index, nr_pages - spd.nr_pages); + error = 0; - index += spd.nr_pages; while (spd.nr_pages < nr_pages) { /* * Page could be there, find_get_pages_contig() breaks on @@ -304,9 +308,6 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, */ page = find_get_page(mapping, index); if (!page) { - page_cache_readahead_ondemand(mapping, &in->f_ra, in, - NULL, index, nr_pages - spd.nr_pages); - /* * page didn't exist, allocate one. */ |