Commit a8a4cd6f authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

[PATCH] readahead: cleanup get_next_ra_size()

get_next_ra_size() can get all info from file_ra_state.
Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2b359d55
...@@ -85,14 +85,16 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) ...@@ -85,14 +85,16 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
* not for each call to readahead. If a cache miss occured, reduce next I/O * 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. * size, else increase depending on how close to max we are.
*/ */
static unsigned long get_next_ra_size(unsigned long cur, unsigned long max, static unsigned long get_next_ra_size(struct file_ra_state *ra)
unsigned long min, unsigned long * flags)
{ {
unsigned long max = get_max_readahead(ra);
unsigned long min = get_min_readahead(ra);
unsigned long cur = ra->size;
unsigned long newsize; unsigned long newsize;
if (*flags & RA_FLAG_MISS) { if (ra->flags & RA_FLAG_MISS) {
ra->flags &= ~RA_FLAG_MISS;
newsize = max((cur - 2), min); newsize = max((cur - 2), min);
*flags &= ~RA_FLAG_MISS;
} else if (cur < max / 16) { } else if (cur < max / 16) {
newsize = 4 * cur; newsize = 4 * cur;
} else { } else {
...@@ -413,7 +415,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -413,7 +415,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
struct file *filp, unsigned long offset, struct file *filp, unsigned long offset,
unsigned long req_size) unsigned long req_size)
{ {
unsigned long max, min; unsigned long max;
unsigned long newsize = req_size; unsigned long newsize = req_size;
unsigned long block; unsigned long block;
...@@ -427,7 +429,6 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -427,7 +429,6 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
goto out; goto out;
max = get_max_readahead(ra); max = get_max_readahead(ra);
min = get_min_readahead(ra);
newsize = min(req_size, max); newsize = min(req_size, max);
if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) { if (newsize == 0 || (ra->flags & RA_FLAG_INCACHE)) {
...@@ -457,8 +458,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -457,8 +458,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
* immediately. * immediately.
*/ */
if (req_size >= max) { if (req_size >= max) {
ra->ahead_size = get_next_ra_size(ra->size, max, min, ra->ahead_size = get_next_ra_size(ra);
&ra->flags);
ra->ahead_start = ra->start + ra->size; ra->ahead_start = ra->start + ra->size;
blockable_page_cache_readahead(mapping, filp, blockable_page_cache_readahead(mapping, filp,
ra->ahead_start, ra->ahead_size, ra, 1); ra->ahead_start, ra->ahead_size, ra, 1);
...@@ -484,8 +484,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -484,8 +484,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
*/ */
if (ra->ahead_start == 0) { /* no ahead window yet */ if (ra->ahead_start == 0) { /* no ahead window yet */
ra->ahead_size = get_next_ra_size(ra->size, max, min, ra->ahead_size = get_next_ra_size(ra);
&ra->flags);
ra->ahead_start = ra->start + ra->size; ra->ahead_start = ra->start + ra->size;
block = ((offset + newsize -1) >= ra->ahead_start); block = ((offset + newsize -1) >= ra->ahead_start);
if (!blockable_page_cache_readahead(mapping, filp, if (!blockable_page_cache_readahead(mapping, filp,
...@@ -517,9 +516,8 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, ...@@ -517,9 +516,8 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra,
if ((offset + newsize - 1) >= ra->ahead_start) { if ((offset + newsize - 1) >= ra->ahead_start) {
ra->start = ra->ahead_start; ra->start = ra->ahead_start;
ra->size = ra->ahead_size; ra->size = ra->ahead_size;
ra->ahead_start = ra->ahead_start + ra->ahead_size; ra->ahead_start = ra->start + ra->size;
ra->ahead_size = get_next_ra_size(ra->ahead_size, ra->ahead_size = get_next_ra_size(ra);
max, min, &ra->flags);
block = ((offset + newsize - 1) >= ra->ahead_start); block = ((offset + newsize - 1) >= ra->ahead_start);
if (!blockable_page_cache_readahead(mapping, filp, if (!blockable_page_cache_readahead(mapping, filp,
ra->ahead_start, ra->ahead_size, ra, block)) { ra->ahead_start, ra->ahead_size, ra, block)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment