aboutsummaryrefslogtreecommitdiffstats
path: root/fs/kernfs
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-13 17:27:16 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-13 17:27:16 -0500
commit55f6e30d0a6a8975cc0831e8a4a3715b815b6a2f (patch)
tree0316cdf73f1d42a386563dca5e9ff73f296d6ec4 /fs/kernfs
parent7653fe9d6cddc3fc5e4220608079006d8ac0054c (diff)
Revert "kernfs: invoke kernfs_unmap_bin_file() directly from __kernfs_remove()"
This reverts commit f601f9a2bf7dc1f7ee18feece4c4e2fc6845d6c4. 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')
-rw-r--r--fs/kernfs/dir.c42
-rw-r--r--fs/kernfs/file.c5
-rw-r--r--fs/kernfs/kernfs-internal.h2
3 files changed, 14 insertions, 35 deletions
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index f878e4f2efe7..e565ec096ae9 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -121,17 +121,13 @@ static int kernfs_link_sibling(struct kernfs_node *kn)
121 * Locking: 121 * Locking:
122 * mutex_lock(kernfs_mutex) 122 * mutex_lock(kernfs_mutex)
123 */ 123 */
124static bool kernfs_unlink_sibling(struct kernfs_node *kn) 124static void kernfs_unlink_sibling(struct kernfs_node *kn)
125{ 125{
126 if (RB_EMPTY_NODE(&kn->rb))
127 return false;
128
129 if (kernfs_type(kn) == KERNFS_DIR) 126 if (kernfs_type(kn) == KERNFS_DIR)
130 kn->parent->dir.subdirs--; 127 kn->parent->dir.subdirs--;
131 128
132 rb_erase(&kn->rb, &kn->parent->dir.children); 129 rb_erase(&kn->rb, &kn->parent->dir.children);
133 RB_CLEAR_NODE(&kn->rb); 130 RB_CLEAR_NODE(&kn->rb);
134 return true;
135} 131}
136 132
137/** 133/**
@@ -500,6 +496,7 @@ void kernfs_addrm_finish(struct kernfs_addrm_cxt *acxt)
500 496
501 acxt->removed = kn->u.removed_list; 497 acxt->removed = kn->u.removed_list;
502 498
499 kernfs_unmap_bin_file(kn);
503 kernfs_put(kn); 500 kernfs_put(kn);
504 } 501 }
505} 502}
@@ -857,44 +854,23 @@ static void __kernfs_remove(struct kernfs_addrm_cxt *acxt,
857 854
858 /* unlink the subtree node-by-node */ 855 /* unlink the subtree node-by-node */
859 do { 856 do {
860 pos = kernfs_leftmost_descendant(kn); 857 struct kernfs_iattrs *ps_iattr;
861
862 /*
863 * We're gonna release kernfs_mutex to unmap bin files,
864 * Make sure @pos doesn't go away inbetween.
865 */
866 kernfs_get(pos);
867 858
868 /* 859 pos = kernfs_leftmost_descendant(kn);
869 * This must be come before unlinking; otherwise, when
870 * there are multiple removers, some may finish before
871 * unmapping is complete.
872 */
873 if (pos->flags & KERNFS_HAS_MMAP) {
874 mutex_unlock(&kernfs_mutex);
875 kernfs_unmap_file(pos);
876 mutex_lock(&kernfs_mutex);
877 }
878 860
879 /* 861 if (pos->parent) {
880 * kernfs_unlink_sibling() succeeds once per node. Use it 862 kernfs_unlink_sibling(pos);
881 * to decide who's responsible for cleanups.
882 */
883 if (!pos->parent || kernfs_unlink_sibling(pos)) {
884 struct kernfs_iattrs *ps_iattr =
885 pos->parent ? pos->parent->iattr : NULL;
886 863
887 /* update timestamps on the parent */ 864 /* update timestamps on the parent */
865 ps_iattr = pos->parent->iattr;
888 if (ps_iattr) { 866 if (ps_iattr) {
889 ps_iattr->ia_iattr.ia_ctime = CURRENT_TIME; 867 ps_iattr->ia_iattr.ia_ctime = CURRENT_TIME;
890 ps_iattr->ia_iattr.ia_mtime = CURRENT_TIME; 868 ps_iattr->ia_iattr.ia_mtime = CURRENT_TIME;
891 } 869 }
892
893 pos->u.removed_list = acxt->removed;
894 acxt->removed = pos;
895 } 870 }
896 871
897 kernfs_put(pos); 872 pos->u.removed_list = acxt->removed;
873 acxt->removed = pos;
898 } while (pos != kn); 874 } while (pos != kn);
899} 875}
900 876
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 404ffd2f27bc..231a171f48b6 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -700,11 +700,14 @@ static int kernfs_fop_release(struct inode *inode, struct file *filp)
700 return 0; 700 return 0;
701} 701}
702 702
703void kernfs_unmap_file(struct kernfs_node *kn) 703void kernfs_unmap_bin_file(struct kernfs_node *kn)
704{ 704{
705 struct kernfs_open_node *on; 705 struct kernfs_open_node *on;
706 struct kernfs_open_file *of; 706 struct kernfs_open_file *of;
707 707
708 if (!(kn->flags & KERNFS_HAS_MMAP))
709 return;
710
708 spin_lock_irq(&kernfs_open_node_lock); 711 spin_lock_irq(&kernfs_open_node_lock);
709 on = kn->attr.open; 712 on = kn->attr.open;
710 if (on) 713 if (on)
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index e9ec38c86074..57a93f4d645c 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -113,7 +113,7 @@ struct kernfs_node *kernfs_new_node(struct kernfs_root *root, const char *name,
113 */ 113 */
114extern const struct file_operations kernfs_file_fops; 114extern const struct file_operations kernfs_file_fops;
115 115
116void kernfs_unmap_file(struct kernfs_node *kn); 116void kernfs_unmap_bin_file(struct kernfs_node *kn);
117 117
118/* 118/*
119 * symlink.c 119 * symlink.c