Skip to content

Commit

Permalink
readahead: drop pointless index from force_page_cache_ra()
Browse files Browse the repository at this point in the history
Current index to readahead is tracked in readahead_control and properly
updated by page_cache_ra_unbounded() (read_pages() in fact).  So there's
no need to track the index separately in force_page_cache_ra().

Link: https://lkml.kernel.org/r/20240625101909.12234-4-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Tested-by: Zhang Peng <zhangpengpeng0808@gmail.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
jankara authored and akpm00 committed Jul 4, 2024
1 parent 7c87758 commit 878343d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void force_page_cache_ra(struct readahead_control *ractl,
struct address_space *mapping = ractl->mapping;
struct file_ra_state *ra = ractl->ra;
struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
unsigned long max_pages, index;
unsigned long max_pages;

if (unlikely(!mapping->a_ops->read_folio && !mapping->a_ops->readahead))
return;
Expand All @@ -322,18 +322,15 @@ void force_page_cache_ra(struct readahead_control *ractl,
* If the request exceeds the readahead window, allow the read to
* be up to the optimal hardware IO size
*/
index = readahead_index(ractl);
max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages);
nr_to_read = min_t(unsigned long, nr_to_read, max_pages);
while (nr_to_read) {
unsigned long this_chunk = (2 * 1024 * 1024) / PAGE_SIZE;

if (this_chunk > nr_to_read)
this_chunk = nr_to_read;
ractl->_index = index;
do_page_cache_ra(ractl, this_chunk, 0);

index += this_chunk;
nr_to_read -= this_chunk;
}
}
Expand Down

0 comments on commit 878343d

Please sign in to comment.