Merge tag 'ecryptfs-3.8-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Jan 2013 01:33:50 +0000 (17:33 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Jan 2013 01:33:50 +0000 (17:33 -0800)
Pull ecryptfs fixes from Tyler Hicks:
 "Two self-explanatory fixes and a third patch which improves
  performance: when overwriting a full page in the eCryptfs page cache,
  skip reading in and decrypting the corresponding lower page."

* tag 'ecryptfs-3.8-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs:
  fs/ecryptfs/crypto.c: make ecryptfs_encode_for_filename() static
  eCryptfs: fix to use list_for_each_entry_safe() when delete items
  eCryptfs: Avoid unnecessary disk read and data decryption during writing

fs/ecryptfs/crypto.c
fs/ecryptfs/kthread.c
fs/ecryptfs/mmap.c

index ea9931281557ad8d3ed4049b48c66110df5f0811..a7b0c2dfb3db76066703076ab43f4d589637523d 100644 (file)
@@ -1935,7 +1935,7 @@ static const unsigned char filename_rev_map[256] = {
  * @src: Source location for the filename to encode
  * @src_size: Size of the source in bytes
  */
-void ecryptfs_encode_for_filename(unsigned char *dst, size_t *dst_size,
+static void ecryptfs_encode_for_filename(unsigned char *dst, size_t *dst_size,
                                  unsigned char *src, size_t src_size)
 {
        size_t num_blocks;
index 809e67d05ca34fa32eb1363c555db71757d1a6a7..f1ea610362c6c160a9d955c6a8e946da03b83ccb 100644 (file)
@@ -102,12 +102,12 @@ int __init ecryptfs_init_kthread(void)
 
 void ecryptfs_destroy_kthread(void)
 {
-       struct ecryptfs_open_req *req;
+       struct ecryptfs_open_req *req, *tmp;
 
        mutex_lock(&ecryptfs_kthread_ctl.mux);
        ecryptfs_kthread_ctl.flags |= ECRYPTFS_KTHREAD_ZOMBIE;
-       list_for_each_entry(req, &ecryptfs_kthread_ctl.req_list,
-                           kthread_ctl_list) {
+       list_for_each_entry_safe(req, tmp, &ecryptfs_kthread_ctl.req_list,
+                                kthread_ctl_list) {
                list_del(&req->kthread_ctl_list);
                *req->lower_file = ERR_PTR(-EIO);
                complete(&req->done);
index bd1d57f98f746af552df4af0acda732f92f6d2f9..564a1fa34b9941a4672d3b455db928ebcd4e4fa1 100644 (file)
@@ -338,7 +338,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 "
@@ -348,8 +349,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.
@@ -499,6 +500,13 @@ static int ecryptfs_write_end(struct file *file,
                }
                goto out;
        }
+       if (!PageUptodate(page)) {
+               if (copied < PAGE_CACHE_SIZE) {
+                       rc = 0;
+                       goto out;
+               }
+               SetPageUptodate(page);
+       }
        /* Fills in zeros if 'to' goes beyond inode size */
        rc = fill_zeros_to_end_of_page(page, to);
        if (rc) {