* [PATCH] cgroup: remove redundant variable in cgroup_mount()
@ 2014-09-20 6:49 Zefan Li
[not found] ` <541D2366.2020107-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Zefan Li @ 2014-09-20 6:49 UTC (permalink / raw)
To: Tejun Heo; +Cc: Cgroups, LKML
Both pinned_sb and new_sb indicate if a new superblock is needed,
so we can just remove new_sb.
Note now we must check if kernfs_tryget_sb() returns NULL, because
when it returns NULL, kernfs_mount() may still re-use an existing
superblock, which is just allocated by another concurent mount.
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
---
Hi Tejun,
I think you wanted to see the @new_sb argument removed from kernfs_mount(),
but it's also used in debugfs and we can't use kernfs_tryget_sb() to
replace the new_sb check.
---
kernel/cgroup.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 33f15b3..15a2387 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1694,7 +1694,6 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
struct dentry *dentry;
int ret;
int i;
- bool new_sb;
/*
* The first time anyone tries to mount a cgroup, enable the list
@@ -1785,7 +1784,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
* path is super cold. Let's just sleep a bit and retry.
*/
pinned_sb = kernfs_pin_sb(root->kf_root, NULL);
- if (IS_ERR(pinned_sb) ||
+ if (IS_ERR_OR_NULL(pinned_sb) ||
!percpu_ref_tryget_live(&root->cgrp.self.refcnt)) {
mutex_unlock(&cgroup_mutex);
if (!IS_ERR_OR_NULL(pinned_sb))
@@ -1831,18 +1830,16 @@ out_free:
return ERR_PTR(ret);
dentry = kernfs_mount(fs_type, flags, root->kf_root,
- CGROUP_SUPER_MAGIC, &new_sb);
- if (IS_ERR(dentry) || !new_sb)
+ CGROUP_SUPER_MAGIC, NULL);
+ if (IS_ERR(dentry) || pinned_sb)
cgroup_put(&root->cgrp);
/*
* If @pinned_sb, we're reusing an existing root and holding an
* extra ref on its sb. Mount is complete. Put the extra ref.
*/
- if (pinned_sb) {
- WARN_ON(new_sb);
+ if (pinned_sb)
deactivate_super(pinned_sb);
- }
return dentry;
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cgroup: remove redundant variable in cgroup_mount()
[not found] ` <541D2366.2020107-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2014-09-20 17:12 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2014-09-20 17:12 UTC (permalink / raw)
To: Zefan Li; +Cc: Cgroups, LKML
Hello, Li.
On Sat, Sep 20, 2014 at 02:49:10PM +0800, Zefan Li wrote:
> Both pinned_sb and new_sb indicate if a new superblock is needed,
> so we can just remove new_sb.
>
> Note now we must check if kernfs_tryget_sb() returns NULL, because
> when it returns NULL, kernfs_mount() may still re-use an existing
> superblock, which is just allocated by another concurent mount.
>
> Suggested-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Ah, this is so much better. Thanks for doing this. Applied to
cgroup/for-3.18.
> ---
>
> Hi Tejun,
>
> I think you wanted to see the @new_sb argument removed from kernfs_mount(),
> but it's also used in debugfs and we can't use kernfs_tryget_sb() to
> replace the new_sb check.
Bummer, someday. :)
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-20 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-20 6:49 [PATCH] cgroup: remove redundant variable in cgroup_mount() Zefan Li
[not found] ` <541D2366.2020107-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-09-20 17:12 ` Tejun Heo
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).