summaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/file.c
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2012-07-03 19:50:57 -0400
committerTyler Hicks <tyhicks@canonical.com>2012-07-13 19:46:06 -0400
commit821f7494a77627fb1ab539591c57b22cdca702d6 (patch)
tree561ee1768e62c120766c40c0b8fc8aa30b4f4a95 /fs/ecryptfs/file.c
parente3ccaa9761200952cc269b1f4b7d7bb77a5e071b (diff)
eCryptfs: Revert to a writethrough cache model
A change was made about a year ago to get eCryptfs to better utilize its page cache during writes. The idea was to do the page encryption operations during page writeback, rather than doing them when initially writing into the page cache, to reduce the number of page encryption operations during sequential writes. This meant that the encrypted page would only be written to the lower filesystem during page writeback, which was a change from how eCryptfs had previously wrote to the lower filesystem in ecryptfs_write_end(). The change caused a few eCryptfs-internal bugs that were shook out. Unfortunately, more grave side effects have been identified that will force changes outside of eCryptfs. Because the lower filesystem isn't consulted until page writeback, eCryptfs has no way to pass lower write errors (ENOSPC, mainly) back to userspace. Additionaly, it was reported that quotas could be bypassed because of the way eCryptfs may sometimes open the lower filesystem using a privileged kthread. It would be nice to resolve the latest issues, but it is best if the eCryptfs commits be reverted to the old behavior in the meantime. This reverts: 32001d6f "eCryptfs: Flush file in vma close" 5be79de2 "eCryptfs: Flush dirty pages in setattr" 57db4e8d "ecryptfs: modify write path to encrypt page in writepage" Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Tested-by: Colin King <colin.king@canonical.com> Cc: Colin King <colin.king@canonical.com> Cc: Thieu Le <thieule@google.com>
Diffstat (limited to 'fs/ecryptfs/file.c')
-rw-r--r--fs/ecryptfs/file.c33
1 files changed, 2 insertions, 31 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index baf8b0550391..44ce5c6a541d 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -138,27 +138,6 @@ out:
138 return rc; 138 return rc;
139} 139}
140 140
141static void ecryptfs_vma_close(struct vm_area_struct *vma)
142{
143 filemap_write_and_wait(vma->vm_file->f_mapping);
144}
145
146static const struct vm_operations_struct ecryptfs_file_vm_ops = {
147 .close = ecryptfs_vma_close,
148 .fault = filemap_fault,
149};
150
151static int ecryptfs_file_mmap(struct file *file, struct vm_area_struct *vma)
152{
153 int rc;
154
155 rc = generic_file_mmap(file, vma);
156 if (!rc)
157 vma->vm_ops = &ecryptfs_file_vm_ops;
158
159 return rc;
160}
161
162struct kmem_cache *ecryptfs_file_info_cache; 141struct kmem_cache *ecryptfs_file_info_cache;
163 142
164static int read_or_initialize_metadata(struct dentry *dentry) 143static int read_or_initialize_metadata(struct dentry *dentry)
@@ -311,15 +290,7 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
311static int 290static int
312ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync) 291ecryptfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
313{ 292{
314 int rc = 0; 293 return vfs_fsync(ecryptfs_file_to_lower(file), datasync);
315
316 rc = generic_file_fsync(file, start, end, datasync);
317 if (rc)
318 goto out;
319 rc = vfs_fsync_range(ecryptfs_file_to_lower(file), start, end,
320 datasync);
321out:
322 return rc;
323} 294}
324 295
325static int ecryptfs_fasync(int fd, struct file *file, int flag) 296static int ecryptfs_fasync(int fd, struct file *file, int flag)
@@ -388,7 +359,7 @@ const struct file_operations ecryptfs_main_fops = {
388#ifdef CONFIG_COMPAT 359#ifdef CONFIG_COMPAT
389 .compat_ioctl = ecryptfs_compat_ioctl, 360 .compat_ioctl = ecryptfs_compat_ioctl,
390#endif 361#endif
391 .mmap = ecryptfs_file_mmap, 362 .mmap = generic_file_mmap,
392 .open = ecryptfs_open, 363 .open = ecryptfs_open,
393 .flush = ecryptfs_flush, 364 .flush = ecryptfs_flush,
394 .release = ecryptfs_release, 365 .release = ecryptfs_release,