Commit ab1c83b9 authored by Pavel Emelyanov's avatar Pavel Emelyanov

file-ids: Fix subnode linkage

The subtree node should be linked with common rbtree procedure. Otherwise
the very first subtree insertion results in an infinite loop in the rb
linking and balancing code.

Plus, mark the root as static and add the subroot node initialization check.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9e47a06c
......@@ -77,7 +77,7 @@ struct fd_id_entry {
} __aligned(sizeof(long));
struct rb_root fd_id_root = RB_ROOT;
static struct rb_root fd_id_root = RB_ROOT;
static unsigned long fd_id_entries_subid = 1;
static struct fd_id_entry *alloc_fd_id_entry(u32 genid, pid_t pid, int fd)
......@@ -98,7 +98,9 @@ static struct fd_id_entry *alloc_fd_id_entry(u32 genid, pid_t pid, int fd)
rb_init_node(&e->node);
rb_init_node(&e->subtree_node);
rb_attach_node(&e->subtree_root, &e->subtree_node);
e->subtree_root = RB_ROOT;
rb_link_and_balance(&e->subtree_root, &e->subtree_node,
NULL, &e->subtree_root.rb_node);
err:
return e;
}
......@@ -112,6 +114,8 @@ lookup_alloc_subtree(struct fd_id_entry *e, u32 genid, pid_t pid, int fd)
struct rb_node **new = &e->subtree_root.rb_node;
struct rb_node *parent = NULL;
BUG_ON(!node);
while (node) {
struct fd_id_entry *this = rb_entry(node, struct fd_id_entry, subtree_node);
int ret = sys_kcmp(this->pid, pid, KCMP_FILE, this->fd, fd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment