summaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index fc0333fd5676..04c4804cbdef 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -52,8 +52,8 @@ static int proc_match(const char *name, struct proc_dir_entry *de, unsigned int
52 52
53static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir) 53static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir)
54{ 54{
55 return rb_entry_safe(rb_first_cached(&dir->subdir), 55 return rb_entry_safe(rb_first(&dir->subdir), struct proc_dir_entry,
56 struct proc_dir_entry, subdir_node); 56 subdir_node);
57} 57}
58 58
59static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir) 59static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir)
@@ -66,7 +66,7 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
66 const char *name, 66 const char *name,
67 unsigned int len) 67 unsigned int len)
68{ 68{
69 struct rb_node *node = dir->subdir.rb_root.rb_node; 69 struct rb_node *node = dir->subdir.rb_node;
70 70
71 while (node) { 71 while (node) {
72 struct proc_dir_entry *de = rb_entry(node, 72 struct proc_dir_entry *de = rb_entry(node,
@@ -87,9 +87,8 @@ static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
87static bool pde_subdir_insert(struct proc_dir_entry *dir, 87static bool pde_subdir_insert(struct proc_dir_entry *dir,
88 struct proc_dir_entry *de) 88 struct proc_dir_entry *de)
89{ 89{
90 struct rb_root_cached *root = &dir->subdir; 90 struct rb_root *root = &dir->subdir;
91 struct rb_node **new = &root->rb_root.rb_node, *parent = NULL; 91 struct rb_node **new = &root->rb_node, *parent = NULL;
92 bool leftmost = true;
93 92
94 /* Figure out where to put new node */ 93 /* Figure out where to put new node */
95 while (*new) { 94 while (*new) {
@@ -101,16 +100,15 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,
101 parent = *new; 100 parent = *new;
102 if (result < 0) 101 if (result < 0)
103 new = &(*new)->rb_left; 102 new = &(*new)->rb_left;
104 else if (result > 0) { 103 else if (result > 0)
105 new = &(*new)->rb_right; 104 new = &(*new)->rb_right;
106 leftmost = false; 105 else
107 } else
108 return false; 106 return false;
109 } 107 }
110 108
111 /* Add new node and rebalance tree. */ 109 /* Add new node and rebalance tree. */
112 rb_link_node(&de->subdir_node, parent, new); 110 rb_link_node(&de->subdir_node, parent, new);
113 rb_insert_color_cached(&de->subdir_node, root, leftmost); 111 rb_insert_color(&de->subdir_node, root);
114 return true; 112 return true;
115} 113}
116 114
@@ -401,7 +399,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
401 ent->namelen = qstr.len; 399 ent->namelen = qstr.len;
402 ent->mode = mode; 400 ent->mode = mode;
403 ent->nlink = nlink; 401 ent->nlink = nlink;
404 ent->subdir = RB_ROOT_CACHED; 402 ent->subdir = RB_ROOT;
405 refcount_set(&ent->refcnt, 1); 403 refcount_set(&ent->refcnt, 1);
406 spin_lock_init(&ent->pde_unload_lock); 404 spin_lock_init(&ent->pde_unload_lock);
407 INIT_LIST_HEAD(&ent->pde_openers); 405 INIT_LIST_HEAD(&ent->pde_openers);
@@ -577,7 +575,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
577 575
578 de = pde_subdir_find(parent, fn, len); 576 de = pde_subdir_find(parent, fn, len);
579 if (de) 577 if (de)
580 rb_erase_cached(&de->subdir_node, &parent->subdir); 578 rb_erase(&de->subdir_node, &parent->subdir);
581 write_unlock(&proc_subdir_lock); 579 write_unlock(&proc_subdir_lock);
582 if (!de) { 580 if (!de) {
583 WARN(1, "name '%s'\n", name); 581 WARN(1, "name '%s'\n", name);
@@ -614,13 +612,13 @@ int remove_proc_subtree(const char *name, struct proc_dir_entry *parent)
614 write_unlock(&proc_subdir_lock); 612 write_unlock(&proc_subdir_lock);
615 return -ENOENT; 613 return -ENOENT;
616 } 614 }
617 rb_erase_cached(&root->subdir_node, &parent->subdir); 615 rb_erase(&root->subdir_node, &parent->subdir);
618 616
619 de = root; 617 de = root;
620 while (1) { 618 while (1) {
621 next = pde_subdir_first(de); 619 next = pde_subdir_first(de);
622 if (next) { 620 if (next) {
623 rb_erase_cached(&next->subdir_node, &de->subdir); 621 rb_erase(&next->subdir_node, &de->subdir);
624 de = next; 622 de = next;
625 continue; 623 continue;
626 } 624 }