[lkml]   [2000]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[potential bug] generic_file_readahead()

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)
if (page_cache_read(filp, raend + ahead) < 0)

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
make end_index = (inode->i_size + PAGE_CACHE_SIZE - 1)>>PAGE_CACHE_SHIFT;


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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

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