All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: [PATCH 31/69] mm/readahead: Convert page_cache_async_readahead to take a folio
Date: Fri, 29 Apr 2022 18:25:18 +0100	[thread overview]
Message-ID: <20220429172556.3011843-32-willy@infradead.org> (raw)
In-Reply-To: <20220429172556.3011843-1-willy@infradead.org>

Removes a couple of calls to compound_head and saves a few bytes.
Also convert verity's read_file_data_page() to be folio-based.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/btrfs/relocation.c   |  5 +++--
 fs/btrfs/send.c         |  3 ++-
 fs/verity/enable.c      | 29 ++++++++++++++---------------
 include/linux/pagemap.h |  6 +++---
 4 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index fdc2c4b411f0..9ae06895ffc9 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2967,8 +2967,9 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
 		goto release_page;
 
 	if (PageReadahead(page))
-		page_cache_async_readahead(inode->i_mapping, ra, NULL, page,
-				   page_index, last_index + 1 - page_index);
+		page_cache_async_readahead(inode->i_mapping, ra, NULL,
+				page_folio(page), page_index,
+				last_index + 1 - page_index);
 
 	if (!PageUptodate(page)) {
 		btrfs_readpage(NULL, page);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 7d1642937274..b327dbe0cbf5 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4986,7 +4986,8 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
 
 		if (PageReadahead(page)) {
 			page_cache_async_readahead(inode->i_mapping, &sctx->ra,
-				NULL, page, index, last_index + 1 - index);
+						NULL, page_folio(page), index,
+						last_index + 1 - index);
 		}
 
 		if (!PageUptodate(page)) {
diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index 60a4372aa4d7..f75d2c010f36 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -18,27 +18,26 @@
  * Read a file data page for Merkle tree construction.  Do aggressive readahead,
  * since we're sequentially reading the entire file.
  */
-static struct page *read_file_data_page(struct file *filp, pgoff_t index,
+static struct page *read_file_data_page(struct file *file, pgoff_t index,
 					struct file_ra_state *ra,
 					unsigned long remaining_pages)
 {
-	struct page *page;
+	DEFINE_READAHEAD(ractl, file, ra, file->f_mapping, index);
+	struct folio *folio;
 
-	page = find_get_page_flags(filp->f_mapping, index, FGP_ACCESSED);
-	if (!page || !PageUptodate(page)) {
-		if (page)
-			put_page(page);
+	folio = __filemap_get_folio(ractl.mapping, index, FGP_ACCESSED, 0);
+	if (!folio || !folio_test_uptodate(folio)) {
+		if (folio)
+			folio_put(folio);
 		else
-			page_cache_sync_readahead(filp->f_mapping, ra, filp,
-						  index, remaining_pages);
-		page = read_mapping_page(filp->f_mapping, index, NULL);
-		if (IS_ERR(page))
-			return page;
+			page_cache_sync_ra(&ractl, remaining_pages);
+		folio = read_cache_folio(ractl.mapping, index, NULL, file);
+		if (IS_ERR(folio))
+			return &folio->page;
 	}
-	if (PageReadahead(page))
-		page_cache_async_readahead(filp->f_mapping, ra, filp, page,
-					   index, remaining_pages);
-	return page;
+	if (folio_test_readahead(folio))
+		page_cache_async_ra(&ractl, folio, remaining_pages);
+	return folio_file_page(folio, index);
 }
 
 static int build_merkle_tree_level(struct file *filp, unsigned int level,
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 60657132080f..b70192f56454 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -1242,7 +1242,7 @@ void page_cache_sync_readahead(struct address_space *mapping,
  * @mapping: address_space which holds the pagecache and I/O vectors
  * @ra: file_ra_state which holds the readahead state
  * @file: Used by the filesystem for authentication.
- * @page: The page at @index which triggered the readahead call.
+ * @folio: The folio at @index which triggered the readahead call.
  * @index: Index of first page to be read.
  * @req_count: Total number of pages being read by the caller.
  *
@@ -1254,10 +1254,10 @@ void page_cache_sync_readahead(struct address_space *mapping,
 static inline
 void page_cache_async_readahead(struct address_space *mapping,
 		struct file_ra_state *ra, struct file *file,
-		struct page *page, pgoff_t index, unsigned long req_count)
+		struct folio *folio, pgoff_t index, unsigned long req_count)
 {
 	DEFINE_READAHEAD(ractl, file, ra, mapping, index);
-	page_cache_async_ra(&ractl, page_folio(page), req_count);
+	page_cache_async_ra(&ractl, folio, req_count);
 }
 
 static inline struct folio *__readahead_folio(struct readahead_control *ractl)
-- 
2.34.1


  parent reply	other threads:[~2022-04-29 17:26 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-29 17:24 [PATCH 00/69] Filesystem/page cache patches for 5.19 Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 01/69] scsicam: Fix use of page cache Matthew Wilcox (Oracle)
2022-05-03 14:35   ` Christoph Hellwig
2022-05-03 21:12     ` Matthew Wilcox
2022-04-29 17:24 ` [PATCH 02/69] ext4: Use page_symlink() instead of __page_symlink() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 03/69] namei: Merge page_symlink() and __page_symlink() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 04/69] namei: Convert page_symlink() to use memalloc_nofs_save() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 05/69] f2fs: Convert f2fs_grab_cache_page() to use scoped memory APIs Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 06/69] ext4: Allow GFP_FS allocations in ext4_da_convert_inline_data_to_extent() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 07/69] ext4: Use scoped memory API in mext_page_double_lock() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 08/69] ext4: Use scoped memory APIs in ext4_da_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 09/69] ext4: Use scoped memory APIs in ext4_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 10/69] fs: Remove AOP_FLAG_NOFS Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 11/69] fs: Remove aop_flags parameter from netfs_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:24 ` [PATCH 12/69] fs: Remove aop flags parameter from block_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 13/69] fs: Remove aop flags parameter from cont_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 14/69] fs: Remove aop flags parameter from grab_cache_page_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 15/69] fs: Remove aop flags parameter from nobh_write_begin() Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 16/69] fs: Remove flags parameter from aops->write_begin Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 17/69] buffer: Call aops write_begin() and write_end() directly Matthew Wilcox (Oracle)
2022-05-03 14:36   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 18/69] namei: " Matthew Wilcox (Oracle)
2022-05-03 14:36   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 19/69] ntfs3: Call ntfs_write_begin() and ntfs_write_end() directly Matthew Wilcox (Oracle)
2022-05-03  6:15   ` Namjae Jeon
2022-05-03 14:36   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 20/69] hfs: Call hfs_write_begin() and generic_write_end() directly Matthew Wilcox (Oracle)
2022-05-03 14:37   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 21/69] hfsplus: Call hfsplus_write_begin() " Matthew Wilcox (Oracle)
2022-05-03 14:37   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 22/69] ext4: Call aops write_begin() and write_end() directly Matthew Wilcox (Oracle)
2022-05-03 14:37   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 23/69] f2fs: " Matthew Wilcox (Oracle)
2022-05-03 14:37   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 24/69] i915: " Matthew Wilcox (Oracle)
2022-05-03 14:38   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 25/69] fs: Remove pagecache_write_begin() and pagecache_write_end() Matthew Wilcox (Oracle)
2022-05-03 14:38   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 26/69] filemap: Remove obsolete comment in lock_page Matthew Wilcox (Oracle)
2022-05-03 14:38   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 27/69] filemap: Update the folio_lock documentation Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 28/69] filemap: Update the folio_mark_dirty documentation Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 29/69] readahead: Use a folio in read_pages() Matthew Wilcox (Oracle)
2022-05-03 14:38   ` Christoph Hellwig
2022-04-29 17:25 ` [PATCH 30/69] fs: Convert is_dirty_writeback() to take a folio Matthew Wilcox (Oracle)
2022-05-03 14:39   ` Christoph Hellwig
2022-04-29 17:25 ` Matthew Wilcox (Oracle) [this message]
2022-05-03 14:39   ` [PATCH 31/69] mm/readahead: Convert page_cache_async_readahead " Christoph Hellwig
2022-04-29 17:25 ` [PATCH 32/69] buffer: Rewrite nobh_truncate_page() to use folios Matthew Wilcox (Oracle)
2022-05-03 14:41   ` Christoph Hellwig
2022-05-08 18:37     ` Matthew Wilcox
2022-04-29 17:25 ` [PATCH 33/69] fs: Introduce aops->read_folio Matthew Wilcox (Oracle)
2022-05-03 14:42   ` Christoph Hellwig
2022-05-06 20:22   ` Kees Cook
2022-04-29 17:25 ` [PATCH 34/69] fs: read_folio documentation Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 35/69] fs: Convert netfs_readpage to netfs_read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 36/69] fs: Convert iomap_readpage to iomap_read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 37/69] fs: Convert block_read_full_page() to block_read_full_folio() Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 38/69] fs: Convert mpage_readpage to mpage_read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 39/69] fs: Convert simple_readpage to simple_read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 40/69] affs: Convert affs to read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 41/69] afs: Convert afs_symlink_readpage to afs_symlink_read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 42/69] befs: Convert befs to read_folio Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 43/69] btrfs: Convert btrfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 44/69] cifs: Convert cifs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 45/69] coda: Convert coda " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 46/69] cramfs: Convert cramfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 47/69] ecryptfs: Convert ecryptfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 48/69] efs: Convert efs symlinks " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 49/69] erofs: Convert erofs zdata " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 50/69] ext4: Convert ext4 " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 51/69] f2fs: Convert f2fs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 52/69] freevxfs: Convert vxfs_immed " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 53/69] fuse: Convert fuse " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 54/69] hostfs: Convert hostfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 55/69] hpfs: Convert symlinks " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 56/69] isofs: Convert symlinks and zisofs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 57/69] jffs2: Convert jffs2 " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 58/69] jfs: Convert metadata pages " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 59/69] nfs: Convert nfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 60/69] ntfs: Convert ntfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 61/69] ocfs2: Convert ocfs2 " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 62/69] orangefs: Convert orangefs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 63/69] romfs: Convert romfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 64/69] squashfs: Convert squashfs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 65/69] ubifs: Convert ubifs " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 66/69] udf: Convert adinicb and symlinks " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 67/69] vboxsf: Convert vboxsf " Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 68/69] mm: Convert swap_readpage to call read_folio instead of readpage Matthew Wilcox (Oracle)
2022-04-29 17:25 ` [PATCH 69/69] mm,fs: Remove stray references to ->readpage 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=20220429172556.3011843-32-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.