* [PATCH] fs: ecryptfs: fixed msync to flush data
@ 2013-05-23 21:31 Paul Taysom
2013-05-24 23:31 ` Tyler Hicks
0 siblings, 1 reply; 3+ messages in thread
From: Paul Taysom @ 2013-05-23 21:31 UTC (permalink / raw)
To: Tyler Hicks; +Cc: Dustin Kirkland, ecryptfs, linux-kernel, olofj, taysom
When msync is called on a memory mapped file, that
data is not flushed to the disk.
In Linux, msync calls fsync for the file. For ecryptfs,
fsync just calls the lower level file system's fsync.
Changed the ecryptfs fsync code to call filemap_write_and_wait
before calling the lower level fsync.
Addresses the problem described in http://crbug.com/239536
Signed-off-by: Paul Taysom <taysom@chromium.org>
---
fs/ecryptfs/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 201f0a0..16f509d 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -295,6 +295,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
static int
ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
+ filemap_write_and_wait(file->f_mapping);
return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
}
--
1.8.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: ecryptfs: fixed msync to flush data
2013-05-23 21:31 [PATCH] fs: ecryptfs: fixed msync to flush data Paul Taysom
@ 2013-05-24 23:31 ` Tyler Hicks
2013-06-05 6:53 ` [PATCH] eCryptfs: Check return of filemap_write_and_wait during fsync Tyler Hicks
0 siblings, 1 reply; 3+ messages in thread
From: Tyler Hicks @ 2013-05-24 23:31 UTC (permalink / raw)
To: Paul Taysom; +Cc: Dustin Kirkland, ecryptfs, linux-kernel, olofj
[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]
On 2013-05-23 14:31:43, Paul Taysom wrote:
> When msync is called on a memory mapped file, that
> data is not flushed to the disk.
>
> In Linux, msync calls fsync for the file. For ecryptfs,
> fsync just calls the lower level file system's fsync.
> Changed the ecryptfs fsync code to call filemap_write_and_wait
> before calling the lower level fsync.
>
> Addresses the problem described in http://crbug.com/239536
>
> Signed-off-by: Paul Taysom <taysom@chromium.org>
> ---
Thanks, Paul! I've pushed this to the eCryptfs next branch:
http://git.kernel.org/cgit/linux/kernel/git/tyhicks/ecryptfs.git/log/?h=next
I also marked it for the stable kernel as affecting 3.6 and newer.
As a side note, we need to make ecryptfs_fsync() more selective about
what gets synced by using filemap_write_and_wait_range() and
vfs_fsync_range(). Since we're already calling vfs_fsync() for the
entire lower file, this patch is good enough for now.
Tyler
> fs/ecryptfs/file.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
> index 201f0a0..16f509d 100644
> --- a/fs/ecryptfs/file.c
> +++ b/fs/ecryptfs/file.c
> @@ -295,6 +295,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
> static int
> ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> {
> + filemap_write_and_wait(file->f_mapping);
> return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
> }
>
> --
> 1.8.2.1
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] eCryptfs: Check return of filemap_write_and_wait during fsync
2013-05-24 23:31 ` Tyler Hicks
@ 2013-06-05 6:53 ` Tyler Hicks
0 siblings, 0 replies; 3+ messages in thread
From: Tyler Hicks @ 2013-06-05 6:53 UTC (permalink / raw)
To: ecryptfs; +Cc: linux-kernel, Paul Taysom, Olof Johansson
Error out of ecryptfs_fsync() if filemap_write_and_wait() fails.
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Cc: Paul Taysom <taysom@chromium.org>
Cc: Olof Johansson <olofj@chromium.org>
---
After giving Paul's patch one more look, I noticed that we were ignoring
filemap_write_and_wait()'s return value. I plan to push this patch along with
Paul's original patch.
fs/ecryptfs/file.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 16f509d..a7abbea 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -295,7 +295,12 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
static int
ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
- filemap_write_and_wait(file->f_mapping);
+ int rc;
+
+ rc = filemap_write_and_wait(file->f_mapping);
+ if (rc)
+ return rc;
+
return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-06-05 6:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-23 21:31 [PATCH] fs: ecryptfs: fixed msync to flush data Paul Taysom
2013-05-24 23:31 ` Tyler Hicks
2013-06-05 6:53 ` [PATCH] eCryptfs: Check return of filemap_write_and_wait during fsync Tyler Hicks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).