diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-03 14:02:57 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 18:42:40 -0500 |
commit | ccf02aaf8167bb8bfb3c17c01c843d309b872671 (patch) | |
tree | 744c59c27e0883dca4da631118432a8df86ce894 /fs | |
parent | 35beab0635f3cdd475e3c11a304b866c25b76fcf (diff) |
kernfs: invoke kernfs_unmap_bin_file() directly from kernfs_deactivate()
kernfs_unmap_bin_file() is supposed to unmap all memory mappings of
the target file before kernfs_remove() finishes; however, it currently
is being called from kernfs_addrm_finish() and has the same race
problem as the original implementation of deactivation when there are
multiple removers - only the remover which snatches the node to its
addrm_cxt->removed list is guaranteed to wait for its completion
before returning.
It can be easily fixed by moving kernfs_unmap_bin_file() invocation
from kernfs_addrm_finish() to kernfs_deactivated(). The function may
be called multiple times but that shouldn't do any harm.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/kernfs/dir.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 3ac93737174a..9603c06550a0 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c | |||
@@ -177,9 +177,10 @@ void kernfs_put_active(struct kernfs_node *kn) | |||
177 | * kernfs_deactivate - deactivate kernfs_node | 177 | * kernfs_deactivate - deactivate kernfs_node |
178 | * @kn: kernfs_node to deactivate | 178 | * @kn: kernfs_node to deactivate |
179 | * | 179 | * |
180 | * Deny new active references and drain existing ones. Mutiple | 180 | * Deny new active references, drain existing ones and nuke all |
181 | * removers may invoke this function concurrently on @kn and all will | 181 | * existing mmaps. Mutiple removers may invoke this function |
182 | * return after deactivation and draining are complete. | 182 | * concurrently on @kn and all will return after deactivation and |
183 | * draining are complete. | ||
183 | */ | 184 | */ |
184 | static void kernfs_deactivate(struct kernfs_node *kn) | 185 | static void kernfs_deactivate(struct kernfs_node *kn) |
185 | __releases(&kernfs_mutex) __acquires(&kernfs_mutex) | 186 | __releases(&kernfs_mutex) __acquires(&kernfs_mutex) |
@@ -213,6 +214,8 @@ static void kernfs_deactivate(struct kernfs_node *kn) | |||
213 | rwsem_release(&kn->dep_map, 1, _RET_IP_); | 214 | rwsem_release(&kn->dep_map, 1, _RET_IP_); |
214 | } | 215 | } |
215 | 216 | ||
217 | kernfs_unmap_bin_file(kn); | ||
218 | |||
216 | mutex_lock(&kernfs_mutex); | 219 | mutex_lock(&kernfs_mutex); |
217 | } | 220 | } |
218 | 221 | ||
@@ -493,7 +496,6 @@ void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt) | |||
493 | 496 | ||
494 | acxt->removed = kn->u.removed_list; | 497 | acxt->removed = kn->u.removed_list; |
495 | 498 | ||
496 | kernfs_unmap_bin_file(kn); | ||
497 | kernfs_put(kn); | 499 | kernfs_put(kn); |
498 | } | 500 | } |
499 | } | 501 | } |