Skip to content

Commit 497eb79

Browse files
Matthew Wilcox (Oracle)brauner
authored andcommitted
ecryptfs: Convert ecryptfs_copy_up_encrypted_with_header() to take a folio
Both callers have a folio, so pass it in and use it throughout. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Pankaj Raghav <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 064fe6b commit 497eb79

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

fs/ecryptfs/mmap.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void strip_xattr_flag(char *page_virt,
9595

9696
/**
9797
* ecryptfs_copy_up_encrypted_with_header
98-
* @page: Sort of a ``virtual'' representation of the encrypted lower
98+
* @folio: Sort of a ``virtual'' representation of the encrypted lower
9999
* file. The actual lower file does not have the metadata in
100100
* the header. This is locked.
101101
* @crypt_stat: The eCryptfs inode's cryptographic context
@@ -104,7 +104,7 @@ static void strip_xattr_flag(char *page_virt,
104104
* seeing, with the header information inserted.
105105
*/
106106
static int
107-
ecryptfs_copy_up_encrypted_with_header(struct page *page,
107+
ecryptfs_copy_up_encrypted_with_header(struct folio *folio,
108108
struct ecryptfs_crypt_stat *crypt_stat)
109109
{
110110
loff_t extent_num_in_page = 0;
@@ -113,31 +113,31 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
113113
int rc = 0;
114114

115115
while (extent_num_in_page < num_extents_per_page) {
116-
loff_t view_extent_num = ((((loff_t)page->index)
116+
loff_t view_extent_num = ((loff_t)folio->index
117117
* num_extents_per_page)
118-
+ extent_num_in_page);
118+
+ extent_num_in_page;
119119
size_t num_header_extents_at_front =
120120
(crypt_stat->metadata_size / crypt_stat->extent_size);
121121

122122
if (view_extent_num < num_header_extents_at_front) {
123123
/* This is a header extent */
124124
char *page_virt;
125125

126-
page_virt = kmap_local_page(page);
126+
page_virt = kmap_local_folio(folio, 0);
127127
memset(page_virt, 0, PAGE_SIZE);
128128
/* TODO: Support more than one header extent */
129129
if (view_extent_num == 0) {
130130
size_t written;
131131

132132
rc = ecryptfs_read_xattr_region(
133-
page_virt, page->mapping->host);
133+
page_virt, folio->mapping->host);
134134
strip_xattr_flag(page_virt + 16, crypt_stat);
135135
ecryptfs_write_header_metadata(page_virt + 20,
136136
crypt_stat,
137137
&written);
138138
}
139139
kunmap_local(page_virt);
140-
flush_dcache_page(page);
140+
flush_dcache_folio(folio);
141141
if (rc) {
142142
printk(KERN_ERR "%s: Error reading xattr "
143143
"region; rc = [%d]\n", __func__, rc);
@@ -150,9 +150,9 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
150150
- crypt_stat->metadata_size);
151151

152152
rc = ecryptfs_read_lower_page_segment(
153-
page, (lower_offset >> PAGE_SHIFT),
153+
&folio->page, (lower_offset >> PAGE_SHIFT),
154154
(lower_offset & ~PAGE_MASK),
155-
crypt_stat->extent_size, page->mapping->host);
155+
crypt_stat->extent_size, folio->mapping->host);
156156
if (rc) {
157157
printk(KERN_ERR "%s: Error attempting to read "
158158
"extent at offset [%lld] in the lower "
@@ -189,8 +189,8 @@ static int ecryptfs_read_folio(struct file *file, struct folio *folio)
189189
inode);
190190
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
191191
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
192-
err = ecryptfs_copy_up_encrypted_with_header(&folio->page,
193-
crypt_stat);
192+
err = ecryptfs_copy_up_encrypted_with_header(folio,
193+
crypt_stat);
194194
if (err) {
195195
printk(KERN_ERR "%s: Error attempting to copy "
196196
"the encrypted content from the lower "
@@ -291,7 +291,7 @@ static int ecryptfs_write_begin(struct file *file,
291291
} else if (crypt_stat->flags & ECRYPTFS_VIEW_AS_ENCRYPTED) {
292292
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) {
293293
rc = ecryptfs_copy_up_encrypted_with_header(
294-
&folio->page, crypt_stat);
294+
folio, crypt_stat);
295295
if (rc) {
296296
printk(KERN_ERR "%s: Error attempting "
297297
"to copy the encrypted content "

0 commit comments

Comments
 (0)