Skip to content

Commit 807a11d

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages()
By adding a ->migrate_folio implementation, theree is no need to keep the ->writepage implementation. The new writepages removes the unnecessary call to SetPageUptodate(); the folio should already be uptodate at this point. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 8198375 commit 807a11d

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

fs/ecryptfs/mmap.c

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,30 @@ struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index)
3838
return page;
3939
}
4040

41-
/**
42-
* ecryptfs_writepage
43-
* @page: Page that is locked before this call is made
44-
* @wbc: Write-back control structure
45-
*
46-
* Returns zero on success; non-zero otherwise
47-
*
41+
/*
4842
* This is where we encrypt the data and pass the encrypted data to
4943
* the lower filesystem. In OpenPGP-compatible mode, we operate on
5044
* entire underlying packets.
5145
*/
52-
static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc)
46+
static int ecryptfs_writepages(struct address_space *mapping,
47+
struct writeback_control *wbc)
5348
{
54-
int rc;
55-
56-
rc = ecryptfs_encrypt_page(page);
57-
if (rc) {
58-
ecryptfs_printk(KERN_WARNING, "Error encrypting "
59-
"page (upper index [0x%.16lx])\n", page->index);
60-
ClearPageUptodate(page);
61-
goto out;
49+
struct folio *folio = NULL;
50+
int error;
51+
52+
while ((folio = writeback_iter(mapping, wbc, folio, &error))) {
53+
error = ecryptfs_encrypt_page(&folio->page);
54+
if (error) {
55+
ecryptfs_printk(KERN_WARNING,
56+
"Error encrypting folio (index [0x%.16lx])\n",
57+
folio->index);
58+
folio_clear_uptodate(folio);
59+
mapping_set_error(mapping, error);
60+
}
61+
folio_unlock(folio);
6262
}
63-
SetPageUptodate(page);
64-
out:
65-
unlock_page(page);
66-
return rc;
63+
64+
return error;
6765
}
6866

6967
static void strip_xattr_flag(char *page_virt,
@@ -548,9 +546,10 @@ const struct address_space_operations ecryptfs_aops = {
548546
.dirty_folio = block_dirty_folio,
549547
.invalidate_folio = block_invalidate_folio,
550548
#endif
551-
.writepage = ecryptfs_writepage,
549+
.writepages = ecryptfs_writepages,
552550
.read_folio = ecryptfs_read_folio,
553551
.write_begin = ecryptfs_write_begin,
554552
.write_end = ecryptfs_write_end,
553+
.migrate_folio = filemap_migrate_folio,
555554
.bmap = ecryptfs_bmap,
556555
};

0 commit comments

Comments
 (0)