Commit 8238287e authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

mm/readahead: make do_page_cache_ra take a readahead_control

Rename __do_page_cache_readahead() to do_page_cache_ra() and call it
directly from ondemand_readahead() instead of indirecting via ra_submit().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Eric Biggers <ebiggers@google.com>
Link: https://lkml.kernel.org/r/20200903140844.14194-5-willy@infradead.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 73bb49da
...@@ -51,18 +51,17 @@ void unmap_page_range(struct mmu_gather *tlb, ...@@ -51,18 +51,17 @@ void unmap_page_range(struct mmu_gather *tlb,
void force_page_cache_readahead(struct address_space *, struct file *, void force_page_cache_readahead(struct address_space *, struct file *,
pgoff_t index, unsigned long nr_to_read); pgoff_t index, unsigned long nr_to_read);
void __do_page_cache_readahead(struct address_space *, struct file *, void do_page_cache_ra(struct readahead_control *,
pgoff_t index, unsigned long nr_to_read, unsigned long nr_to_read, unsigned long lookahead_size);
unsigned long lookahead_size);
/* /*
* Submit IO for the read-ahead request in file_ra_state. * Submit IO for the read-ahead request in file_ra_state.
*/ */
static inline void ra_submit(struct file_ra_state *ra, static inline void ra_submit(struct file_ra_state *ra,
struct address_space *mapping, struct file *filp) struct address_space *mapping, struct file *file)
{ {
__do_page_cache_readahead(mapping, filp, DEFINE_READAHEAD(ractl, file, mapping, ra->start);
ra->start, ra->size, ra->async_size); do_page_cache_ra(&ractl, ra->size, ra->async_size);
} }
struct page *find_get_entry(struct address_space *mapping, pgoff_t index); struct page *find_get_entry(struct address_space *mapping, pgoff_t index);
......
...@@ -241,17 +241,16 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, ...@@ -241,17 +241,16 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
EXPORT_SYMBOL_GPL(page_cache_ra_unbounded); EXPORT_SYMBOL_GPL(page_cache_ra_unbounded);
/* /*
* __do_page_cache_readahead() actually reads a chunk of disk. It allocates * do_page_cache_ra() actually reads a chunk of disk. It allocates
* the pages first, then submits them for I/O. This avoids the very bad * the pages first, then submits them for I/O. This avoids the very bad
* behaviour which would occur if page allocations are causing VM writeback. * behaviour which would occur if page allocations are causing VM writeback.
* We really don't want to intermingle reads and writes like that. * We really don't want to intermingle reads and writes like that.
*/ */
void __do_page_cache_readahead(struct address_space *mapping, void do_page_cache_ra(struct readahead_control *ractl,
struct file *file, pgoff_t index, unsigned long nr_to_read, unsigned long nr_to_read, unsigned long lookahead_size)
unsigned long lookahead_size)
{ {
DEFINE_READAHEAD(ractl, file, mapping, index); struct inode *inode = ractl->mapping->host;
struct inode *inode = mapping->host; unsigned long index = readahead_index(ractl);
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(inode);
pgoff_t end_index; /* The last page we want to read */ pgoff_t end_index; /* The last page we want to read */
...@@ -265,7 +264,7 @@ void __do_page_cache_readahead(struct address_space *mapping, ...@@ -265,7 +264,7 @@ void __do_page_cache_readahead(struct address_space *mapping,
if (nr_to_read > end_index - index) if (nr_to_read > end_index - index)
nr_to_read = end_index - index + 1; nr_to_read = end_index - index + 1;
page_cache_ra_unbounded(&ractl, nr_to_read, lookahead_size); page_cache_ra_unbounded(ractl, nr_to_read, lookahead_size);
} }
/* /*
...@@ -273,10 +272,11 @@ void __do_page_cache_readahead(struct address_space *mapping, ...@@ -273,10 +272,11 @@ void __do_page_cache_readahead(struct address_space *mapping,
* memory at once. * memory at once.
*/ */
void force_page_cache_readahead(struct address_space *mapping, void force_page_cache_readahead(struct address_space *mapping,
struct file *filp, pgoff_t index, unsigned long nr_to_read) struct file *file, pgoff_t index, unsigned long nr_to_read)
{ {
DEFINE_READAHEAD(ractl, file, mapping, index);
struct backing_dev_info *bdi = inode_to_bdi(mapping->host); struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
struct file_ra_state *ra = &filp->f_ra; struct file_ra_state *ra = &file->f_ra;
unsigned long max_pages; unsigned long max_pages;
if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages && if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages &&
...@@ -294,7 +294,7 @@ void force_page_cache_readahead(struct address_space *mapping, ...@@ -294,7 +294,7 @@ void force_page_cache_readahead(struct address_space *mapping,
if (this_chunk > nr_to_read) if (this_chunk > nr_to_read)
this_chunk = nr_to_read; this_chunk = nr_to_read;
__do_page_cache_readahead(mapping, filp, index, this_chunk, 0); do_page_cache_ra(&ractl, this_chunk, 0);
index += this_chunk; index += this_chunk;
nr_to_read -= this_chunk; nr_to_read -= this_chunk;
...@@ -432,10 +432,11 @@ static int try_context_readahead(struct address_space *mapping, ...@@ -432,10 +432,11 @@ static int try_context_readahead(struct address_space *mapping,
* A minimal readahead algorithm for trivial sequential/random reads. * A minimal readahead algorithm for trivial sequential/random reads.
*/ */
static void ondemand_readahead(struct address_space *mapping, static void ondemand_readahead(struct address_space *mapping,
struct file_ra_state *ra, struct file *filp, struct file_ra_state *ra, struct file *file,
bool hit_readahead_marker, pgoff_t index, bool hit_readahead_marker, pgoff_t index,
unsigned long req_size) unsigned long req_size)
{ {
DEFINE_READAHEAD(ractl, file, mapping, index);
struct backing_dev_info *bdi = inode_to_bdi(mapping->host); struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
unsigned long max_pages = ra->ra_pages; unsigned long max_pages = ra->ra_pages;
unsigned long add_pages; unsigned long add_pages;
...@@ -516,7 +517,7 @@ static void ondemand_readahead(struct address_space *mapping, ...@@ -516,7 +517,7 @@ static void ondemand_readahead(struct address_space *mapping,
* standalone, small random read * standalone, small random read
* Read as is, and do not pollute the readahead state. * Read as is, and do not pollute the readahead state.
*/ */
__do_page_cache_readahead(mapping, filp, index, req_size, 0); do_page_cache_ra(&ractl, req_size, 0);
return; return;
initial_readahead: initial_readahead:
...@@ -542,7 +543,8 @@ static void ondemand_readahead(struct address_space *mapping, ...@@ -542,7 +543,8 @@ static void ondemand_readahead(struct address_space *mapping,
} }
} }
ra_submit(ra, mapping, filp); ractl._index = ra->start;
do_page_cache_ra(&ractl, ra->size, ra->async_size);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment