linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: willy@infradead.org
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/6] mm: Make ondemand_readahead() take a readahead_control struct [ver #2]
Date: Wed, 02 Sep 2020 16:44:31 +0100	[thread overview]
Message-ID: <159906147106.663183.11426662588034129469.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <159906145700.663183.3678164182141075453.stgit@warthog.procyon.org.uk>

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(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index 91859e6e2b7d..e3e3419dfe3d 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -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);
 



  parent reply	other threads:[~2020-09-02 15:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 15:44 [RFC PATCH 0/6] mm: Make more use of readahead_control [ver #2] David Howells
2020-09-02 15:44 ` [RFC PATCH 1/6] Fix khugepaged's request size in collapse_file() " David Howells
2020-09-02 15:44 ` David Howells [this message]
2020-09-02 15:44 ` [RFC PATCH 3/6] mm: Push readahead_control down into force_page_cache_readahead() " David Howells
2020-09-02 15:54   ` Matthew Wilcox
2020-09-02 15:44 ` [RFC PATCH 4/6] mm: Pass readahead_control into page_cache_{sync,async}_readahead() " David Howells
2020-09-02 15:44 ` [RFC PATCH 5/6] mm: Fold ra_submit() into do_sync_mmap_readahead() " David Howells
2020-09-02 15:45 ` [RFC PATCH 6/6] mm: Pass a file_ra_state struct into force_page_cache_readahead() " David Howells

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=159906147106.663183.11426662588034129469.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).