From 2ce948bf8f2374609611eb3dcf1999a823a7b243 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Thu, 19 Jul 2007 01:48:06 -0700 Subject: [PATCH] --- yaml --- r: 61575 b: refs/heads/master c: d8983910a4045fa21022cfccf76ed13eb40fd7f5 h: refs/heads/master i: 61573: 4fe3c389276439fae4fc2357cbb51dbb5f1bcfa9 61571: bfd096cd5be8bd78a3fcdc419a5ac3351d3042d4 61567: 56fcb65c7941bdd6824bb090d4a7731af102771d v: v3 --- [refs] | 2 +- trunk/fs/splice.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index b0dcd4366705..cc211ec595c9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 431a4820bfcdf7ff530e745230bafb06c9bf2d6d +refs/heads/master: d8983910a4045fa21022cfccf76ed13eb40fd7f5 diff --git a/trunk/fs/splice.c b/trunk/fs/splice.c index 421b3b821152..6ddd0329f866 100644 --- a/trunk/fs/splice.c +++ b/trunk/fs/splice.c @@ -265,7 +265,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, unsigned int flags) { struct address_space *mapping = in->f_mapping; - unsigned int loff, nr_pages; + unsigned int loff, nr_pages, req_pages; struct page *pages[PIPE_BUFFERS]; struct partial_page partial[PIPE_BUFFERS]; struct page *page; @@ -281,10 +281,8 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, index = *ppos >> PAGE_CACHE_SHIFT; loff = *ppos & ~PAGE_CACHE_MASK; - nr_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - - if (nr_pages > PIPE_BUFFERS) - nr_pages = PIPE_BUFFERS; + req_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + nr_pages = min(req_pages, (unsigned)PIPE_BUFFERS); /* * Lookup the (hopefully) full range of pages we need. @@ -298,7 +296,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, */ if (spd.nr_pages < nr_pages) page_cache_readahead_ondemand(mapping, &in->f_ra, in, - NULL, index, nr_pages - spd.nr_pages); + NULL, index, req_pages - spd.nr_pages); error = 0; while (spd.nr_pages < nr_pages) { @@ -355,7 +353,7 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, if (PageReadahead(page)) page_cache_readahead_ondemand(mapping, &in->f_ra, in, - page, index, nr_pages - page_nr); + page, index, req_pages - page_nr); /* * If the page isn't uptodate, we may need to start io on it