linux-fsdevel.vger.kernel.org archive mirror
 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 08/23] ecryptfs: Convert ecryptfs_write_end() to use a folio
Date: Wed, 17 Jul 2024 16:46:58 +0100	[thread overview]
Message-ID: <20240717154716.237943-9-willy@infradead.org> (raw)
In-Reply-To: <20240717154716.237943-1-willy@infradead.org>

Convert the passed page to a folio and operate on that.
Replaces four calls to compound_head() with one.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ecryptfs/mmap.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index e2483acc4366..9b86fad2b9d1 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -234,17 +234,17 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
 /*
  * Called with lower inode mutex held.
  */
-static int fill_zeros_to_end_of_page(struct page *page, unsigned int to)
+static int fill_zeros_to_end_of_page(struct folio *folio, unsigned int to)
 {
-	struct inode *inode = page->mapping->host;
+	struct inode *inode = folio->mapping->host;
 	int end_byte_in_page;
 
-	if ((i_size_read(inode) / PAGE_SIZE) != page->index)
+	if ((i_size_read(inode) / PAGE_SIZE) != folio->index)
 		goto out;
 	end_byte_in_page = i_size_read(inode) % PAGE_SIZE;
 	if (to > end_byte_in_page)
 		end_byte_in_page = to;
-	zero_user_segment(page, end_byte_in_page, PAGE_SIZE);
+	folio_zero_segment(folio, end_byte_in_page, PAGE_SIZE);
 out:
 	return 0;
 }
@@ -465,6 +465,7 @@ static int ecryptfs_write_end(struct file *file,
 			loff_t pos, unsigned len, unsigned copied,
 			struct page *page, void *fsdata)
 {
+	struct folio *folio = page_folio(page);
 	pgoff_t index = pos >> PAGE_SHIFT;
 	unsigned from = pos & (PAGE_SIZE - 1);
 	unsigned to = from + copied;
@@ -476,8 +477,8 @@ static int ecryptfs_write_end(struct file *file,
 	ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
 			"(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
 	if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
-		rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0,
-						       to);
+		rc = ecryptfs_write_lower_page_segment(ecryptfs_inode,
+				&folio->page, 0, to);
 		if (!rc) {
 			rc = copied;
 			fsstack_copy_inode_size(ecryptfs_inode,
@@ -485,21 +486,21 @@ static int ecryptfs_write_end(struct file *file,
 		}
 		goto out;
 	}
-	if (!PageUptodate(page)) {
+	if (!folio_test_uptodate(folio)) {
 		if (copied < PAGE_SIZE) {
 			rc = 0;
 			goto out;
 		}
-		SetPageUptodate(page);
+		folio_mark_uptodate(folio);
 	}
 	/* Fills in zeros if 'to' goes beyond inode size */
-	rc = fill_zeros_to_end_of_page(page, to);
+	rc = fill_zeros_to_end_of_page(folio, to);
 	if (rc) {
 		ecryptfs_printk(KERN_WARNING, "Error attempting to fill "
 			"zeros in page with index = [0x%.16lx]\n", index);
 		goto out;
 	}
-	rc = ecryptfs_encrypt_page(page);
+	rc = ecryptfs_encrypt_page(&folio->page);
 	if (rc) {
 		ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
 				"index [0x%.16lx])\n", index);
@@ -518,8 +519,8 @@ static int ecryptfs_write_end(struct file *file,
 	else
 		rc = copied;
 out:
-	unlock_page(page);
-	put_page(page);
+	folio_unlock(folio);
+	folio_put(folio);
 	return rc;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2024-07-17 15:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 15:46 [PATCH 00/23] Convert write_begin / write_end to take a folio Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 01/23] reiserfs: Convert grab_tail_page() to use " Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 02/23] reiserfs: Convert reiserfs_write_begin() " Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 03/23] block: Use a folio in blkdev_write_end() Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 04/23] buffer: Use a folio in generic_write_end() Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 05/23] nilfs2: Use a folio in nilfs_recover_dsync_blocks() Matthew Wilcox (Oracle)
2024-07-18 17:14   ` Ryusuke Konishi
2024-07-17 15:46 ` [PATCH 06/23] ntfs3: Remove reset_log_file() Matthew Wilcox (Oracle)
2024-07-17 15:46 ` [PATCH 07/23] buffer: Convert block_write_end() to take a folio Matthew Wilcox (Oracle)
2024-07-17 15:46 ` Matthew Wilcox (Oracle) [this message]
2024-07-17 15:46 ` [PATCH 09/23] ecryptfs: Use a folio in ecryptfs_write_begin() Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 10/23] f2fs: Convert f2fs_write_end() to use a folio Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 11/23] f2fs: Convert f2fs_write_begin() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 12/23] fuse: Convert fuse_write_end() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 13/23] fuse: Convert fuse_write_begin() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 14/23] hostfs: Convert hostfs_write_end() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 15/23] jffs2: Convert jffs2_write_end() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 16/23] jffs2: Convert jffs2_write_begin() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 17/23] orangefs: Convert orangefs_write_end() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 18/23] orangefs: Convert orangefs_write_begin() " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 19/23] vboxsf: Use a folio in vboxsf_write_end() Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 20/23] fs: Convert aops->write_end to take a folio Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 21/23] fs: Convert aops->write_begin " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 22/23] ocfs2: Convert ocfs2_write_zero_page to use " Matthew Wilcox (Oracle)
2024-07-17 15:47 ` [PATCH 23/23] buffer: Convert __block_write_begin() to take " Matthew Wilcox (Oracle)
2024-07-18 15:24 ` [PATCH 00/23] Convert write_begin / write_end " Josef Bacik
2024-07-23  7:49 ` Christian Brauner
2024-07-23 13:20   ` Matthew Wilcox
2024-07-23 13:41     ` Christian Brauner
2024-07-23 22:54       ` Matthew Wilcox
2024-07-30 14:23         ` Christian Brauner

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=20240717154716.237943-9-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 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).