From: Oleg Nesterov <oleg@tv-sign.ru>
To: linux-kernel@vger.kernel.org
Cc: Ram Pai <linuxram@us.ibm.com>,
Steven Pratt <slpratt@austin.ibm.com>,
Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH 3/4] readahead: factor out duplicated code
Date: Sat, 29 Jan 2005 14:35:51 +0300 [thread overview]
Message-ID: <41FB7517.418D556A@tv-sign.ru> (raw)
In-Reply-To: 41FB6F45.848CEFF6@tv-sign.ru
> This patch introduces make_ahead_window() function for
> simplification of page_cache_readahead.
If you will count this patch acceptable, I'll rediff it against
next mm iteration.
For your convenience here is the code with the patch applied.
int make_ahead_window(mapping, filp, ra, int force)
{
int block, ret;
ra->ahead_size = get_next_ra_size(ra);
ra->ahead_start = ra->start + ra->size;
block = force || (ra->prev_page >= ra->ahead_start);
ret = blockable_page_cache_readahead(mapping, filp,
ra->ahead_start, ra->ahead_size, ra, block);
if (!ret && !force) {
ra->ahead_start = 0;
ra->ahead_size = 0;
}
return ret;
}
unsigned long page_cache_readahead(mapping, ra, filp, offset, req_size)
{
unsigned long max, newsize = req_size;
int sequential = (offset == ra->prev_page + 1);
if (offset == ra->prev_page && req_size == 1 && ra->size != 0)
goto out;
ra->prev_page = offset;
max = get_max_readahead(ra);
newsize = min(req_size, max);
if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) {
newsize = 1;
goto out;
}
ra->prev_page += newsize - 1;
if ((ra->size == 0 && offset == 0) ||
(ra->size == -1 && sequential)) {
ra->size = get_init_ra_size(newsize, max);
ra->start = offset;
if (!blockable_page_cache_readahead(mapping, filp, offset, ra->size, ra, 1))
goto out;
if (req_size >= max)
make_ahead_window(mapping, filp, ra, 1);
goto out;
}
if (!sequential || (ra->size == 0)) {
ra_off(ra);
blockable_page_cache_readahead(mapping, filp, offset, newsize, ra, 1);
goto out;
}
if (ra->ahead_start == 0) {
if (!make_ahead_window(mapping, filp, ra, 0))
goto out;
}
if (ra->prev_page >= ra->ahead_start) {
ra->start = ra->ahead_start;
ra->size = ra->ahead_size;
make_ahead_window(mapping, filp, ra, 0);
}
out:
return newsize;
}
next prev parent reply other threads:[~2005-01-29 10:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-29 11:11 [PATCH 3/4] readahead: factor out duplicated code Oleg Nesterov
2005-01-29 11:35 ` Oleg Nesterov [this message]
2005-02-03 2:43 ` Ram
2005-02-03 11:34 ` Oleg Nesterov
2005-02-02 21:37 ` Steven Pratt
2005-02-03 11:32 ` Oleg Nesterov
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=41FB7517.418D556A@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=slpratt@austin.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox