Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
David Howells <dhowells@redhat.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Eric Biggers <ebiggers@google.com>
Subject: [PATCH 4/9] mm/readahead: Make do_page_cache_ra take a readahead_control
Date: Thu, 3 Sep 2020 15:08:39 +0100 [thread overview]
Message-ID: <20200903140844.14194-5-willy@infradead.org> (raw)
In-Reply-To: <20200903140844.14194-1-willy@infradead.org>
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: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/internal.h | 11 +++++------
mm/readahead.c | 28 +++++++++++++++-------------
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h
index 10c677655912..6aef85f62b9d 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -51,18 +51,17 @@ void unmap_page_range(struct mmu_gather *tlb,
void force_page_cache_readahead(struct address_space *, struct file *,
pgoff_t index, unsigned long nr_to_read);
-void __do_page_cache_readahead(struct address_space *, struct file *,
- pgoff_t index, unsigned long nr_to_read,
- unsigned long lookahead_size);
+void do_page_cache_ra(struct readahead_control *,
+ unsigned long nr_to_read, unsigned long lookahead_size);
/*
* Submit IO for the read-ahead request in file_ra_state.
*/
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,
- ra->start, ra->size, ra->async_size);
+ DEFINE_READAHEAD(ractl, file, mapping, ra->start);
+ do_page_cache_ra(&ractl, ra->size, ra->async_size);
}
/**
diff --git a/mm/readahead.c b/mm/readahead.c
index a444943781bb..577f180d9252 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -241,17 +241,16 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
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
* behaviour which would occur if page allocations are causing VM writeback.
* We really don't want to intermingle reads and writes like that.
*/
-void __do_page_cache_readahead(struct address_space *mapping,
- struct file *file, pgoff_t index, unsigned long nr_to_read,
- unsigned long lookahead_size)
+void do_page_cache_ra(struct readahead_control *ractl,
+ unsigned long nr_to_read, unsigned long lookahead_size)
{
- DEFINE_READAHEAD(ractl, file, mapping, index);
- struct inode *inode = mapping->host;
+ struct inode *inode = ractl->mapping->host;
+ unsigned long index = readahead_index(ractl);
loff_t isize = i_size_read(inode);
pgoff_t end_index; /* The last page we want to read */
@@ -265,7 +264,7 @@ void __do_page_cache_readahead(struct address_space *mapping,
if (nr_to_read > end_index - index)
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,
* memory at once.
*/
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 file_ra_state *ra = &filp->f_ra;
+ struct file_ra_state *ra = &file->f_ra;
unsigned long max_pages;
if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages &&
@@ -294,7 +294,7 @@ void force_page_cache_readahead(struct address_space *mapping,
if (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;
nr_to_read -= this_chunk;
@@ -432,10 +432,11 @@ static int try_context_readahead(struct address_space *mapping,
* A minimal readahead algorithm for trivial sequential/random reads.
*/
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,
unsigned long req_size)
{
+ DEFINE_READAHEAD(ractl, file, mapping, index);
struct backing_dev_info *bdi = inode_to_bdi(mapping->host);
unsigned long max_pages = ra->ra_pages;
unsigned long add_pages;
@@ -516,7 +517,7 @@ static void ondemand_readahead(struct address_space *mapping,
* standalone, small random read
* 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;
initial_readahead:
@@ -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);
}
/**
--
2.28.0
next prev parent reply other threads:[~2020-09-03 14:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 14:08 [PATCH 0/9] Readahead patches for 5.9/5.10 Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 1/9] Fix khugepaged's request size in collapse_file Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 2/9] mm/readahead: Add DEFINE_READAHEAD Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 3/9] mm/readahead: Make page_cache_ra_unbounded take a readahead_control Matthew Wilcox (Oracle)
2020-09-03 19:22 ` Andrew Morton
2020-09-03 19:33 ` Matthew Wilcox
2020-09-03 14:08 ` Matthew Wilcox (Oracle) [this message]
2020-09-03 14:08 ` [PATCH 5/9] mm/readahead: Make ondemand_readahead " Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 6/9] mm/readahead: Pass readahead_control to force_page_cache_ra Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 7/9] mm/readahead: Add page_cache_sync_ra and page_cache_async_ra Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 8/9] mm/filemap: Fold ra_submit into do_sync_mmap_readahead Matthew Wilcox (Oracle)
2020-09-03 14:08 ` [PATCH 9/9] mm/readahead: Pass a file_ra_state into force_page_cache_ra Matthew Wilcox (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200903140844.14194-5-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=ebiggers@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--subject='Re: [PATCH 4/9] mm/readahead: Make do_page_cache_ra take a readahead_control' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).