File cgconfig-Do-not-overwrite-defaultcgroup-configuratio.patch of Package libcgroup.428

From 1f56fee18da3d7b1039eea10cc5f6a01026f089b Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.cz>
Date: Mon, 12 Jan 2015 15:47:08 +0100
Subject: [PATCH] cgconfig: Do not overwrite defaultcgroup configuration

cpuset controller doesn't accept any tasks until cpuset.cpus and
cpuset.mems are configured. cgconfig init script tries to create
and configure defaultcgroup when enabled but it doesn't check whether
the defaultcgroup already exists and it is configured from
/etc/cgconfig.conf and happily overwrites the configuration. This is
clearly wrong. Fix this simply by checking both knobs and inherit the
value from root only when uninitialized.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 scripts/init.d/cgconfig.in | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in
index f299d0ff3f73..45b370266f0c 100644
--- a/scripts/init.d/cgconfig.in
+++ b/scripts/init.d/cgconfig.in
@@ -78,13 +78,21 @@ create_default_groups() {
         cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null
 
         #
-        # special rule for cpusets
+        # cpusets need cpus and mems to initialized which is not the case
+        # for the freshly created groups. Inherit values from / if the
+        # defaultcgroup is not initialized
         #
         if echo $controllers | grep -q -w cpuset; then
-                cpus=`cgget -nv -r cpuset.cpus /`
-                cgset -r cpuset.cpus=$cpus $defaultcgroup
-                mems=`cgget -nv -r cpuset.mems /`
-                cgset -r cpuset.mems=$mems $defaultcgroup
+		if [ -z "`cgget -nv -r cpuset.cpus $defaultcgroup`" ]
+		then
+			cpus=`cgget -nv -r cpuset.cpus /`
+			cgset -r cpuset.cpus=$cpus $defaultcgroup
+		fi
+		if [ -z "`cgget -nv -r cpuset.mems $defaultcgroup`" ]
+		then
+			mems=`cgget -nv -r cpuset.mems /`
+			cgset -r cpuset.mems=$mems $defaultcgroup
+		fi
         fi
 
         #
-- 
2.1.4
openSUSE Build Service is sponsored by