[RESEND,v1,20/55] pid: Add ns::pid::rb_root

Submitted by Kirill Tkhai on March 24, 2017, 3:12 p.m.

Details

Message ID 149036833304.23093.3607738229097789412.stgit@localhost.localdomain
State New
Series "Nested pid namespaces support"
Headers show

Commit Message

Kirill Tkhai March 24, 2017, 3:12 p.m.
Add a per-ns rb tree to link pids. Should replace global pid_root_rb.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/include/namespaces.h |    3 +++
 criu/namespaces.c         |    3 +++
 2 files changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index f638d12c..50727513 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -119,6 +119,9 @@  struct ns_id {
 			UsernsEntry *e;
 			int nsfd_id;
 		} user;
+		struct {
+			struct rb_root rb_root;
+		} pid;
 	};
 };
 extern struct ns_id *ns_ids;
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 925805ca..da0b07d2 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -309,6 +309,8 @@  struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid,
 		nsid->ns_populated = false;
 		INIT_LIST_HEAD(&nsid->children);
 		INIT_LIST_HEAD(&nsid->siblings);
+		if (nd == &pid_ns_desc)
+			nsid->pid.rb_root = RB_ROOT;
 	}
 
 	return nsid;
@@ -431,6 +433,7 @@  static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd
 	nsid_add(nsid, nd, ns_next_id++, pid);
 
 	if (nd == &pid_ns_desc) {
+		nsid->pid.rb_root = RB_ROOT;
 		if (type == NS_ROOT || (type == NS_CRIU && !top_pid_ns))
 			top_pid_ns = nsid;
 	}