From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Tyler Hicks <code@tyhicks.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
ecryptfs@vger.kernel.org, Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 08/10] ecryptfs: Convert ecryptfs_decrypt_page() to take a folio
Date: Fri, 25 Oct 2024 20:08:18 +0100 [thread overview]
Message-ID: <20241025190822.1319162-9-willy@infradead.org> (raw)
In-Reply-To: <20241025190822.1319162-1-willy@infradead.org>
Both callers have a folio, so pass it in and use it throughout.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ecryptfs/crypto.c | 11 ++++++-----
fs/ecryptfs/ecryptfs_kernel.h | 2 +-
fs/ecryptfs/mmap.c | 4 ++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 995ae3a97d52..90d38da20f5c 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -461,7 +461,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
/**
* ecryptfs_decrypt_page
- * @page: Page mapped from the eCryptfs inode for the file; data read
+ * @folio: Folio mapped from the eCryptfs inode for the file; data read
* and decrypted from the lower file will be written into this
* page
*
@@ -475,7 +475,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
*
* Returns zero on success; negative on error
*/
-int ecryptfs_decrypt_page(struct page *page)
+int ecryptfs_decrypt_page(struct folio *folio)
{
struct inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat;
@@ -484,13 +484,13 @@ int ecryptfs_decrypt_page(struct page *page)
loff_t lower_offset;
int rc = 0;
- ecryptfs_inode = page->mapping->host;
+ ecryptfs_inode = folio->mapping->host;
crypt_stat =
&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
- lower_offset = lower_offset_for_page(crypt_stat, page);
- page_virt = kmap_local_page(page);
+ lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
+ page_virt = kmap_local_folio(folio, 0);
rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE,
ecryptfs_inode);
kunmap_local(page_virt);
@@ -504,6 +504,7 @@ int ecryptfs_decrypt_page(struct page *page)
for (extent_offset = 0;
extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) {
+ struct page *page = folio_page(folio, 0);
rc = crypt_extent(crypt_stat, page, page,
extent_offset, DECRYPT);
if (rc) {
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index bffced0c1d8f..1f562e75d0e4 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -570,7 +570,7 @@ void ecryptfs_destroy_mount_crypt_stat(
int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
int ecryptfs_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
int ecryptfs_encrypt_page(struct folio *folio);
-int ecryptfs_decrypt_page(struct page *page);
+int ecryptfs_decrypt_page(struct folio *folio);
int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
struct inode *ecryptfs_inode);
int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index b2c22f49ef6f..60f0ac8744b5 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -194,7 +194,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
}
} else {
- err = ecryptfs_decrypt_page(&folio->page);
+ err = ecryptfs_decrypt_page(folio);
if (err) {
ecryptfs_printk(KERN_ERR, "Error decrypting page; "
"err = [%d]\n", err);
@@ -305,7 +305,7 @@ static int ecryptfs_write_begin(struct file *file,
folio_zero_range(folio, 0, PAGE_SIZE);
folio_mark_uptodate(folio);
} else if (len < PAGE_SIZE) {
- rc = ecryptfs_decrypt_page(&folio->page);
+ rc = ecryptfs_decrypt_page(folio);
if (rc) {
printk(KERN_ERR "%s: Error decrypting "
"page at index [%ld]; "
--
2.43.0
next prev parent reply other threads:[~2024-10-25 19:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 19:08 [PATCH v2 00/10] Convert ecryptfs to use folios Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 02/10] ecryptfs: Use a folio throughout ecryptfs_read_folio() Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 03/10] ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 04/10] ecryptfs: Convert ecryptfs_read_lower_page_segment() " Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 05/10] ecryptfs: Convert ecryptfs_write() to use " Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 06/10] ecryptfs: Convert ecryptfs_write_lower_page_segment() to take " Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 07/10] ecryptfs: Convert ecryptfs_encrypt_page() " Matthew Wilcox (Oracle)
2024-10-25 19:08 ` Matthew Wilcox (Oracle) [this message]
2024-10-25 19:08 ` [PATCH v2 09/10] ecryptfs: Convert lower_offset_for_page() " Matthew Wilcox (Oracle)
2024-10-25 19:08 ` [PATCH v2 10/10] ecryptfs: Pass the folio index to crypt_extent() Matthew Wilcox (Oracle)
2024-11-05 15:01 ` [PATCH v2 00/10] Convert ecryptfs to use folios Matthew Wilcox
2024-11-05 16:21 ` 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=20241025190822.1319162-9-willy@infradead.org \
--to=willy@infradead.org \
--cc=brauner@kernel.org \
--cc=code@tyhicks.com \
--cc=ecryptfs@vger.kernel.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).