Skip to content

Commit 20ff1c9

Browse files
hsiangkaotorvalds
authored andcommitted
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>
1 parent 368686a commit 20ff1c9

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mm/readahead.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,15 @@ static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
270270
* return it as the new window size.
271271
*/
272272
static unsigned long get_next_ra_size(struct file_ra_state *ra,
273-
unsigned long max)
273+
unsigned long max)
274274
{
275275
unsigned long cur = ra->size;
276-
unsigned long newsize;
277276

278277
if (cur < max / 16)
279-
newsize = 4 * cur;
280-
else
281-
newsize = 2 * cur;
282-
283-
return min(newsize, max);
278+
return 4 * cur;
279+
if (cur <= max / 2)
280+
return 2 * cur;
281+
return max;
284282
}
285283

286284
/*

0 commit comments

Comments
 (0)