Linux Container Development
 help / color / mirror / Atom feed
From: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
To: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Linux Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Balbir Singh
	<balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Subject: [PATCH] cgroups: handle failure of cgroup_populate_dir() at mount/remount
Date: Fri, 22 May 2009 11:00:12 +0800	[thread overview]
Message-ID: <4A16153C.2080004@cn.fujitsu.com> (raw)

Now we have 'stat' file in both memory and cpuacct subsystems. If we
mount these 2 subsystems with option 'noprefix', the creation of 'stat'
file for cpuacct will fail, but without any notificatin to the user.

With this patch, we fail the mount/remount in this case.

Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 kernel/cgroup.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index a7267bf..eab83f7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -896,6 +896,7 @@ static int parse_cgroupfs_options(char *data,
 static int cgroup_remount(struct super_block *sb, int *flags, char *data)
 {
 	int ret = 0;
+	unsigned long subsys_bits;
 	struct cgroupfs_root *root = sb->s_fs_info;
 	struct cgroup *cgrp = &root->top_cgroup;
 	struct cgroup_sb_opts opts;
@@ -914,12 +915,17 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
 		goto out_unlock;
 	}
 
+	subsys_bits = root->subsys_bits;
 	ret = rebind_subsystems(root, opts.subsys_bits);
 	if (ret)
 		goto out_unlock;
 
 	/* (re)populate subsystem files */
-	cgroup_populate_dir(cgrp);
+	ret = cgroup_populate_dir(cgrp);
+	if (ret) {
+		rebind_subsystems(root, subsys_bits);
+		goto out_unlock;
+	}
 
 	if (opts.release_agent)
 		strcpy(root->release_agent_path, opts.release_agent);
@@ -1122,9 +1128,13 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
 		BUG_ON(!list_empty(&root_cgrp->children));
 		BUG_ON(root->number_of_cgroups != 1);
 
-		cgroup_populate_dir(root_cgrp);
+		ret = cgroup_populate_dir(root_cgrp);
+
 		mutex_unlock(&inode->i_mutex);
 		mutex_unlock(&cgroup_mutex);
+
+		if (ret)
+			goto drop_new_super;
 	}
 
 	simple_set_mnt(mnt, sb);
@@ -1803,6 +1813,10 @@ int cgroup_add_file(struct cgroup *cgrp,
 		dput(dentry);
 	} else
 		error = PTR_ERR(dentry);
+
+	if (error)
+		printk(KERN_WARNING "cgroup: Failed to create file '%s': %d\n",
+		       name, error);
 	return error;
 }
 
-- 
1.5.4.rc3

             reply	other threads:[~2009-05-22  3:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-22  3:00 Li Zefan [this message]
     [not found] ` <4A16153C.2080004-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-05-22  8:25   ` [PATCH] cgroups: handle failure of cgroup_populate_dir() at mount/remount KAMEZAWA Hiroyuki
2009-05-25 13:17   ` Balbir Singh
     [not found] ` <20090522172545.1e5e5f81.kamezawa.hiroyu@jp.fujitsu.com>
     [not found]   ` <4A1663C2.4080401@cn.fujitsu.com>
     [not found]     ` <4A1663C2.4080401-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-05-22  8:34       ` KAMEZAWA Hiroyuki
     [not found]     ` <20090522173421.ecacb40e.kamezawa.hiroyu@jp.fujitsu.com>
     [not found]       ` <20090522173421.ecacb40e.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-05-22  9:10         ` Dhaval Giani
     [not found]       ` <20090522091034.GC8696@linux.vnet.ibm.com>
     [not found]         ` <20090522091034.GC8696-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2009-05-25  9:14           ` Li Zefan
     [not found]         ` <4A1A6192.6050608@cn.fujitsu.com>
     [not found]           ` <4A1A6192.6050608-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-05-25  9:47             ` Dhaval Giani
     [not found]   ` <20090522172545.1e5e5f81.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-05-22  8:35     ` Li Zefan
2009-05-26 22:06     ` Paul Menage
     [not found]   ` <6599ad830905261506x480f2167naf1034177bbc7036@mail.gmail.com>
     [not found]     ` <6599ad830905261506x480f2167naf1034177bbc7036-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-05-27  1:07       ` Li Zefan
     [not found]     ` <4A1C9253.3060108@cn.fujitsu.com>
     [not found]       ` <4A1C9253.3060108-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-05-27  1:34         ` KAMEZAWA Hiroyuki
     [not found]       ` <20090527103404.81d3c1a4.kamezawa.hiroyu@jp.fujitsu.com>
     [not found]         ` <20090527103404.81d3c1a4.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2009-05-27  3:24           ` Li Zefan
     [not found]         ` <4A1CB266.8000400@cn.fujitsu.com>
     [not found]           ` <4A1CB266.8000400-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-05-27  6:16             ` KAMEZAWA Hiroyuki
     [not found] ` <20090525131753.GL4858@balbir.in.ibm.com>
     [not found]   ` <20090525131753.GL4858-SINUvgVNF2CyUtPGxGje5AC/G2K4zDHf@public.gmane.org>
2009-05-26  1:24     ` Li Zefan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A16153C.2080004@cn.fujitsu.com \
    --to=lizf-bthxqxjhjhxqfuhtdcdx3a@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox