Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=431a4820bfcdf7ff530e745230bafb06c9bf2d6d
Commit:     431a4820bfcdf7ff530e745230bafb06c9bf2d6d
Parent:     c743d96b6d2ff55a94df7b5ac7c74987bb9c343b
Author:     Fengguang Wu <[EMAIL PROTECTED]>
AuthorDate: Thu Jul 19 01:48:05 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Jul 19 10:04:44 2007 -0700

    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 <[EMAIL PROTECTED]>
    Cc: Jens Axboe <[EMAIL PROTECTED]>
    Cc: Rusty Russell <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/splice.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index 722449f..421b3b8 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.
                         */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to