diff options
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/inode.c | 18 | ||||
-rw-r--r-- | fs/ecryptfs/super.c | 14 |
2 files changed, 24 insertions, 8 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 31ef5252f0fe..82900b063b1e 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -804,10 +804,20 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia, | |||
804 | size_t num_zeros = (PAGE_CACHE_SIZE | 804 | size_t num_zeros = (PAGE_CACHE_SIZE |
805 | - (ia->ia_size & ~PAGE_CACHE_MASK)); | 805 | - (ia->ia_size & ~PAGE_CACHE_MASK)); |
806 | 806 | ||
807 | |||
808 | /* | ||
809 | * XXX(truncate) this should really happen at the begginning | ||
810 | * of ->setattr. But the code is too messy to that as part | ||
811 | * of a larger patch. ecryptfs is also totally missing out | ||
812 | * on the inode_change_ok check at the beginning of | ||
813 | * ->setattr while would include this. | ||
814 | */ | ||
815 | rc = inode_newsize_ok(inode, ia->ia_size); | ||
816 | if (rc) | ||
817 | goto out; | ||
818 | |||
807 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { | 819 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
808 | rc = simple_setsize(inode, ia->ia_size); | 820 | truncate_setsize(inode, ia->ia_size); |
809 | if (rc) | ||
810 | goto out; | ||
811 | lower_ia->ia_size = ia->ia_size; | 821 | lower_ia->ia_size = ia->ia_size; |
812 | lower_ia->ia_valid |= ATTR_SIZE; | 822 | lower_ia->ia_valid |= ATTR_SIZE; |
813 | goto out; | 823 | goto out; |
@@ -830,7 +840,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia, | |||
830 | goto out; | 840 | goto out; |
831 | } | 841 | } |
832 | } | 842 | } |
833 | simple_setsize(inode, ia->ia_size); | 843 | truncate_setsize(inode, ia->ia_size); |
834 | rc = ecryptfs_write_inode_size_to_metadata(inode); | 844 | rc = ecryptfs_write_inode_size_to_metadata(inode); |
835 | if (rc) { | 845 | if (rc) { |
836 | printk(KERN_ERR "Problem with " | 846 | printk(KERN_ERR "Problem with " |
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index 0435886e4a9f..f7fc286a3aa9 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c | |||
@@ -118,11 +118,15 @@ void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode) | |||
118 | */ | 118 | */ |
119 | static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 119 | static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
120 | { | 120 | { |
121 | return vfs_statfs(ecryptfs_dentry_to_lower(dentry), buf); | 121 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
122 | |||
123 | if (!lower_dentry->d_sb->s_op->statfs) | ||
124 | return -ENOSYS; | ||
125 | return lower_dentry->d_sb->s_op->statfs(lower_dentry, buf); | ||
122 | } | 126 | } |
123 | 127 | ||
124 | /** | 128 | /** |
125 | * ecryptfs_clear_inode | 129 | * ecryptfs_evict_inode |
126 | * @inode - The ecryptfs inode | 130 | * @inode - The ecryptfs inode |
127 | * | 131 | * |
128 | * Called by iput() when the inode reference count reached zero | 132 | * Called by iput() when the inode reference count reached zero |
@@ -131,8 +135,10 @@ static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
131 | * on the inode free list. We use this to drop out reference to the | 135 | * on the inode free list. We use this to drop out reference to the |
132 | * lower inode. | 136 | * lower inode. |
133 | */ | 137 | */ |
134 | static void ecryptfs_clear_inode(struct inode *inode) | 138 | static void ecryptfs_evict_inode(struct inode *inode) |
135 | { | 139 | { |
140 | truncate_inode_pages(&inode->i_data, 0); | ||
141 | end_writeback(inode); | ||
136 | iput(ecryptfs_inode_to_lower(inode)); | 142 | iput(ecryptfs_inode_to_lower(inode)); |
137 | } | 143 | } |
138 | 144 | ||
@@ -184,6 +190,6 @@ const struct super_operations ecryptfs_sops = { | |||
184 | .drop_inode = generic_delete_inode, | 190 | .drop_inode = generic_delete_inode, |
185 | .statfs = ecryptfs_statfs, | 191 | .statfs = ecryptfs_statfs, |
186 | .remount_fs = NULL, | 192 | .remount_fs = NULL, |
187 | .clear_inode = ecryptfs_clear_inode, | 193 | .evict_inode = ecryptfs_evict_inode, |
188 | .show_options = ecryptfs_show_options | 194 | .show_options = ecryptfs_show_options |
189 | }; | 195 | }; |