Commit 2a0ff3fb authored by Jeff Liu's avatar Jeff Liu Committed by Tejun Heo

cgroup: warn about mismatching options of a new mount of an existing hierarchy

With the new __DEVEL__sane_behavior mount option was introduced,
if the root cgroup is alive with no xattr function, to mount a
new cgroup with xattr will be rejected in terms of design which
just fine.  However, if the root cgroup does not mounted with
__DEVEL__sane_hehavior, to create a new cgroup with xattr option
will succeed although after that the EA function does not works
as expected but will get ENOTSUPP for setting up attributes under
either cgroup. e.g.

setfattr: /cgroup2/test: Operation not supported

Instead of keeping silence in this case, it's better to drop a log
entry in warning level.  That would be helpful to understand the
reason behind the scene from the user's perspective, and this is
essentially an improvement does not break the backward compatibilities.

With this fix, above mount attemption will keep up works as usual but
the following line cound be found at the system log:

[ ...] cgroup: new mount options do not match the existing superblock

tj: minor formatting / message updates.
Signed-off-by: default avatarJie Liu <jeff.liu@oracle.com>
Reported-by: default avatarAlexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
parent 7805d000
...@@ -1686,11 +1686,14 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1686,11 +1686,14 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
*/ */
cgroup_drop_root(opts.new_root); cgroup_drop_root(opts.new_root);
if (((root->flags | opts.flags) & CGRP_ROOT_SANE_BEHAVIOR) && if (root->flags != opts.flags) {
root->flags != opts.flags) { if ((root->flags | opts.flags) & CGRP_ROOT_SANE_BEHAVIOR) {
pr_err("cgroup: sane_behavior: new mount options should match the existing superblock\n"); pr_err("cgroup: sane_behavior: new mount options should match the existing superblock\n");
ret = -EINVAL; ret = -EINVAL;
goto drop_new_super; goto drop_new_super;
} else {
pr_warning("cgroup: new mount options do not match the existing superblock, will be ignored\n");
}
} }
/* no subsys rebinding, so refcounts don't change */ /* no subsys rebinding, so refcounts don't change */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment