lkml.org 
[lkml]   [2000]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [potential bug] generic_file_readahead()
On Wed, 25 Oct 2000, Alexander Viro wrote:

> In generic_file_readahead():
>
> unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
> unsigned long index = page->index;
> ...
> max_ahead = 0;
> ...
> raend = index;
> if (raend < end_index)
> max_ahead = filp->f_ramax;
> and later
> ahead = 0;
> while (ahead < max_ahead) {
> ahead ++;
> if ((raend + ahead) >= end_index)
> break;
> if (page_cache_read(filp, raend + ahead) < 0)
> break;
> }
>
> AFAICS it means that we have off-by-partial here - if the file size is not
> a multiple of PAGE_CACHE_SIZE we are missing the last page. Proposed
> fix:
> make end_index = (inode->i_size + PAGE_CACHE_SIZE - 1)>>PAGE_CACHE_SHIFT;
>
> Objections?

Indeed, this should fix another inefficiency in the
readahead code. I'll prepare a patch for filemap.c
soon (also containing ANOTHER small fix to the
readahead code).

> PS: folks, could those who wrote that function comment on the
> readahead rules in general? This stuff looks really ugly
> (presumably from the layers and layers of small modifications)
> and comments on _intentions_ of that code (as opposed to "what
> are we doing in the next two lines") would be very welcome.

While I haven't written it, I'll try to come up with
some documentation when I have the time (yeah right).
Oh well, I'll try to at least comment on everything _I_
try to change in the kernel ;)

regards,

Rik
--
"What you're running that piece of shit Gnome?!?!"
-- Miguel de Icaza, UKUUG 2000

http://www.conectiva.com/ http://www.surriel.com/

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

\
 
 \ /
  Last update: 2005-03-22 12:41    [W:0.025 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site