From: "Li Wang" <liwang@nudt.edu.cn>
To: Tyler Hicks <tyhicks@canonical.com>
Cc: ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] eCryptfs: write optimization
Date: Wed, 25 Jan 2012 23:08:58 +0800 [thread overview]
Message-ID: <527503333.04197@eyou.net> (raw)
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 writing. 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 writing 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@nudt.edu.cn>
Yunchuan Wen <wenyunchuan@kylinos.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.
WARNING: multiple messages have this Message-ID (diff)
From: "Li Wang" <liwang@nudt.edu.cn>
To: "Tyler Hicks" <tyhicks@canonical.com>
Cc: <ecryptfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] eCryptfs: write optimization
Date: Wed, 25 Jan 2012 23:08:58 +0800 [thread overview]
Message-ID: <527503333.04197@eyou.net> (raw)
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 writing. 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 writing 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@nudt.edu.cn>
Yunchuan Wen <wenyunchuan@kylinos.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.
next reply other threads:[~2012-01-25 15:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-25 15:08 Li Wang [this message]
2012-01-25 15:08 ` [PATCH] eCryptfs: write optimization Li Wang
2012-01-25 23:05 ` Tyler Hicks
-- strict thread matches above, loose matches on Subject: below --
2012-01-25 15:10 Li Wang
2012-01-25 15:10 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=527503333.04197@eyou.net \
--to=liwang@nudt.edu.cn \
--cc=ecryptfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tyhicks@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.