lkml.org 
[lkml]   [2000]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Re: PATCH: killing read_ahead[]
On Wed, 25 Oct 2000, Linus Torvalds wrote:
> On Wed, 25 Oct 2000, Rik van Riel wrote:
> >
> > OTOH, block-dev readahead makes sense for filesystems where
> > the packing locality is close to the access pattern BUT NOT
> > close to anything the page cache would recognise as being
> > close.
>
> I dunno. The main reason I'd like to get the block devices into
> the page cache is that right now there is no way to mmap them -
> something that can potentially be _very_ useful, regardless of
> readahead.
>
> And quite frankly, the generic file readahead has been pounded
> upon and tested a lot more than the block device read-ahead ever
> was. I bet it performs better if for no other reason.

Indeed.

Anyway, below is a patch that implements Al Viro's
readahead fix and one small readahead adjustment
that seems to make sense ...

regards,

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

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


--- mm/filemap.c.orig Wed Oct 25 14:58:01 2000
+++ mm/filemap.c Wed Oct 25 15:06:23 2000
@@ -794,7 +794,7 @@
struct file * filp, struct inode * inode,
struct page * page)
{
- unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ unsigned long end_index = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
unsigned long index = page->index;
unsigned long max_ahead, ahead;
unsigned long raend;
@@ -943,14 +943,28 @@
}
/*
* Adjust the current value of read-ahead max.
- * If the read operation stay in the first half page, force no readahead.
- * Otherwise try to increase read ahead max just enough to do the read request.
- * Then, at least MIN_READAHEAD if read ahead is ok,
- * and at most MAX_READAHEAD in all cases.
*/
- if (!index && offset + desc->count <= (PAGE_CACHE_SIZE >> 1)) {
- filp->f_ramax = 0;
+ if (!index) {
+ /*
+ * If we start reading from the beginning of the file,
+ * read in MIN_READAHEAD pages. Note that if the file is
+ * smaller than MIN_READAHEAD * 2 limiting ourselves to
+ * MIN_READAHEAD would result in one 'too small' IO, so
+ * in that case we just read in the whole file.
+ */
+ int ramax;
+ if ((inode->i_size >> PAGE_CACHE_SHIFT) > MIN_READAHEAD * 2)
+ ramax = MIN_READAHEAD;
+ else
+ ramax = inode->i_size >> PAGE_CACHE_SHIFT;
+ filp->f_ramax = ramax;
} else {
+ /*
+ * Otherwise, if readahead is ok, we try to increase the
+ * read ahead maximum to be at least big enough for the
+ * current read request. Note that generic_file_readahead()
+ * will tune this value further...
+ */
unsigned long needed;

needed = ((offset + desc->count) >> PAGE_CACHE_SHIFT) + 1;
-
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    [from the cache]
©2003-2011 Jasper Spaans