@@ -511,14 +511,14 @@ 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, unsigned long req_size)
{
- 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 index = rac->_index;
pgoff_t prev_index;
/*
@@ -556,7 +556,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 +589,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 +622,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 +645,8 @@ 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);
+
/* no read-ahead */
if (!ra->ra_pages)
return;
@@ -659,7 +661,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, req_count);
}
EXPORT_SYMBOL_GPL(page_cache_sync_readahead);
@@ -683,7 +685,9 @@ 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);
+
+ /* No Read-ahead */
if (!ra->ra_pages)
return;
@@ -705,7 +709,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, req_count);
}
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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)