diff options
author | Li Zefan <lizefan@huawei.com> | 2014-02-14 03:56:04 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-14 10:52:40 -0500 |
commit | cc045e3952175e84c38dad22dea14465b9fc8fb5 (patch) | |
tree | d331bc8403047232ea13fd6c3951c9ef347b1bac /include/linux/cgroup.h | |
parent | 6534fd6c15858fe4ce4ae568106225e68d5afa81 (diff) |
cgroup: deal with dummp_top in cgroup_name() and cgroup_path()
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>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index ef0b3af0e61c..8c283a910b91 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -487,13 +487,21 @@ struct cgroup_subsys_state *seq_css(struct seq_file *seq); | |||
487 | 487 | ||
488 | static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen) | 488 | static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen) |
489 | { | 489 | { |
490 | return kernfs_name(cgrp->kn, buf, buflen); | 490 | /* dummy_top doesn't have a kn associated */ |
491 | if (cgrp->kn) | ||
492 | return kernfs_name(cgrp->kn, buf, buflen); | ||
493 | else | ||
494 | return strlcpy(buf, "/", buflen); | ||
491 | } | 495 | } |
492 | 496 | ||
493 | static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf, | 497 | static inline char * __must_check cgroup_path(struct cgroup *cgrp, char *buf, |
494 | size_t buflen) | 498 | size_t buflen) |
495 | { | 499 | { |
496 | return kernfs_path(cgrp->kn, buf, buflen); | 500 | /* dummy_top doesn't have a kn associated */ |
501 | if (cgrp->kn) | ||
502 | return kernfs_path(cgrp->kn, buf, buflen); | ||
503 | strlcpy(buf, "/", buflen); | ||
504 | return (buflen <= 2) ? NULL : buf; | ||
497 | } | 505 | } |
498 | 506 | ||
499 | static inline void pr_cont_cgroup_name(struct cgroup *cgrp) | 507 | static inline void pr_cont_cgroup_name(struct cgroup *cgrp) |