eCryptfs: Remove ECRYPTFS_NEW_FILE crypt stat flag
authorTyler Hicks <tyhicks@linux.vnet.ibm.com>
Wed, 23 Feb 2011 06:54:20 +0000 (00:54 -0600)
committerTyler Hicks <tyhicks@linux.vnet.ibm.com>
Mon, 28 Mar 2011 06:47:44 +0000 (01:47 -0500)
Now that grow_file() is not called in the ecryptfs_create() path, the
ECRYPTFS_NEW_FILE flag is no longer needed. It helped
ecryptfs_readpage() know not to decrypt zeroes that were read from the
lower file in the grow_file() path.

Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
fs/ecryptfs/ecryptfs_kernel.h
fs/ecryptfs/inode.c
fs/ecryptfs/mmap.c

index e007534..427478e 100644 (file)
@@ -257,19 +257,18 @@ struct ecryptfs_filename {
 struct ecryptfs_crypt_stat {
 #define ECRYPTFS_STRUCT_INITIALIZED   0x00000001
 #define ECRYPTFS_POLICY_APPLIED       0x00000002
-#define ECRYPTFS_NEW_FILE             0x00000004
-#define ECRYPTFS_ENCRYPTED            0x00000008
-#define ECRYPTFS_SECURITY_WARNING     0x00000010
-#define ECRYPTFS_ENABLE_HMAC          0x00000020
-#define ECRYPTFS_ENCRYPT_IV_PAGES     0x00000040
-#define ECRYPTFS_KEY_VALID            0x00000080
-#define ECRYPTFS_METADATA_IN_XATTR    0x00000100
-#define ECRYPTFS_VIEW_AS_ENCRYPTED    0x00000200
-#define ECRYPTFS_KEY_SET              0x00000400
-#define ECRYPTFS_ENCRYPT_FILENAMES    0x00000800
-#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00001000
-#define ECRYPTFS_ENCFN_USE_FEK        0x00002000
-#define ECRYPTFS_UNLINK_SIGS         0x00004000
+#define ECRYPTFS_ENCRYPTED            0x00000004
+#define ECRYPTFS_SECURITY_WARNING     0x00000008
+#define ECRYPTFS_ENABLE_HMAC          0x00000010
+#define ECRYPTFS_ENCRYPT_IV_PAGES     0x00000020
+#define ECRYPTFS_KEY_VALID            0x00000040
+#define ECRYPTFS_METADATA_IN_XATTR    0x00000080
+#define ECRYPTFS_VIEW_AS_ENCRYPTED    0x00000100
+#define ECRYPTFS_KEY_SET              0x00000200
+#define ECRYPTFS_ENCRYPT_FILENAMES    0x00000400
+#define ECRYPTFS_ENCFN_USE_MOUNT_FNEK 0x00000800
+#define ECRYPTFS_ENCFN_USE_FEK        0x00001000
+#define ECRYPTFS_UNLINK_SIGS          0x00002000
        u32 flags;
        unsigned int file_version;
        size_t iv_bytes;
index 8fa365a..f99051b 100644 (file)
@@ -161,7 +161,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
                crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
                goto out;
        }
-       crypt_stat->flags |= ECRYPTFS_NEW_FILE;
        ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n");
        rc = ecryptfs_new_file_context(ecryptfs_dentry);
        if (rc) {
index cc64fca..519af27 100644 (file)
@@ -193,11 +193,7 @@ static int ecryptfs_readpage(struct file *file, struct page *page)
                &ecryptfs_inode_to_private(page->mapping->host)->crypt_stat;
        int rc = 0;
 
-       if (!crypt_stat
-           || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
-           || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
-               ecryptfs_printk(KERN_DEBUG,
-                               "Passing through unencrypted page\n");
+       if (!crypt_stat || !(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
                rc = ecryptfs_read_lower_page_segment(page, page->index, 0,
                                                      PAGE_CACHE_SIZE,
                                                      page->mapping->host);
@@ -295,8 +291,7 @@ static int ecryptfs_write_begin(struct file *file,
                struct ecryptfs_crypt_stat *crypt_stat =
                        &ecryptfs_inode_to_private(mapping->host)->crypt_stat;
 
-               if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)
-                   || (crypt_stat->flags & ECRYPTFS_NEW_FILE)) {
+               if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
                        rc = ecryptfs_read_lower_page_segment(
                                page, index, 0, PAGE_CACHE_SIZE, mapping->host);
                        if (rc) {
@@ -487,12 +482,6 @@ static int ecryptfs_write_end(struct file *file,
                &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
        int rc;
 
-       if (crypt_stat->flags & ECRYPTFS_NEW_FILE) {
-               ecryptfs_printk(KERN_DEBUG, "ECRYPTFS_NEW_FILE flag set in "
-                       "crypt_stat at memory location [%p]\n", crypt_stat);
-               crypt_stat->flags &= ~(ECRYPTFS_NEW_FILE);
-       } else
-               ecryptfs_printk(KERN_DEBUG, "Not a new file\n");
        ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
                        "(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
        if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {