From: Fengguang Wu <wfg@mail.ustc.edu.cn>
To: Andrew Morton <akpm@osdl.org>
Cc: Jens Axboe <jens.axboe@oracle.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] readahead: pass real splice size
Date: Tue, 12 Jun 2007 11:00:34 +0800 [thread overview]
Message-ID: <381617742.09898@ustc.edu.cn> (raw)
Message-ID: <20070612030905.812075843@mail.ustc.edu.cn> (raw)
In-Reply-To: 20070612030450.590659600@mail.ustc.edu.cn
[-- Attachment #1: readahead-fix-splice-size.patch --]
[-- Type: text/plain, Size: 2025 bytes --]
Pass real splice size to page_cache_readahead_ondemand().
The splice code works in chunks of 16 pages internally.
The readahead code should be told of the overall splice size, instead of
the internal chunk size. Otherwize bad things may happen. Imagine some
17-page random splice reads. The code before this patch will result in
two readahead calls: readahead(16); readahead(1); That leads to one
16-page I/O and one 32-page I/O: one extra I/O and 31 readahead miss pages.
Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
---
fs/splice.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
--- linux-2.6.22-rc3-mm1.orig/fs/splice.c
+++ linux-2.6.22-rc3-mm1/fs/splice.c
@@ -267,7 +267,7 @@ __generic_file_splice_read(struct file *
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;
@@ -284,10 +284,8 @@ __generic_file_splice_read(struct file *
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);
/*
* Now fill in the holes:
@@ -307,7 +305,7 @@ __generic_file_splice_read(struct file *
*/
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);
while (spd.nr_pages < nr_pages) {
/*
@@ -363,7 +361,7 @@ __generic_file_splice_read(struct file *
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
--
next prev parent reply other threads:[~2007-06-12 3:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-12 3:00 [PATCH 0/2] readahead update on splice reads Fengguang Wu
2007-06-12 3:00 ` Fengguang Wu
2007-06-12 3:00 ` [PATCH 1/2] readahead: move synchronous readahead call out of splice loop Fengguang Wu
2007-06-12 3:00 ` Fengguang Wu
2007-06-12 3:00 ` Fengguang Wu [this message]
2007-06-12 3:00 ` [PATCH 2/2] readahead: pass real splice size Fengguang Wu
2007-06-12 6:40 ` [PATCH 0/2] readahead update on splice reads Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=381617742.09898@ustc.edu.cn \
--to=wfg@mail.ustc.edu.cn \
--cc=akpm@osdl.org \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.