mm/readahead.c: simplify get_next_ra_size()

It's a trivial simplification for get_next_ra_size() and clear enough for
humans to understand.

It also fixes potential overflow if ra->size(< ra_pages) is too large.

Link: http://lkml.kernel.org/r/1540707206-19649-1-git-send-email-hsiangkao@aol.com
Signed-off-by: Gao Xiang <hsiangkao@aol.com>
Reviewed-by: Fengguang Wu <fengguang.wu@intel.com>
Reviewed-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Gao Xiang 2018-12-28 00:33:34 -08:00 committed by Linus Torvalds
parent 368686a95e
commit 20ff1c9505

View File

@ -273,14 +273,12 @@ static unsigned long get_next_ra_size(struct file_ra_state *ra,
unsigned long max) unsigned long max)
{ {
unsigned long cur = ra->size; unsigned long cur = ra->size;
unsigned long newsize;
if (cur < max / 16) if (cur < max / 16)
newsize = 4 * cur; return 4 * cur;
else if (cur <= max / 2)
newsize = 2 * cur; return 2 * cur;
return max;
return min(newsize, max);
} }
/* /*