Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105899
b: refs/heads/master
c: e885dcd
h: refs/heads/master
i:
  105897: a6d20cf
  105895: 5ccf3cb
v: v3
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Jul 25, 2008
1 parent 1d221f7 commit ed387ac
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 856c13aa1ff6136c1968414fdea5938ea9d5ebf2
refs/heads/master: e885dcde75685e09f23cffae1f6d5169c105b8a0
3 changes: 2 additions & 1 deletion trunk/include/linux/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ static inline struct cgroup* task_cgroup(struct task_struct *task,
return task_subsys_state(task, subsys_id)->cgroup;
}

int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss);
int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *ss,
char *nodename);

/* A cgroup_iter should be treated as an opaque object */
struct cgroup_iter {
Expand Down
7 changes: 5 additions & 2 deletions trunk/include/linux/nsproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ static inline void get_nsproxy(struct nsproxy *ns)
}

#ifdef CONFIG_CGROUP_NS
int ns_cgroup_clone(struct task_struct *tsk);
int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid);
#else
static inline int ns_cgroup_clone(struct task_struct *tsk) { return 0; }
static inline int ns_cgroup_clone(struct task_struct *tsk, struct pid *pid)
{
return 0;
}
#endif

#endif
7 changes: 3 additions & 4 deletions trunk/kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2848,16 +2848,17 @@ void cgroup_exit(struct task_struct *tsk, int run_callbacks)
* cgroup_clone - clone the cgroup the given subsystem is attached to
* @tsk: the task to be moved
* @subsys: the given subsystem
* @nodename: the name for the new cgroup
*
* Duplicate the current cgroup in the hierarchy that the given
* subsystem is attached to, and move this task into the new
* child.
*/
int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys)
int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
char *nodename)
{
struct dentry *dentry;
int ret = 0;
char nodename[MAX_CGROUP_TYPE_NAMELEN];
struct cgroup *parent, *child;
struct inode *inode;
struct css_set *cg;
Expand All @@ -2882,8 +2883,6 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys)
cg = tsk->cgroups;
parent = task_cgroup(tsk, subsys->subsys_id);

snprintf(nodename, MAX_CGROUP_TYPE_NAMELEN, "%d", tsk->pid);

/* Pin the hierarchy */
atomic_inc(&parent->root->sb->s_active);

Expand Down
6 changes: 6 additions & 0 deletions trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,12 @@ static struct task_struct *copy_process(unsigned long clone_flags,
if (clone_flags & CLONE_THREAD)
p->tgid = current->tgid;

if (current->nsproxy != p->nsproxy) {
retval = ns_cgroup_clone(p, pid);
if (retval)
goto bad_fork_free_pid;
}

p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
/*
* Clear TID on mm_release()?
Expand Down
8 changes: 6 additions & 2 deletions trunk/kernel/ns_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/module.h>
#include <linux/cgroup.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/nsproxy.h>

Expand All @@ -24,9 +25,12 @@ static inline struct ns_cgroup *cgroup_to_ns(
struct ns_cgroup, css);
}

int ns_cgroup_clone(struct task_struct *task)
int ns_cgroup_clone(struct task_struct *task, struct pid *pid)
{
return cgroup_clone(task, &ns_subsys);
char name[PROC_NUMBUF];

snprintf(name, PROC_NUMBUF, "%d", pid_vnr(pid));
return cgroup_clone(task, &ns_subsys, name);
}

/*
Expand Down
8 changes: 1 addition & 7 deletions trunk/kernel/nsproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk)
goto out;
}

err = ns_cgroup_clone(tsk);
if (err) {
put_nsproxy(new_ns);
goto out;
}

tsk->nsproxy = new_ns;

out:
Expand Down Expand Up @@ -209,7 +203,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
goto out;
}

err = ns_cgroup_clone(current);
err = ns_cgroup_clone(current, task_pid(current));
if (err)
put_nsproxy(*new_nsp);

Expand Down

0 comments on commit ed387ac

Please sign in to comment.