mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: linux-kernel@vger.kernel.org
Cc: Ram Pai <linuxram@us.ibm.com>,
	Steven Pratt <slpratt@austin.ibm.com>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH 2/4][RESEND] readahead: cleanup get_next_ra_size()
Date: Thu, 24 Feb 2005 22:37:06 +0300	[thread overview]
Message-ID: <421E2CE2.707A0D2A@tv-sign.ru> (raw)

get_next_ra_size() can get all info from file_ra_state.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.11-rc5/mm/readahead.c~	2005-01-26 19:29:49.000000000 +0300
+++ 2.6.11-rc5/mm/readahead.c	2005-01-27 22:14:39.000000000 +0300
@@ -85,14 +85,16 @@ static unsigned long get_init_ra_size(un
  * not for each call to readahead.  If a cache miss occured, reduce next I/O
  * size, else increase depending on how close to max we are.
  */
-static unsigned long get_next_ra_size(unsigned long cur, unsigned long max,
-				unsigned long min, unsigned long * flags)
+static unsigned long get_next_ra_size(struct file_ra_state *ra)
 {
+	unsigned long max = get_max_readahead(ra);
+	unsigned long min = get_min_readahead(ra);
+	unsigned long cur = ra->size;
 	unsigned long newsize;
 
-	if (*flags & RA_FLAG_MISS) {
+	if (ra->flags & RA_FLAG_MISS) {
+		ra->flags &= ~RA_FLAG_MISS;
 		newsize = max((cur - 2), min);
-		*flags &= ~RA_FLAG_MISS;
 	} else if (cur < max / 16) {
 		newsize = 4 * cur;
 	} else {
@@ -413,7 +415,7 @@ page_cache_readahead(struct address_spac
 		     struct file *filp, unsigned long offset,
 		     unsigned long req_size)
 {
-	unsigned long max, min;
+	unsigned long max;
 	unsigned long newsize = req_size;
 	unsigned long block;
 
@@ -427,7 +429,6 @@ page_cache_readahead(struct address_spac
 		goto out;
 
 	max = get_max_readahead(ra);
-	min = get_min_readahead(ra);
 	newsize = min(req_size, max);
 
 	if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) {
@@ -457,8 +458,7 @@ page_cache_readahead(struct address_spac
 		 * immediately.
 		 */
 		if (req_size >= max) {
-			ra->ahead_size = get_next_ra_size(ra->size, max, min,
-							  &ra->flags);
+			ra->ahead_size = get_next_ra_size(ra);
 			ra->ahead_start = ra->start + ra->size;
 			blockable_page_cache_readahead(mapping, filp,
 				 ra->ahead_start, ra->ahead_size, ra, 1);
@@ -484,8 +484,7 @@ page_cache_readahead(struct address_spac
 	 */
 
 	if (ra->ahead_start == 0) {	 /* no ahead window yet */
-		ra->ahead_size = get_next_ra_size(ra->size, max, min,
-						  &ra->flags);
+		ra->ahead_size = get_next_ra_size(ra);
 		ra->ahead_start = ra->start + ra->size;
 		block = ((offset + newsize -1) >= ra->ahead_start);
 		if (!blockable_page_cache_readahead(mapping, filp,
@@ -517,9 +516,8 @@ page_cache_readahead(struct address_spac
 	if ((offset + newsize - 1) >= ra->ahead_start) {
 		ra->start = ra->ahead_start;
 		ra->size = ra->ahead_size;
-		ra->ahead_start = ra->ahead_start + ra->ahead_size;
-		ra->ahead_size = get_next_ra_size(ra->ahead_size,
-						  max, min, &ra->flags);
+		ra->ahead_start = ra->start + ra->size;
+		ra->ahead_size = get_next_ra_size(ra);
 		block = ((offset + newsize - 1) >= ra->ahead_start);
 		if (!blockable_page_cache_readahead(mapping, filp,
 			ra->ahead_start, ra->ahead_size, ra, block)) {

                 reply	other threads:[~2005-02-24 18:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=421E2CE2.707A0D2A@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=slpratt@austin.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®