ecryptfs: Convert ecryptfs_decrypt_page() to take a folio

Both callers have a folio, so pass it in and use it throughout.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20241025190822.1319162-9-willy@infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2024-10-25 20:08:18 +01:00 committed by Christian Brauner
parent 6b9c0e8137
commit c15b81461d
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
3 changed files with 9 additions and 8 deletions

View File

@ -461,7 +461,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
/** /**
* ecryptfs_decrypt_page * 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 * and decrypted from the lower file will be written into this
* page * page
* *
@ -475,7 +475,7 @@ int ecryptfs_encrypt_page(struct folio *folio)
* *
* Returns zero on success; negative on error * 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 inode *ecryptfs_inode;
struct ecryptfs_crypt_stat *crypt_stat; struct ecryptfs_crypt_stat *crypt_stat;
@ -484,13 +484,13 @@ int ecryptfs_decrypt_page(struct page *page)
loff_t lower_offset; loff_t lower_offset;
int rc = 0; int rc = 0;
ecryptfs_inode = page->mapping->host; ecryptfs_inode = folio->mapping->host;
crypt_stat = crypt_stat =
&(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat); &(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat);
BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)); BUG_ON(!(crypt_stat->flags & ECRYPTFS_ENCRYPTED));
lower_offset = lower_offset_for_page(crypt_stat, page); lower_offset = lower_offset_for_page(crypt_stat, &folio->page);
page_virt = kmap_local_page(page); page_virt = kmap_local_folio(folio, 0);
rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE, rc = ecryptfs_read_lower(page_virt, lower_offset, PAGE_SIZE,
ecryptfs_inode); ecryptfs_inode);
kunmap_local(page_virt); kunmap_local(page_virt);
@ -504,6 +504,7 @@ int ecryptfs_decrypt_page(struct page *page)
for (extent_offset = 0; for (extent_offset = 0;
extent_offset < (PAGE_SIZE / crypt_stat->extent_size); extent_offset < (PAGE_SIZE / crypt_stat->extent_size);
extent_offset++) { extent_offset++) {
struct page *page = folio_page(folio, 0);
rc = crypt_extent(crypt_stat, page, page, rc = crypt_extent(crypt_stat, page, page,
extent_offset, DECRYPT); extent_offset, DECRYPT);
if (rc) { if (rc) {

View File

@ -570,7 +570,7 @@ void ecryptfs_destroy_mount_crypt_stat(
int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *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_write_inode_size_to_metadata(struct inode *ecryptfs_inode);
int ecryptfs_encrypt_page(struct folio *folio); 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, int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
struct inode *ecryptfs_inode); struct inode *ecryptfs_inode);
int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry); int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry);

View File

@ -194,7 +194,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
} }
} }
} else { } else {
err = ecryptfs_decrypt_page(&folio->page); err = ecryptfs_decrypt_page(folio);
if (err) { if (err) {
ecryptfs_printk(KERN_ERR, "Error decrypting page; " ecryptfs_printk(KERN_ERR, "Error decrypting page; "
"err = [%d]\n", err); "err = [%d]\n", err);
@ -305,7 +305,7 @@ static int ecryptfs_write_begin(struct file *file,
folio_zero_range(folio, 0, PAGE_SIZE); folio_zero_range(folio, 0, PAGE_SIZE);
folio_mark_uptodate(folio); folio_mark_uptodate(folio);
} else if (len < PAGE_SIZE) { } else if (len < PAGE_SIZE) {
rc = ecryptfs_decrypt_page(&folio->page); rc = ecryptfs_decrypt_page(folio);
if (rc) { if (rc) {
printk(KERN_ERR "%s: Error decrypting " printk(KERN_ERR "%s: Error decrypting "
"page at index [%ld]; " "page at index [%ld]; "