Re: [PATCH 3/4] readahead: factor out duplicated code

From: Oleg Nesterov
Date: Thu Feb 03 2005 - 05:32:32 EST


Steven Pratt wrote:
>
> >+static int make_ahead_window(struct address_space *mapping, struct file *filp,
> >+ struct file_ra_state *ra, int force)
> >+{
> >+ int block, ret;
> >+
> >+ 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) {
> >
> This really needs to be
>
> if (!ret && !block) {
>

Current code:

block = offset + newsize-1 >= ra->ahead_start;
if (!blockable_page_cache_readahead(..., block) {
ra->ahead_start = 0;
ra->ahead_size = 0;
}

Patched code:
make_ahead_window(..., 0); // force == 0

So i think the patch is correct.

> otherwise we can have an aheadwindow which was never populated which
> will cause slow reads which we want to avoid in all cases.

may be, but this patch tries not to change the current behavior.

Oleg.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/