public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix readahead breakage for sequential after random reads
@ 2004-07-18 22:30 Miklos Szeredi
  2004-07-26 23:29 ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Miklos Szeredi @ 2004-07-18 22:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Hi Andrew,

Current readahead logic is broken when a random read pattern is
followed by a long sequential read.  The cause is that on a window
miss ra->next_size is set to ra->average, but ra->average is only
updated at the end of a sequence, so window size will remain 1 until
the end of the sequential read.

This patch fixes this by taking the current sequence length into
account (code taken from towards end of page_cache_readahead()), and
also setting ra->average to a decent value in handle_ra_miss() when
sequential access is detected.

Please apply!

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>

==============================================================================
--- linux-2.6.8-rc2/mm/readahead.c.orig	2004-06-16 07:18:57.000000000 +0200
+++ linux-2.6.8-rc2/mm/readahead.c	2004-07-18 23:52:31.000000000 +0200
@@ -470,7 +470,11 @@ do_io:
 			  * pages shall be accessed in the next
 			  * current window.
 			  */
-			ra->next_size = min(ra->average , (unsigned long)max);
+			average = ra->average;
+			if (ra->serial_cnt > average)
+				average = (ra->serial_cnt + ra->average + 1) / 2;
+
+			ra->next_size = min(average , (unsigned long)max);
 		}
 		ra->start = offset;
 		ra->size = ra->next_size;
@@ -552,6 +556,7 @@ void handle_ra_miss(struct address_space
 				ra->size = max;
 				ra->ahead_start = 0;
 				ra->ahead_size = 0;
+				ra->average = max / 2;
 			}
 		}
 		ra->prev_page = offset;




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-08-04 19:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-18 22:30 [PATCH] fix readahead breakage for sequential after random reads Miklos Szeredi
2004-07-26 23:29 ` Andrew Morton
2004-07-26 23:56   ` Ram Pai
2004-07-27  0:08     ` Andrew Morton
2004-07-27  4:18       ` Ram Pai
2004-07-27  7:40         ` Miklos Szeredi
2004-07-27 15:34           ` Ram Pai
2004-08-04 17:38         ` Ram Pai
2004-08-04 19:39           ` Shane Shrybman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox