Skip to content

Commit

Permalink
cgroup: deal with dummp_top in cgroup_name() and cgroup_path()
Browse files Browse the repository at this point in the history
My kernel fails to boot, because blkcg calls cgroup_path() while
cgroupfs is not mounted.

Fix both cgroup_name() and cgroup_path().

Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Li Zefan authored and Tejun Heo committed Feb 14, 2014
1 parent 6534fd6 commit cc045e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions include/linux/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,21 @@ struct cgroup_subsys_state *seq_css(struct seq_file *seq);

static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
{
return kernfs_name(cgrp->kn, buf, buflen);
/* dummy_top doesn't have a kn associated */
if (cgrp->kn)
return kernfs_name(cgrp->kn, buf, buflen);
else
return strlcpy(buf, "/", buflen);
}

static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf,
size_t buflen)
{
return kernfs_path(cgrp->kn, buf, buflen);
/* dummy_top doesn't have a kn associated */
if (cgrp->kn)
return kernfs_path(cgrp->kn, buf, buflen);
strlcpy(buf, "/", buflen);
return (buflen <= 2) ? NULL : buf;
}

static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
Expand Down

0 comments on commit cc045e3

Please sign in to comment.