linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] cgroup: don't destroy the default root
@ 2014-06-03  4:04 Li Zefan
  2014-06-03  4:05 ` [PATCH 2/3] cgroup: make the default root invisible when it's umounted Li Zefan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Li Zefan @ 2014-06-03  4:04 UTC (permalink / raw)
  To: Tejun Heo; +Cc: LKML, Cgroups

The default root is allocated and initialized at boot, so we
shouldn't destroy the default root when it's umounted, otherwise
it will lead to disaster.

Signed-off-by: Li Zefan <lizefan@huawei.com>
---
 kernel/cgroup.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a5f75ac..f73fe48 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1027,12 +1027,14 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
 static void cgroup_get(struct cgroup *cgrp)
 {
 	WARN_ON_ONCE(cgroup_is_dead(cgrp));
-	css_get(&cgrp->self);
+	if (!(cgrp->self.flags & CSS_NO_REF))
+		css_get(&cgrp->self);
 }
 
 static void cgroup_put(struct cgroup *cgrp)
 {
-	css_put(&cgrp->self);
+	if (!(cgrp->self.flags & CSS_NO_REF))
+		css_put(&cgrp->self);
 }
 
 /**
@@ -1781,10 +1783,12 @@ static void cgroup_kill_sb(struct super_block *sb)
 	 * This prevents new mounts by disabling percpu_ref_tryget_live().
 	 * cgroup_mount() may wait for @root's release.
 	 */
-	if (css_has_online_children(&root->cgrp.self))
+	if (css_has_online_children(&root->cgrp.self)) {
 		cgroup_put(&root->cgrp);
-	else
-		percpu_ref_kill(&root->cgrp.self.refcnt);
+	} else {
+		if (root != &cgrp_dfl_root)
+			percpu_ref_kill(&root->cgrp.self.refcnt);
+	}
 
 	kernfs_kill_sb(sb);
 }
-- 
1.8.0.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-05  1:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-03  4:04 [PATCH 1/3] cgroup: don't destroy the default root Li Zefan
2014-06-03  4:05 ` [PATCH 2/3] cgroup: make the default root invisible when it's umounted Li Zefan
2014-06-03 13:01   ` Tejun Heo
2014-06-04  8:59     ` Li Zefan
2014-06-05  1:20       ` Tejun Heo
2014-06-05  1:49         ` Li Zefan
2014-06-03  4:05 ` [PATCH 3/3] cgroup: set visible flag only after we've mounted the default root Li Zefan
2014-06-03 13:02   ` Tejun Heo
2014-06-03 12:57 ` [PATCH 1/3] cgroup: don't destroy " Tejun Heo
2014-06-04  8:40   ` Li Zefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).