aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/mmap.c')
-rw-r--r--fs/ecryptfs/mmap.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 32c5711d79a3..dc74b186145d 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -34,8 +34,6 @@
34#include <linux/scatterlist.h> 34#include <linux/scatterlist.h>
35#include "ecryptfs_kernel.h" 35#include "ecryptfs_kernel.h"
36 36
37struct kmem_cache *ecryptfs_lower_page_cache;
38
39/** 37/**
40 * ecryptfs_get_locked_page 38 * ecryptfs_get_locked_page
41 * 39 *
@@ -102,13 +100,14 @@ static void set_header_info(char *page_virt,
102 struct ecryptfs_crypt_stat *crypt_stat) 100 struct ecryptfs_crypt_stat *crypt_stat)
103{ 101{
104 size_t written; 102 size_t written;
105 int save_num_header_extents_at_front = 103 size_t save_num_header_bytes_at_front =
106 crypt_stat->num_header_extents_at_front; 104 crypt_stat->num_header_bytes_at_front;
107 105
108 crypt_stat->num_header_extents_at_front = 1; 106 crypt_stat->num_header_bytes_at_front =
107 ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
109 ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written); 108 ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written);
110 crypt_stat->num_header_extents_at_front = 109 crypt_stat->num_header_bytes_at_front =
111 save_num_header_extents_at_front; 110 save_num_header_bytes_at_front;
112} 111}
113 112
114/** 113/**
@@ -134,8 +133,11 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
134 loff_t view_extent_num = ((((loff_t)page->index) 133 loff_t view_extent_num = ((((loff_t)page->index)
135 * num_extents_per_page) 134 * num_extents_per_page)
136 + extent_num_in_page); 135 + extent_num_in_page);
136 size_t num_header_extents_at_front =
137 (crypt_stat->num_header_bytes_at_front
138 / crypt_stat->extent_size);
137 139
138 if (view_extent_num < crypt_stat->num_header_extents_at_front) { 140 if (view_extent_num < num_header_extents_at_front) {
139 /* This is a header extent */ 141 /* This is a header extent */
140 char *page_virt; 142 char *page_virt;
141 143
@@ -157,9 +159,8 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
157 } else { 159 } else {
158 /* This is an encrypted data extent */ 160 /* This is an encrypted data extent */
159 loff_t lower_offset = 161 loff_t lower_offset =
160 ((view_extent_num - 162 ((view_extent_num * crypt_stat->extent_size)
161 crypt_stat->num_header_extents_at_front) 163 - crypt_stat->num_header_bytes_at_front);
162 * crypt_stat->extent_size);
163 164
164 rc = ecryptfs_read_lower_page_segment( 165 rc = ecryptfs_read_lower_page_segment(
165 page, (lower_offset >> PAGE_CACHE_SHIFT), 166 page, (lower_offset >> PAGE_CACHE_SHIFT),
@@ -257,8 +258,7 @@ static int fill_zeros_to_end_of_page(struct page *page, unsigned int to)
257 end_byte_in_page = i_size_read(inode) % PAGE_CACHE_SIZE; 258 end_byte_in_page = i_size_read(inode) % PAGE_CACHE_SIZE;
258 if (to > end_byte_in_page) 259 if (to > end_byte_in_page)
259 end_byte_in_page = to; 260 end_byte_in_page = to;
260 zero_user_page(page, end_byte_in_page, 261 zero_user_segment(page, end_byte_in_page, PAGE_CACHE_SIZE);
261 PAGE_CACHE_SIZE - end_byte_in_page, KM_USER0);
262out: 262out:
263 return 0; 263 return 0;
264} 264}
@@ -307,7 +307,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
307 */ 307 */
308 if ((i_size_read(page->mapping->host) == prev_page_end_size) && 308 if ((i_size_read(page->mapping->host) == prev_page_end_size) &&
309 (from != 0)) { 309 (from != 0)) {
310 zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); 310 zero_user(page, 0, PAGE_CACHE_SIZE);
311 } 311 }
312out: 312out:
313 return rc; 313 return rc;