mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
ecryptfs: remove unnecessary decrypt when extending a file
Removes an unecessary page decrypt from ecryptfs_begin_write when the page is beyond the current file size. Previously, the call to ecryptfs_decrypt_page would result in a read of 0 bytes, but still attempt to decrypt an entire page. This patch detects that case and merely zeros the page before marking it up-to-date. Signed-off-by: Frank Swiderski <fes@chromium.org> Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
This commit is contained in:
parent
f24b38874e
commit
24562486be
1 changed files with 14 additions and 8 deletions
|
@ -290,6 +290,7 @@ static int ecryptfs_write_begin(struct file *file,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
*pagep = page;
|
*pagep = page;
|
||||||
|
|
||||||
|
prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT);
|
||||||
if (!PageUptodate(page)) {
|
if (!PageUptodate(page)) {
|
||||||
struct ecryptfs_crypt_stat *crypt_stat =
|
struct ecryptfs_crypt_stat *crypt_stat =
|
||||||
&ecryptfs_inode_to_private(mapping->host)->crypt_stat;
|
&ecryptfs_inode_to_private(mapping->host)->crypt_stat;
|
||||||
|
@ -334,19 +335,24 @@ static int ecryptfs_write_begin(struct file *file,
|
||||||
}
|
}
|
||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (prev_page_end_size
|
||||||
|
>= i_size_read(page->mapping->host)) {
|
||||||
|
zero_user(page, 0, PAGE_CACHE_SIZE);
|
||||||
} else {
|
} else {
|
||||||
rc = ecryptfs_decrypt_page(page);
|
rc = ecryptfs_decrypt_page(page);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printk(KERN_ERR "%s: Error decrypting page "
|
printk(KERN_ERR "%s: Error decrypting "
|
||||||
"at index [%ld]; rc = [%d]\n",
|
"page at index [%ld]; "
|
||||||
|
"rc = [%d]\n",
|
||||||
__func__, page->index, rc);
|
__func__, page->index, rc);
|
||||||
ClearPageUptodate(page);
|
ClearPageUptodate(page);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT);
|
|
||||||
/* If creating a page or more of holes, zero them out via truncate.
|
/* If creating a page or more of holes, zero them out via truncate.
|
||||||
* Note, this will increase i_size. */
|
* Note, this will increase i_size. */
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue