mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
mm/readahead: make page_cache_ra_unbounded take a readahead_control
Define it in the callers instead of in page_cache_ra_unbounded(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew 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-4-willy@infradead.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1aa83cfa5a
commit
73bb49da50
4 changed files with 20 additions and 23 deletions
|
@ -349,6 +349,7 @@ static struct page *ext4_read_merkle_tree_page(struct inode *inode,
|
||||||
pgoff_t index,
|
pgoff_t index,
|
||||||
unsigned long num_ra_pages)
|
unsigned long num_ra_pages)
|
||||||
{
|
{
|
||||||
|
DEFINE_READAHEAD(ractl, NULL, inode->i_mapping, index);
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
|
||||||
index += ext4_verity_metadata_pos(inode) >> PAGE_SHIFT;
|
index += ext4_verity_metadata_pos(inode) >> PAGE_SHIFT;
|
||||||
|
@ -358,8 +359,7 @@ static struct page *ext4_read_merkle_tree_page(struct inode *inode,
|
||||||
if (page)
|
if (page)
|
||||||
put_page(page);
|
put_page(page);
|
||||||
else if (num_ra_pages > 1)
|
else if (num_ra_pages > 1)
|
||||||
page_cache_readahead_unbounded(inode->i_mapping, NULL,
|
page_cache_ra_unbounded(&ractl, num_ra_pages, 0);
|
||||||
index, num_ra_pages, 0);
|
|
||||||
page = read_mapping_page(inode->i_mapping, index, NULL);
|
page = read_mapping_page(inode->i_mapping, index, NULL);
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
|
|
|
@ -228,6 +228,7 @@ static struct page *f2fs_read_merkle_tree_page(struct inode *inode,
|
||||||
pgoff_t index,
|
pgoff_t index,
|
||||||
unsigned long num_ra_pages)
|
unsigned long num_ra_pages)
|
||||||
{
|
{
|
||||||
|
DEFINE_READAHEAD(ractl, NULL, inode->i_mapping, index);
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
|
||||||
index += f2fs_verity_metadata_pos(inode) >> PAGE_SHIFT;
|
index += f2fs_verity_metadata_pos(inode) >> PAGE_SHIFT;
|
||||||
|
@ -237,8 +238,7 @@ static struct page *f2fs_read_merkle_tree_page(struct inode *inode,
|
||||||
if (page)
|
if (page)
|
||||||
put_page(page);
|
put_page(page);
|
||||||
else if (num_ra_pages > 1)
|
else if (num_ra_pages > 1)
|
||||||
page_cache_readahead_unbounded(inode->i_mapping, NULL,
|
page_cache_ra_unbounded(&ractl, num_ra_pages, 0);
|
||||||
index, num_ra_pages, 0);
|
|
||||||
page = read_mapping_page(inode->i_mapping, index, NULL);
|
page = read_mapping_page(inode->i_mapping, index, NULL);
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
|
|
|
@ -768,9 +768,8 @@ void page_cache_sync_readahead(struct address_space *, struct file_ra_state *,
|
||||||
void page_cache_async_readahead(struct address_space *, struct file_ra_state *,
|
void page_cache_async_readahead(struct address_space *, struct file_ra_state *,
|
||||||
struct file *, struct page *, pgoff_t index,
|
struct file *, struct page *, pgoff_t index,
|
||||||
unsigned long req_count);
|
unsigned long req_count);
|
||||||
void page_cache_readahead_unbounded(struct address_space *, struct file *,
|
void page_cache_ra_unbounded(struct readahead_control *,
|
||||||
pgoff_t index, unsigned long nr_to_read,
|
unsigned long nr_to_read, unsigned long lookahead_count);
|
||||||
unsigned long lookahead_count);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Like add_to_page_cache_locked, but used to add newly allocated pages:
|
* Like add_to_page_cache_locked, but used to add newly allocated pages:
|
||||||
|
|
|
@ -158,10 +158,8 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* page_cache_readahead_unbounded - Start unchecked readahead.
|
* page_cache_ra_unbounded - Start unchecked readahead.
|
||||||
* @mapping: File address space.
|
* @ractl: Readahead control.
|
||||||
* @file: This instance of the open file; used for authentication.
|
|
||||||
* @index: First page index to read.
|
|
||||||
* @nr_to_read: The number of pages to read.
|
* @nr_to_read: The number of pages to read.
|
||||||
* @lookahead_size: Where to start the next readahead.
|
* @lookahead_size: Where to start the next readahead.
|
||||||
*
|
*
|
||||||
|
@ -173,13 +171,13 @@ out:
|
||||||
* Context: File is referenced by caller. Mutexes may be held by caller.
|
* Context: File is referenced by caller. Mutexes may be held by caller.
|
||||||
* May sleep, but will not reenter filesystem to reclaim memory.
|
* May sleep, but will not reenter filesystem to reclaim memory.
|
||||||
*/
|
*/
|
||||||
void page_cache_readahead_unbounded(struct address_space *mapping,
|
void page_cache_ra_unbounded(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)
|
|
||||||
{
|
{
|
||||||
|
struct address_space *mapping = ractl->mapping;
|
||||||
|
unsigned long index = readahead_index(ractl);
|
||||||
LIST_HEAD(page_pool);
|
LIST_HEAD(page_pool);
|
||||||
gfp_t gfp_mask = readahead_gfp_mask(mapping);
|
gfp_t gfp_mask = readahead_gfp_mask(mapping);
|
||||||
DEFINE_READAHEAD(rac, file, mapping, index);
|
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -200,7 +198,7 @@ void page_cache_readahead_unbounded(struct address_space *mapping,
|
||||||
for (i = 0; i < nr_to_read; i++) {
|
for (i = 0; i < nr_to_read; i++) {
|
||||||
struct page *page = xa_load(&mapping->i_pages, index + i);
|
struct page *page = xa_load(&mapping->i_pages, index + i);
|
||||||
|
|
||||||
BUG_ON(index + i != rac._index + rac._nr_pages);
|
BUG_ON(index + i != ractl->_index + ractl->_nr_pages);
|
||||||
|
|
||||||
if (page && !xa_is_value(page)) {
|
if (page && !xa_is_value(page)) {
|
||||||
/*
|
/*
|
||||||
|
@ -211,7 +209,7 @@ void page_cache_readahead_unbounded(struct address_space *mapping,
|
||||||
* have a stable reference to this page, and it's
|
* have a stable reference to this page, and it's
|
||||||
* not worth getting one just for that.
|
* not worth getting one just for that.
|
||||||
*/
|
*/
|
||||||
read_pages(&rac, &page_pool, true);
|
read_pages(ractl, &page_pool, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,12 +222,12 @@ void page_cache_readahead_unbounded(struct address_space *mapping,
|
||||||
} else if (add_to_page_cache_lru(page, mapping, index + i,
|
} else if (add_to_page_cache_lru(page, mapping, index + i,
|
||||||
gfp_mask) < 0) {
|
gfp_mask) < 0) {
|
||||||
put_page(page);
|
put_page(page);
|
||||||
read_pages(&rac, &page_pool, true);
|
read_pages(ractl, &page_pool, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i == nr_to_read - lookahead_size)
|
if (i == nr_to_read - lookahead_size)
|
||||||
SetPageReadahead(page);
|
SetPageReadahead(page);
|
||||||
rac._nr_pages++;
|
ractl->_nr_pages++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -237,10 +235,10 @@ void page_cache_readahead_unbounded(struct address_space *mapping,
|
||||||
* uptodate then the caller will launch readpage again, and
|
* uptodate then the caller will launch readpage again, and
|
||||||
* will then handle the error.
|
* will then handle the error.
|
||||||
*/
|
*/
|
||||||
read_pages(&rac, &page_pool, false);
|
read_pages(ractl, &page_pool, false);
|
||||||
memalloc_nofs_restore(nofs);
|
memalloc_nofs_restore(nofs);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(page_cache_readahead_unbounded);
|
EXPORT_SYMBOL_GPL(page_cache_ra_unbounded);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* __do_page_cache_readahead() actually reads a chunk of disk. It allocates
|
* __do_page_cache_readahead() actually reads a chunk of disk. It allocates
|
||||||
|
@ -252,6 +250,7 @@ void __do_page_cache_readahead(struct address_space *mapping,
|
||||||
struct file *file, pgoff_t index, unsigned long nr_to_read,
|
struct file *file, pgoff_t index, unsigned long nr_to_read,
|
||||||
unsigned long lookahead_size)
|
unsigned long lookahead_size)
|
||||||
{
|
{
|
||||||
|
DEFINE_READAHEAD(ractl, file, mapping, index);
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
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 */
|
||||||
|
@ -266,8 +265,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_readahead_unbounded(mapping, file, index, nr_to_read,
|
page_cache_ra_unbounded(&ractl, nr_to_read, lookahead_size);
|
||||||
lookahead_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue