diff options
author | Tejun Heo <tj@kernel.org> | 2014-01-10 08:57:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-10 16:48:08 -0500 |
commit | 99177a34110889a8f2c36420c34e3bcc9bfd8a70 (patch) | |
tree | 53aa8ccc23e3bd92192a8d0518aa4f5f84a634d9 /fs/kernfs/file.c | |
parent | f601f9a2bf7dc1f7ee18feece4c4e2fc6845d6c4 (diff) |
kernfs: remove kernfs_addrm_cxt
kernfs_addrm_cxt and the accompanying kernfs_addrm_start/finish() were
added because there were operations which should be performed outside
kernfs_mutex after adding and removing kernfs_nodes. The necessary
operations were recorded in kernfs_addrm_cxt and performed by
kernfs_addrm_finish(); however, after the recent changes which
relocated deactivation and unmapping so that they're performed
directly during removal, the only operation kernfs_addrm_finish()
performs is kernfs_put(), which can be moved inside the removal path
too.
This patch moves the kernfs_put() of the base ref to __kernfs_remove()
and remove kernfs_addrm_cxt and kernfs_addrm_start/finish().
* kernfs_add_one() is updated to grab and release the parent's active
ref and kernfs_mutex itself. kernfs_get/put_active() and
kernfs_addrm_start/finish() invocations around it are removed from
all users.
* __kernfs_remove() puts an unlinked node directly instead of chaining
it to kernfs_addrm_cxt. Its callers are updated to grab and release
kernfs_mutex instead of calling kernfs_addrm_start/finish() around
it.
v2: Updated to fit the v2 restructuring of removal path.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/kernfs/file.c')
-rw-r--r-- | fs/kernfs/file.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 404ffd2f27bc..ffe1bebf9197 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c | |||
@@ -817,7 +817,6 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent, | |||
817 | bool name_is_static, | 817 | bool name_is_static, |
818 | struct lock_class_key *key) | 818 | struct lock_class_key *key) |
819 | { | 819 | { |
820 | struct kernfs_addrm_cxt acxt; | ||
821 | struct kernfs_node *kn; | 820 | struct kernfs_node *kn; |
822 | unsigned flags; | 821 | unsigned flags; |
823 | int rc; | 822 | int rc; |
@@ -853,14 +852,7 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent, | |||
853 | if (ops->mmap) | 852 | if (ops->mmap) |
854 | kn->flags |= KERNFS_HAS_MMAP; | 853 | kn->flags |= KERNFS_HAS_MMAP; |
855 | 854 | ||
856 | rc = -ENOENT; | 855 | rc = kernfs_add_one(kn, parent); |
857 | if (kernfs_get_active(parent)) { | ||
858 | kernfs_addrm_start(&acxt); | ||
859 | rc = kernfs_add_one(&acxt, kn, parent); | ||
860 | kernfs_addrm_finish(&acxt); | ||
861 | kernfs_put_active(parent); | ||
862 | } | ||
863 | |||
864 | if (rc) { | 856 | if (rc) { |
865 | kernfs_put(kn); | 857 | kernfs_put(kn); |
866 | return ERR_PTR(rc); | 858 | return ERR_PTR(rc); |