diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-15 20:45:11 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-24 23:34:48 -0400 |
commit | 2edbfbf1c1ab0aeb58ce8abfb69b6f6b63542848 (patch) | |
tree | dc37f9a9aac1cd63c578841b29a039fbe86f48bf /fs/ecryptfs | |
parent | 3a93e17cf68b01fa29c7a2e861ce508dcd3401ca (diff) |
ecryptfs: don't leave RCU pathwalk immediately
If the underlying dentry doesn't have ->d_revalidate(), there's no need to
force dropping out of RCU mode. All we need for that is to make freeing
ecryptfs_dentry_info RCU-delayed.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/dentry.c | 30 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 5 |
2 files changed, 20 insertions, 15 deletions
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c index 46e31c92e574..8cefa8e13bcc 100644 --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c | |||
@@ -44,15 +44,15 @@ | |||
44 | */ | 44 | */ |
45 | static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags) | 45 | static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags) |
46 | { | 46 | { |
47 | struct dentry *lower_dentry; | 47 | struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); |
48 | int rc = 1; | 48 | int rc; |
49 | |||
50 | if (!(lower_dentry->d_flags & DCACHE_OP_REVALIDATE)) | ||
51 | return 1; | ||
49 | 52 | ||
50 | if (flags & LOOKUP_RCU) | 53 | if (flags & LOOKUP_RCU) |
51 | return -ECHILD; | 54 | return -ECHILD; |
52 | 55 | ||
53 | lower_dentry = ecryptfs_dentry_to_lower(dentry); | ||
54 | if (!(lower_dentry->d_flags & DCACHE_OP_REVALIDATE)) | ||
55 | goto out; | ||
56 | rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags); | 56 | rc = lower_dentry->d_op->d_revalidate(lower_dentry, flags); |
57 | if (dentry->d_inode) { | 57 | if (dentry->d_inode) { |
58 | struct inode *lower_inode = | 58 | struct inode *lower_inode = |
@@ -60,12 +60,17 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, unsigned int flags) | |||
60 | 60 | ||
61 | fsstack_copy_attr_all(dentry->d_inode, lower_inode); | 61 | fsstack_copy_attr_all(dentry->d_inode, lower_inode); |
62 | } | 62 | } |
63 | out: | ||
64 | return rc; | 63 | return rc; |
65 | } | 64 | } |
66 | 65 | ||
67 | struct kmem_cache *ecryptfs_dentry_info_cache; | 66 | struct kmem_cache *ecryptfs_dentry_info_cache; |
68 | 67 | ||
68 | static void ecryptfs_dentry_free_rcu(struct rcu_head *head) | ||
69 | { | ||
70 | kmem_cache_free(ecryptfs_dentry_info_cache, | ||
71 | container_of(head, struct ecryptfs_dentry_info, rcu)); | ||
72 | } | ||
73 | |||
69 | /** | 74 | /** |
70 | * ecryptfs_d_release | 75 | * ecryptfs_d_release |
71 | * @dentry: The ecryptfs dentry | 76 | * @dentry: The ecryptfs dentry |
@@ -74,15 +79,12 @@ struct kmem_cache *ecryptfs_dentry_info_cache; | |||
74 | */ | 79 | */ |
75 | static void ecryptfs_d_release(struct dentry *dentry) | 80 | static void ecryptfs_d_release(struct dentry *dentry) |
76 | { | 81 | { |
77 | if (ecryptfs_dentry_to_private(dentry)) { | 82 | struct ecryptfs_dentry_info *p = dentry->d_fsdata; |
78 | if (ecryptfs_dentry_to_lower(dentry)) { | 83 | if (p) { |
79 | dput(ecryptfs_dentry_to_lower(dentry)); | 84 | if (p->lower_path.dentry) |
80 | mntput(ecryptfs_dentry_to_lower_mnt(dentry)); | 85 | path_put(&p->lower_path); |
81 | } | 86 | call_rcu(&p->rcu, ecryptfs_dentry_free_rcu); |
82 | kmem_cache_free(ecryptfs_dentry_info_cache, | ||
83 | ecryptfs_dentry_to_private(dentry)); | ||
84 | } | 87 | } |
85 | return; | ||
86 | } | 88 | } |
87 | 89 | ||
88 | const struct dentry_operations ecryptfs_dops = { | 90 | const struct dentry_operations ecryptfs_dops = { |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index df19d34a033b..e7ad2b3f24a7 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -261,7 +261,10 @@ struct ecryptfs_inode_info { | |||
261 | * vfsmount too. */ | 261 | * vfsmount too. */ |
262 | struct ecryptfs_dentry_info { | 262 | struct ecryptfs_dentry_info { |
263 | struct path lower_path; | 263 | struct path lower_path; |
264 | struct ecryptfs_crypt_stat *crypt_stat; | 264 | union { |
265 | struct ecryptfs_crypt_stat *crypt_stat; | ||
266 | struct rcu_head rcu; | ||
267 | }; | ||
265 | }; | 268 | }; |
266 | 269 | ||
267 | /** | 270 | /** |