lkml.org 
[lkml]   [2000]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
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)
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?

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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

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