public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ram <linuxram@us.ibm.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: linux-kernel@vger.kernel.org,
	Steven Pratt <slpratt@austin.ibm.com>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH 3/4] readahead: factor out duplicated code
Date: Wed, 02 Feb 2005 18:43:14 -0800	[thread overview]
Message-ID: <1107398594.5992.134.camel@localhost> (raw)
In-Reply-To: <41FB7517.418D556A@tv-sign.ru>

On Sat, 2005-01-29 at 03:35, Oleg Nesterov wrote:
> > 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) {

As steve pointed out this should be :
         if ( !ret && ! block ) {

> 		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;

At this point prev_page has to be updated:
              ra->prev_page = offset;

> 		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;
> }
Otherwise this code looks much cleaner and correct. Can you send me a
updated patch. I will run it through my test harness.

RP


  reply	other threads:[~2005-02-03  2:46 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
2005-02-03  2:43   ` Ram [this message]
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=1107398594.5992.134.camel@localhost \
    --to=linuxram@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --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