diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/ecryptfs/super.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'fs/ecryptfs/super.c')
-rw-r--r-- | fs/ecryptfs/super.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index f7fc286a3aa9..dbd52d40df4c 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/key.h> | 28 | #include <linux/key.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/seq_file.h> | 30 | #include <linux/seq_file.h> |
31 | #include <linux/smp_lock.h> | ||
32 | #include <linux/file.h> | 31 | #include <linux/file.h> |
33 | #include <linux/crypto.h> | 32 | #include <linux/crypto.h> |
34 | #include "ecryptfs_kernel.h" | 33 | #include "ecryptfs_kernel.h" |
@@ -57,20 +56,30 @@ static struct inode *ecryptfs_alloc_inode(struct super_block *sb) | |||
57 | goto out; | 56 | goto out; |
58 | ecryptfs_init_crypt_stat(&inode_info->crypt_stat); | 57 | ecryptfs_init_crypt_stat(&inode_info->crypt_stat); |
59 | mutex_init(&inode_info->lower_file_mutex); | 58 | mutex_init(&inode_info->lower_file_mutex); |
59 | atomic_set(&inode_info->lower_file_count, 0); | ||
60 | inode_info->lower_file = NULL; | 60 | inode_info->lower_file = NULL; |
61 | inode = &inode_info->vfs_inode; | 61 | inode = &inode_info->vfs_inode; |
62 | out: | 62 | out: |
63 | return inode; | 63 | return inode; |
64 | } | 64 | } |
65 | 65 | ||
66 | static void ecryptfs_i_callback(struct rcu_head *head) | ||
67 | { | ||
68 | struct inode *inode = container_of(head, struct inode, i_rcu); | ||
69 | struct ecryptfs_inode_info *inode_info; | ||
70 | inode_info = ecryptfs_inode_to_private(inode); | ||
71 | |||
72 | INIT_LIST_HEAD(&inode->i_dentry); | ||
73 | kmem_cache_free(ecryptfs_inode_info_cache, inode_info); | ||
74 | } | ||
75 | |||
66 | /** | 76 | /** |
67 | * ecryptfs_destroy_inode | 77 | * ecryptfs_destroy_inode |
68 | * @inode: The ecryptfs inode | 78 | * @inode: The ecryptfs inode |
69 | * | 79 | * |
70 | * This is used during the final destruction of the inode. All | 80 | * This is used during the final destruction of the inode. All |
71 | * allocation of memory related to the inode, including allocated | 81 | * allocation of memory related to the inode, including allocated |
72 | * memory in the crypt_stat struct, will be released here. This | 82 | * memory in the crypt_stat struct, will be released here. |
73 | * function also fput()'s the persistent file for the lower inode. | ||
74 | * There should be no chance that this deallocation will be missed. | 83 | * There should be no chance that this deallocation will be missed. |
75 | */ | 84 | */ |
76 | static void ecryptfs_destroy_inode(struct inode *inode) | 85 | static void ecryptfs_destroy_inode(struct inode *inode) |
@@ -78,34 +87,9 @@ static void ecryptfs_destroy_inode(struct inode *inode) | |||
78 | struct ecryptfs_inode_info *inode_info; | 87 | struct ecryptfs_inode_info *inode_info; |
79 | 88 | ||
80 | inode_info = ecryptfs_inode_to_private(inode); | 89 | inode_info = ecryptfs_inode_to_private(inode); |
81 | if (inode_info->lower_file) { | 90 | BUG_ON(inode_info->lower_file); |
82 | struct dentry *lower_dentry = | ||
83 | inode_info->lower_file->f_dentry; | ||
84 | |||
85 | BUG_ON(!lower_dentry); | ||
86 | if (lower_dentry->d_inode) { | ||
87 | fput(inode_info->lower_file); | ||
88 | inode_info->lower_file = NULL; | ||
89 | } | ||
90 | } | ||
91 | ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat); | 91 | ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat); |
92 | kmem_cache_free(ecryptfs_inode_info_cache, inode_info); | 92 | call_rcu(&inode->i_rcu, ecryptfs_i_callback); |
93 | } | ||
94 | |||
95 | /** | ||
96 | * ecryptfs_init_inode | ||
97 | * @inode: The ecryptfs inode | ||
98 | * | ||
99 | * Set up the ecryptfs inode. | ||
100 | */ | ||
101 | void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode) | ||
102 | { | ||
103 | ecryptfs_set_inode_lower(inode, lower_inode); | ||
104 | inode->i_ino = lower_inode->i_ino; | ||
105 | inode->i_version++; | ||
106 | inode->i_op = &ecryptfs_main_iops; | ||
107 | inode->i_fop = &ecryptfs_main_fops; | ||
108 | inode->i_mapping->a_ops = &ecryptfs_aops; | ||
109 | } | 93 | } |
110 | 94 | ||
111 | /** | 95 | /** |
@@ -180,6 +164,8 @@ static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
180 | seq_printf(m, ",ecryptfs_encrypted_view"); | 164 | seq_printf(m, ",ecryptfs_encrypted_view"); |
181 | if (mount_crypt_stat->flags & ECRYPTFS_UNLINK_SIGS) | 165 | if (mount_crypt_stat->flags & ECRYPTFS_UNLINK_SIGS) |
182 | seq_printf(m, ",ecryptfs_unlink_sigs"); | 166 | seq_printf(m, ",ecryptfs_unlink_sigs"); |
167 | if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY) | ||
168 | seq_printf(m, ",ecryptfs_mount_auth_tok_only"); | ||
183 | 169 | ||
184 | return 0; | 170 | return 0; |
185 | } | 171 | } |
@@ -187,7 +173,7 @@ static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
187 | const struct super_operations ecryptfs_sops = { | 173 | const struct super_operations ecryptfs_sops = { |
188 | .alloc_inode = ecryptfs_alloc_inode, | 174 | .alloc_inode = ecryptfs_alloc_inode, |
189 | .destroy_inode = ecryptfs_destroy_inode, | 175 | .destroy_inode = ecryptfs_destroy_inode, |
190 | .drop_inode = generic_delete_inode, | 176 | .drop_inode = generic_drop_inode, |
191 | .statfs = ecryptfs_statfs, | 177 | .statfs = ecryptfs_statfs, |
192 | .remount_fs = NULL, | 178 | .remount_fs = NULL, |
193 | .evict_inode = ecryptfs_evict_inode, | 179 | .evict_inode = ecryptfs_evict_inode, |