diff options
author | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:55 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:55 -0400 |
commit | db0416b64977cb0f382175608286cc80c7573e38 (patch) | |
tree | a244be0b7e7467ed89c390997aec6b176de71140 /kernel/cgroup.c | |
parent | 6bc103498f5fe512928496fc7802d639cc2d1d20 (diff) |
cgroup: remove cgroup_add_file[s]()
No controller is using cgroup_add_files[s](). Unexport them, and
convert cgroup_add_files() to handle NULL entry terminated array
instead of taking count explicitly and continue creation on failure
for internal use.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 835ae29e4ea2..fb71a930ec8d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2615,9 +2615,8 @@ static umode_t cgroup_file_mode(const struct cftype *cft) | |||
2615 | return mode; | 2615 | return mode; |
2616 | } | 2616 | } |
2617 | 2617 | ||
2618 | int cgroup_add_file(struct cgroup *cgrp, | 2618 | static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys, |
2619 | struct cgroup_subsys *subsys, | 2619 | const struct cftype *cft) |
2620 | const struct cftype *cft) | ||
2621 | { | 2620 | { |
2622 | struct dentry *dir = cgrp->dentry; | 2621 | struct dentry *dir = cgrp->dentry; |
2623 | struct dentry *dentry; | 2622 | struct dentry *dentry; |
@@ -2649,22 +2648,23 @@ int cgroup_add_file(struct cgroup *cgrp, | |||
2649 | error = PTR_ERR(dentry); | 2648 | error = PTR_ERR(dentry); |
2650 | return error; | 2649 | return error; |
2651 | } | 2650 | } |
2652 | EXPORT_SYMBOL_GPL(cgroup_add_file); | ||
2653 | 2651 | ||
2654 | int cgroup_add_files(struct cgroup *cgrp, | 2652 | static int cgroup_add_files(struct cgroup *cgrp, struct cgroup_subsys *subsys, |
2655 | struct cgroup_subsys *subsys, | 2653 | const struct cftype cfts[]) |
2656 | const struct cftype cft[], | ||
2657 | int count) | ||
2658 | { | 2654 | { |
2659 | int i, err; | 2655 | const struct cftype *cft; |
2660 | for (i = 0; i < count; i++) { | 2656 | int err, ret = 0; |
2661 | err = cgroup_add_file(cgrp, subsys, &cft[i]); | 2657 | |
2662 | if (err) | 2658 | for (cft = cfts; cft->name[0] != '\0'; cft++) { |
2663 | return err; | 2659 | err = cgroup_add_file(cgrp, subsys, cft); |
2660 | if (err) { | ||
2661 | pr_warning("cgroup_add_files: failed to create %s, err=%d\n", | ||
2662 | cft->name, err); | ||
2663 | ret = err; | ||
2664 | } | ||
2664 | } | 2665 | } |
2665 | return 0; | 2666 | return ret; |
2666 | } | 2667 | } |
2667 | EXPORT_SYMBOL_GPL(cgroup_add_files); | ||
2668 | 2668 | ||
2669 | static DEFINE_MUTEX(cgroup_cft_mutex); | 2669 | static DEFINE_MUTEX(cgroup_cft_mutex); |
2670 | 2670 | ||
@@ -2688,10 +2688,6 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss, | |||
2688 | { | 2688 | { |
2689 | LIST_HEAD(pending); | 2689 | LIST_HEAD(pending); |
2690 | struct cgroup *cgrp, *n; | 2690 | struct cgroup *cgrp, *n; |
2691 | int count = 0; | ||
2692 | |||
2693 | while (cfts[count].name[0] != '\0') | ||
2694 | count++; | ||
2695 | 2691 | ||
2696 | /* %NULL @cfts indicates abort and don't bother if @ss isn't attached */ | 2692 | /* %NULL @cfts indicates abort and don't bother if @ss isn't attached */ |
2697 | if (cfts && ss->root != &rootnode) { | 2693 | if (cfts && ss->root != &rootnode) { |
@@ -2713,7 +2709,7 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss, | |||
2713 | mutex_lock(&inode->i_mutex); | 2709 | mutex_lock(&inode->i_mutex); |
2714 | mutex_lock(&cgroup_mutex); | 2710 | mutex_lock(&cgroup_mutex); |
2715 | if (!cgroup_is_removed(cgrp)) | 2711 | if (!cgroup_is_removed(cgrp)) |
2716 | cgroup_add_files(cgrp, ss, cfts, count); | 2712 | cgroup_add_files(cgrp, ss, cfts); |
2717 | mutex_unlock(&cgroup_mutex); | 2713 | mutex_unlock(&cgroup_mutex); |
2718 | mutex_unlock(&inode->i_mutex); | 2714 | mutex_unlock(&inode->i_mutex); |
2719 | 2715 | ||
@@ -3739,6 +3735,7 @@ static struct cftype files[] = { | |||
3739 | .write_string = cgroup_release_agent_write, | 3735 | .write_string = cgroup_release_agent_write, |
3740 | .max_write_len = PATH_MAX, | 3736 | .max_write_len = PATH_MAX, |
3741 | }, | 3737 | }, |
3738 | { } /* terminate */ | ||
3742 | }; | 3739 | }; |
3743 | 3740 | ||
3744 | static int cgroup_populate_dir(struct cgroup *cgrp) | 3741 | static int cgroup_populate_dir(struct cgroup *cgrp) |
@@ -3746,7 +3743,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp) | |||
3746 | int err; | 3743 | int err; |
3747 | struct cgroup_subsys *ss; | 3744 | struct cgroup_subsys *ss; |
3748 | 3745 | ||
3749 | err = cgroup_add_files(cgrp, NULL, files, ARRAY_SIZE(files)); | 3746 | err = cgroup_add_files(cgrp, NULL, files); |
3750 | if (err < 0) | 3747 | if (err < 0) |
3751 | return err; | 3748 | return err; |
3752 | 3749 | ||
@@ -3757,16 +3754,8 @@ static int cgroup_populate_dir(struct cgroup *cgrp) | |||
3757 | if (ss->populate && (err = ss->populate(ss, cgrp)) < 0) | 3754 | if (ss->populate && (err = ss->populate(ss, cgrp)) < 0) |
3758 | return err; | 3755 | return err; |
3759 | 3756 | ||
3760 | list_for_each_entry(set, &ss->cftsets, node) { | 3757 | list_for_each_entry(set, &ss->cftsets, node) |
3761 | const struct cftype *cft; | 3758 | cgroup_add_files(cgrp, ss, set->cfts); |
3762 | |||
3763 | for (cft = set->cfts; cft->name[0] != '\0'; cft++) { | ||
3764 | err = cgroup_add_file(cgrp, ss, cft); | ||
3765 | if (err) | ||
3766 | pr_warning("cgroup_populate_dir: failed to create %s, err=%d\n", | ||
3767 | cft->name, err); | ||
3768 | } | ||
3769 | } | ||
3770 | } | 3759 | } |
3771 | 3760 | ||
3772 | /* This cgroup is ready now */ | 3761 | /* This cgroup is ready now */ |