diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-13 17:43:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-13 17:43:11 -0500 |
commit | 87da149343c8c93f6984c0f4b9da7651709624f7 (patch) | |
tree | 47e2f102a0dd40ae822a8b7c470da07f3a1b9081 /fs/kernfs/dir.c | |
parent | 0890147fe09ff7e8275a162b1ab76ab5e3158c6d (diff) |
Revert "kernfs: replace kernfs_node->u.completion with kernfs_root->deactivate_waitq"
This reverts commit ea1c472dfeada211a0100daa7976e8e8e779b858.
Tejun writes:
I'm sorry but can you please revert the whole series?
get_active() waiting while a node is deactivated has potential
to lead to deadlock and that deactivate/reactivate interface is
something fundamentally flawed and that cgroup will have to work
with the remove_self() like everybody else. IOW, I think the
first posting was correct.
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/dir.c')
-rw-r--r-- | fs/kernfs/dir.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index ed62de6cdf8f..510b5062ef30 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * This file is released under the GPLv2. | 8 | * This file is released under the GPLv2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/sched.h> | ||
12 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
13 | #include <linux/namei.h> | 12 | #include <linux/namei.h> |
14 | #include <linux/idr.h> | 13 | #include <linux/idr.h> |
@@ -152,7 +151,6 @@ struct kernfs_node *kernfs_get_active(struct kernfs_node *kn) | |||
152 | */ | 151 | */ |
153 | void kernfs_put_active(struct kernfs_node *kn) | 152 | void kernfs_put_active(struct kernfs_node *kn) |
154 | { | 153 | { |
155 | struct kernfs_root *root = kernfs_root(kn); | ||
156 | int v; | 154 | int v; |
157 | 155 | ||
158 | if (unlikely(!kn)) | 156 | if (unlikely(!kn)) |
@@ -164,7 +162,11 @@ void kernfs_put_active(struct kernfs_node *kn) | |||
164 | if (likely(v != KN_DEACTIVATED_BIAS)) | 162 | if (likely(v != KN_DEACTIVATED_BIAS)) |
165 | return; | 163 | return; |
166 | 164 | ||
167 | wake_up_all(&root->deactivate_waitq); | 165 | /* |
166 | * atomic_dec_return() is a mb(), we'll always see the updated | ||
167 | * kn->u.completion. | ||
168 | */ | ||
169 | complete(kn->u.completion); | ||
168 | } | 170 | } |
169 | 171 | ||
170 | /** | 172 | /** |
@@ -175,22 +177,26 @@ void kernfs_put_active(struct kernfs_node *kn) | |||
175 | */ | 177 | */ |
176 | static void kernfs_deactivate(struct kernfs_node *kn) | 178 | static void kernfs_deactivate(struct kernfs_node *kn) |
177 | { | 179 | { |
178 | struct kernfs_root *root = kernfs_root(kn); | 180 | DECLARE_COMPLETION_ONSTACK(wait); |
181 | int v; | ||
179 | 182 | ||
180 | BUG_ON(!(kn->flags & KERNFS_REMOVED)); | 183 | BUG_ON(!(kn->flags & KERNFS_REMOVED)); |
181 | 184 | ||
182 | if (!(kernfs_type(kn) & KERNFS_ACTIVE_REF)) | 185 | if (!(kernfs_type(kn) & KERNFS_ACTIVE_REF)) |
183 | return; | 186 | return; |
184 | 187 | ||
185 | rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_); | 188 | kn->u.completion = (void *)&wait; |
186 | 189 | ||
187 | atomic_add(KN_DEACTIVATED_BIAS, &kn->active); | 190 | rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_); |
191 | /* atomic_add_return() is a mb(), put_active() will always see | ||
192 | * the updated kn->u.completion. | ||
193 | */ | ||
194 | v = atomic_add_return(KN_DEACTIVATED_BIAS, &kn->active); | ||
188 | 195 | ||
189 | if (atomic_read(&kn->active) != KN_DEACTIVATED_BIAS) | 196 | if (v != KN_DEACTIVATED_BIAS) { |
190 | lock_contended(&kn->dep_map, _RET_IP_); | 197 | lock_contended(&kn->dep_map, _RET_IP_); |
191 | 198 | wait_for_completion(&wait); | |
192 | wait_event(root->deactivate_waitq, | 199 | } |
193 | atomic_read(&kn->active) == KN_DEACTIVATED_BIAS); | ||
194 | 200 | ||
195 | lock_acquired(&kn->dep_map, _RET_IP_); | 201 | lock_acquired(&kn->dep_map, _RET_IP_); |
196 | rwsem_release(&kn->dep_map, 1, _RET_IP_); | 202 | rwsem_release(&kn->dep_map, 1, _RET_IP_); |
@@ -607,7 +613,6 @@ struct kernfs_root *kernfs_create_root(struct kernfs_dir_ops *kdops, void *priv) | |||
607 | 613 | ||
608 | root->dir_ops = kdops; | 614 | root->dir_ops = kdops; |
609 | root->kn = kn; | 615 | root->kn = kn; |
610 | init_waitqueue_head(&root->deactivate_waitq); | ||
611 | 616 | ||
612 | return root; | 617 | return root; |
613 | } | 618 | } |