@@ -511,14 +511,15 @@ static bool page_cache_readahead_order(struct readahead_control *rac,
/*
* A minimal readahead algorithm for trivial sequential/random reads.
*/
-static void ondemand_readahead(struct address_space *mapping,
- struct file_ra_state *ra, struct file *file,
- struct page *page, pgoff_t index, unsigned long req_size)
+static void ondemand_readahead(struct readahead_control *rac,
+ struct file_ra_state *ra,
+ struct page *page)
{
- DEFINE_READAHEAD(rac, file, mapping, index);
- struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
+ struct backing_dev_info *bdi = inode_to_bdi(rac->mapping->host);
unsigned long max_pages = ra->ra_pages;
unsigned long add_pages;
+ unsigned long req_size = rac->_nr_pages;
+ unsigned long index = rac->_index;
pgoff_t prev_index;
/*
@@ -556,7 +557,7 @@ static void ondemand_readahead(struct address_space *mapping,
pgoff_t start;
rcu_read_lock();
- start = page_cache_next_miss(mapping, index + 1, max_pages);
+ start = page_cache_next_miss(rac->mapping, index + 1, max_pages);
rcu_read_unlock();
if (!start || start - index > max_pages)
@@ -589,14 +590,14 @@ static void ondemand_readahead(struct address_space *mapping,
* Query the page cache and look for the traces(cached history pages)
* that a sequential stream would leave behind.
*/
- if (try_context_readahead(mapping, ra, index, req_size, max_pages))
+ if (try_context_readahead(rac->mapping, ra, index, req_size, max_pages))
goto readit;
/*
* standalone, small random read
* Read as is, and do not pollute the readahead state.
*/
- __do_page_cache_readahead(&rac, req_size, 0);
+ __do_page_cache_readahead(rac, req_size, 0);
return;
initial_readahead:
@@ -622,10 +623,10 @@ static void ondemand_readahead(struct address_space *mapping,
}
}
- rac._index = ra->start;
- if (page && page_cache_readahead_order(&rac, ra, thp_order(page)))
+ rac->_index = ra->start;
+ if (page && page_cache_readahead_order(rac, ra, thp_order(page)))
return;
- __do_page_cache_readahead(&rac, ra->size, ra->async_size);
+ __do_page_cache_readahead(rac, ra->size, ra->async_size);
}
/**
@@ -645,6 +646,9 @@ void page_cache_sync_readahead(struct address_space *mapping,
struct file_ra_state *ra, struct file *filp,
pgoff_t index, unsigned long req_count)
{
+ DEFINE_READAHEAD(rac, filp, mapping, index);
+ rac._nr_pages = req_count;
+
/* no read-ahead */
if (!ra->ra_pages)
return;
@@ -659,7 +663,7 @@ void page_cache_sync_readahead(struct address_space *mapping,
}
/* do read-ahead */
- ondemand_readahead(mapping, ra, filp, NULL, index, req_count);
+ ondemand_readahead(&rac, ra, NULL);
}
EXPORT_SYMBOL_GPL(page_cache_sync_readahead);
@@ -683,7 +687,10 @@ page_cache_async_readahead(struct address_space *mapping,
struct page *page, pgoff_t index,
unsigned long req_count)
{
- /* no read-ahead */
+ DEFINE_READAHEAD(rac, filp, mapping, index);
+ rac._nr_pages = req_count;
+
+ /* No Read-ahead */
if (!ra->ra_pages)
return;
@@ -705,7 +712,7 @@ page_cache_async_readahead(struct address_space *mapping,
return;
/* do read-ahead */
- ondemand_readahead(mapping, ra, filp, page, index, req_count);
+ ondemand_readahead(&rac, ra, page);
}
EXPORT_SYMBOL_GPL(page_cache_async_readahead);
Make ondemand_readahead() take a readahead_control struct in preparation for making do_sync_mmap_readahead() pass down an RAC struct. Signed-off-by: David Howells <dhowells@redhat.com> --- mm/readahead.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)