All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 11/11] ntfs3: Convert ni_readpage_cmpr() to take a folio
Date: Mon, 22 Apr 2024 20:32:01 +0100	[thread overview]
Message-ID: <20240422193203.3534108-12-willy@infradead.org> (raw)
In-Reply-To: <20240422193203.3534108-1-willy@infradead.org>

We still use an array of pages for the decompression, but this removes
a few calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/frecord.c | 13 +++++++------
 fs/ntfs3/inode.c   |  2 +-
 fs/ntfs3/ntfs_fs.h |  2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index b9b3f1bf1bc4..8b1139fd5359 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -2085,12 +2085,12 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
  * When decompressing, we typically obtain more than one page per reference.
  * We inject the additional pages into the page cache.
  */
-int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)
+int ni_readpage_cmpr(struct ntfs_inode *ni, struct folio *folio)
 {
 	int err;
 	struct ntfs_sb_info *sbi = ni->mi.sbi;
-	struct address_space *mapping = page->mapping;
-	pgoff_t index = page->index;
+	struct address_space *mapping = folio->mapping;
+	pgoff_t index = folio->index;
 	u64 frame_vbo, vbo = (u64)index << PAGE_SHIFT;
 	struct page **pages = NULL; /* Array of at most 16 pages. stack? */
 	u8 frame_bits;
@@ -2100,7 +2100,8 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)
 	struct page *pg;
 
 	if (vbo >= i_size_read(&ni->vfs_inode)) {
-		SetPageUptodate(page);
+		folio_zero_range(folio, 0, folio_size(folio));
+		folio_mark_uptodate(folio);
 		err = 0;
 		goto out;
 	}
@@ -2124,7 +2125,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)
 		goto out;
 	}
 
-	pages[idx] = page;
+	pages[idx] = &folio->page;
 	index = frame_vbo >> PAGE_SHIFT;
 	gfp_mask = mapping_gfp_mask(mapping);
 
@@ -2154,7 +2155,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)
 out:
 	/* At this point, err contains 0 or -EIO depending on the "critical" page. */
 	kfree(pages);
-	unlock_page(page);
+	folio_unlock(folio);
 
 	return err;
 }
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 4791a002500b..ef32be41b860 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -727,7 +727,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
 
 	if (is_compressed(ni)) {
 		ni_lock(ni);
-		err = ni_readpage_cmpr(ni, &folio->page);
+		err = ni_readpage_cmpr(ni, folio);
 		ni_unlock(ni);
 		return err;
 	}
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index fbd14776bd28..3b50c4357a46 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -577,7 +577,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint);
 #define _ni_write_inode(i, w) ni_write_inode(i, w, __func__)
 int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,
 	      __u64 vbo, __u64 len);
-int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page);
+int ni_readpage_cmpr(struct ntfs_inode *ni, struct folio *folio);
 int ni_decompress_file(struct ntfs_inode *ni);
 int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,
 		  u32 pages_per_frame);
-- 
2.43.0


  parent reply	other threads:[~2024-04-22 19:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 19:31 [PATCH v2 00/11] Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 01/11] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 02/11] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 03/11] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 04/11] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 05/11] ntfs3: Convert attr_data_write_resident to use " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 06/11] ntfs3: Convert attr_make_nonresident " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 07/11] ntfs3: Convert inode_read_data() to use folios Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 08/11] ntfs3: Remove calls to set/clear the error flag Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 09/11] ntfs3: Convert attr_wof_frame_info() to use a folio Matthew Wilcox (Oracle)
2024-04-22 19:32 ` [PATCH v2 10/11] ntfs3: Convert ntfs_get_frame_pages() " Matthew Wilcox (Oracle)
2024-04-22 19:32 ` Matthew Wilcox (Oracle) [this message]
2024-04-23 14:51 ` [PATCH v2 00/11] Convert (most of) ntfs3 to use folios Konstantin Komarov

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=20240422193203.3534108-12-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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.