Skip to content

Commit

Permalink
mm: remove 'page_offset' from readahead loop
Browse files Browse the repository at this point in the history
Replace the page_offset variable with 'index + i'.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: John Hubbard <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: William Kucharski <[email protected]>
Cc: Chao Yu <[email protected]>
Cc: Cong Wang <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: Eric Biggers <[email protected]>
Cc: Gao Xiang <[email protected]>
Cc: Jaegeuk Kim <[email protected]>
Cc: Joseph Qi <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Zi Yan <[email protected]>
Cc: Johannes Thumshirn <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and torvalds committed Jun 2, 2020
1 parent c2c7ad7 commit ef8153b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,10 @@ void __do_page_cache_readahead(struct address_space *mapping,
* Preallocate as many pages as we will need.
*/
for (i = 0; i < nr_to_read; i++) {
pgoff_t page_offset = index + i;

if (page_offset > end_index)
if (index + i > end_index)
break;

page = xa_load(&mapping->i_pages, page_offset);
page = xa_load(&mapping->i_pages, index + i);
if (page && !xa_is_value(page)) {
/*
* Page already present? Kick off the current batch of
Expand All @@ -199,7 +197,7 @@ void __do_page_cache_readahead(struct address_space *mapping,
page = __page_cache_alloc(gfp_mask);
if (!page)
break;
page->index = page_offset;
page->index = index + i;
list_add(&page->lru, &page_pool);
if (i == nr_to_read - lookahead_size)
SetPageReadahead(page);
Expand Down

0 comments on commit ef8153b

Please sign in to comment.