Kyle McMartin e2302e
From: Greg KH <gregkh@suse.de>
Kyle McMartin e2302e
Date: Thu, 5 Aug 2010 20:53:35 +0000 (-0700)
Kyle McMartin e2302e
Subject: cgroupfs: create /sys/fs/cgroup to mount cgroupfs on
Kyle McMartin e2302e
X-Git-Tag: v2.6.36-rc1~521^2~7
Kyle McMartin e2302e
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=676db4af043014e852f67ba0349dae0071bd11f3
Kyle McMartin e2302e
Kyle McMartin e2302e
cgroupfs: create /sys/fs/cgroup to mount cgroupfs on
Kyle McMartin e2302e
Kyle McMartin e2302e
We really shouldn't be asking userspace to create new root filesystems.
Kyle McMartin e2302e
So follow along with all of the other in-kernel filesystems, and provide
Kyle McMartin e2302e
a mount point in sysfs.
Kyle McMartin e2302e
Kyle McMartin e2302e
For cgroupfs, this should be in /sys/fs/cgroup/  This change provides
Kyle McMartin e2302e
that mount point when the cgroup filesystem is registered in the kernel.
Kyle McMartin e2302e
Kyle McMartin e2302e
Acked-by: Paul Menage <menage@google.com>
Kyle McMartin e2302e
Acked-by: Dhaval Giani <dhaval.giani@gmail.com>
Kyle McMartin e2302e
Cc: Li Zefan <lizf@cn.fujitsu.com>
Kyle McMartin e2302e
Cc: Lennart Poettering <lennart@poettering.net>
Kyle McMartin e2302e
Cc: Kay Sievers <kay.sievers@vrfy.org>
Kyle McMartin e2302e
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Kyle McMartin e2302e
---
Kyle McMartin e2302e
Kyle McMartin e2302e
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
Kyle McMartin e2302e
index a8ce099..d83cab0 100644
Kyle McMartin e2302e
--- a/kernel/cgroup.c
Kyle McMartin e2302e
+++ b/kernel/cgroup.c
Kyle McMartin e2302e
@@ -1623,6 +1623,8 @@ static struct file_system_type cgroup_fs_type = {
Kyle McMartin e2302e
 	.kill_sb = cgroup_kill_sb,
Kyle McMartin e2302e
 };
Kyle McMartin e2302e
 
Kyle McMartin e2302e
+static struct kobject *cgroup_kobj;
Kyle McMartin e2302e
+
Kyle McMartin e2302e
 static inline struct cgroup *__d_cgrp(struct dentry *dentry)
Kyle McMartin e2302e
 {
Kyle McMartin e2302e
 	return dentry->d_fsdata;
Kyle McMartin e2302e
@@ -3894,9 +3896,18 @@ int __init cgroup_init(void)
Kyle McMartin e2302e
 	hhead = css_set_hash(init_css_set.subsys);
Kyle McMartin e2302e
 	hlist_add_head(&init_css_set.hlist, hhead);
Kyle McMartin e2302e
 	BUG_ON(!init_root_id(&rootnode));
Kyle McMartin e2302e
+
Kyle McMartin e2302e
+	cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
Kyle McMartin e2302e
+	if (!cgroup_kobj) {
Kyle McMartin e2302e
+		err = -ENOMEM;
Kyle McMartin e2302e
+		goto out;
Kyle McMartin e2302e
+	}
Kyle McMartin e2302e
+
Kyle McMartin e2302e
 	err = register_filesystem(&cgroup_fs_type);
Kyle McMartin e2302e
-	if (err < 0)
Kyle McMartin e2302e
+	if (err < 0) {
Kyle McMartin e2302e
+		kobject_put(cgroup_kobj);
Kyle McMartin e2302e
 		goto out;
Kyle McMartin e2302e
+	}
Kyle McMartin e2302e
 
Kyle McMartin e2302e
 	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
Kyle McMartin e2302e