[<prev] [next>] [day] [month] [year] [list]
Message-Id: <120125231058365612da29f3ab1c3bb2d794f83e9305@nudt.edu.cn>
Date: Wed, 25 Jan 2012 23:10:58 +0800
From: "Li Wang" <liwang@...t.edu.cn>
To: "Tyler Hicks" <tyhicks@...onical.com>
Cc: "ecryptfs" <ecryptfs@...r.kernel.org>,
"linux-kernel" <linux-kernel@...r.kernel.org>
Subject: [PATCH] eCryptfs: write optimization
Hi,
ecryptfs_write_begin() grabs a page from page cache for writing.
If the page does not contain valid data, or the data are older than
the counterpart on the disk, eCryptfs will read out the corresponding data
from the disk into the eCryptfs page cache, decrypt them,
then perform writting. However, for current page, if the length of
the data to be written into is equal to page size, that means the whole
page of data will be overwritten, in which case, it does not matter whatever
the data were before, it is beneficial to perform writting directly.
This is useful while using eCryptfs in backup situation, user copies file
out from eCryptfs folder, modifies, and copies the revised file back to
replace the original one.
With this optimization, according to our test, iozone 'write' operation on an existing
file with write size being multiple of page size will enjoy a steady 3x speedup.
Signed-off-by: Li Wang <liwang@...t.edu.cn>
Yunchuan Wen <wenyunchuan@...inos.com.cn>
---
fs/ecryptfs/mmap.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 6a44148..9724ef2 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -346,7 +346,8 @@ static int ecryptfs_write_begin(struct file *file,
if (prev_page_end_size
>= i_size_read(page->mapping->host)) {
zero_user(page, 0, PAGE_CACHE_SIZE);
- } else {
+ SetPageUptodate(page);
+ } else if (len < PAGE_CACHE_SIZE) {
rc = ecryptfs_decrypt_page(page);
if (rc) {
printk(KERN_ERR "%s: Error decrypting "
@@ -356,8 +357,8 @@ static int ecryptfs_write_begin(struct file *file,
ClearPageUptodate(page);
goto out;
}
+ SetPageUptodate(page);
}
- SetPageUptodate(page);
}
}
/* If creating a page or more of holes, zero them out via truncate.
Powered by blists - more mailing lists