[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A68082C.8010604@cn.fujitsu.com>
Date: Thu, 23 Jul 2009 14:50:20 +0800
From: Li Zefan <lizf@...fujitsu.com>
To: Paul Menage <menage@...gle.com>
CC: akpm@...ux-foundation.org, containers@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] Support named cgroups hierarchies
>>> static int cgroup_set_super(struct super_block *sb, void *data)
>>> {
>>> int ret;
>>> - struct cgroupfs_root *root = data;
>>> + struct cgroup_sb_opts *opts = data;
>>> +
>>> + /* If we don't have a new root, we can't set up a new sb */
>>> + if (!opts->new_root)
>>> + return -EINVAL;
>>> +
>> I think this should be BUG_ON(). If set_super() is called,
>> we are allocating a new root, so opts->new_root won't be NULL.
>
> Not true - if you try to mount a hierarchy by name, but with no
> subsystem options, then we don't construct a new root, but we still
> call sget(). If we find a superblock with the right name then we use
> it, else sget() will allocate a new superblock and call
> cgroup_set_super(), at which point we need to fail.
>
Ah, I see.
>>> + struct cgroupfs_root *new_root = cgroup_root_from_opts(&opts);
>> Why not just declare new_root in the beginning of cgroup_get_sb()?
>
> Because it's not needed for the entire scope of the function. Keeping
> its scope as small as possible makes it clearer what it's being used
> for.
>
If we had been doing this, we'll see many:
(no if, while, for)
{
...
}
in kernel code, but I don't remember I ever saw this style.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists