ecryptfs: Convert ecryptfs_read_lower_page_segment() to take a folio

All callers have a folio, so pass it in and use it directly.  This will
not work for large folios, but I doubt anybody wants to use large folios
with ecryptfs.

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

View File

@ -658,7 +658,7 @@ int ecryptfs_write_lower_page_segment(struct inode *ecryptfs_inode,
int ecryptfs_write(struct inode *inode, char *data, loff_t offset, size_t size);
int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
struct inode *ecryptfs_inode);
int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
pgoff_t page_index,
size_t offset_in_page, size_t size,
struct inode *ecryptfs_inode);

View File

@ -150,7 +150,7 @@ ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
- crypt_stat->metadata_size);
rc = ecryptfs_read_lower_page_segment(
&folio->page, (lower_offset >> PAGE_SHIFT),
folio, (lower_offset >> PAGE_SHIFT),
(lower_offset & ~PAGE_MASK),
crypt_stat->extent_size, folio->mapping->host);
if (rc) {
@ -184,9 +184,8 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
int err = 0;
if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
err = ecryptfs_read_lower_page_segment(&folio->page, folio->index, 0,
folio_size(folio),
inode);
err = ecryptfs_read_lower_page_segment(folio, folio->index, 0,
folio_size(folio), inode);
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
err = ecryptfs_copy_up_encrypted_with_header(folio,
@ -201,7 +200,7 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
}
} else {
err = ecryptfs_read_lower_page_segment(&folio->page,
err = ecryptfs_read_lower_page_segment(folio,
folio->index, 0, folio_size(folio),
inode);
if (err) {
@ -279,7 +278,7 @@ static int ecryptfs_write_begin(struct file *file,
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
rc = ecryptfs_read_lower_page_segment(
&folio->page, index, 0, PAGE_SIZE, mapping->host);
folio, index, 0, PAGE_SIZE, mapping->host);
if (rc) {
printk(KERN_ERR "%s: Error attempting to read "
"lower page segment; rc = [%d]\n",
@ -305,7 +304,7 @@ static int ecryptfs_write_begin(struct file *file,
folio_mark_uptodate(folio);
} else {
rc = ecryptfs_read_lower_page_segment(
&folio->page, index, 0, PAGE_SIZE,
folio, index, 0, PAGE_SIZE,
mapping->host);
if (rc) {
printk(KERN_ERR "%s: Error reading "

View File

@ -228,7 +228,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
/**
* ecryptfs_read_lower_page_segment
* @page_for_ecryptfs: The page into which data for eCryptfs will be
* @folio_for_ecryptfs: The folio into which data for eCryptfs will be
* written
* @page_index: Page index in @page_for_ecryptfs from which to start
* writing
@ -243,7 +243,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
*
* Returns zero on success; non-zero otherwise
*/
int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
int ecryptfs_read_lower_page_segment(struct folio *folio_for_ecryptfs,
pgoff_t page_index,
size_t offset_in_page, size_t size,
struct inode *ecryptfs_inode)
@ -252,12 +252,12 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
loff_t offset;
int rc;
offset = ((((loff_t)page_index) << PAGE_SHIFT) + offset_in_page);
virt = kmap_local_page(page_for_ecryptfs);
offset = (loff_t)page_index * PAGE_SIZE + offset_in_page;
virt = kmap_local_folio(folio_for_ecryptfs, 0);
rc = ecryptfs_read_lower(virt, offset, size, ecryptfs_inode);
if (rc > 0)
rc = 0;
kunmap_local(virt);
flush_dcache_page(page_for_ecryptfs);
flush_dcache_folio(folio_for_ecryptfs);
return rc;
}