aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/cgroup.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index fde3633ef389..42e588ef62d1 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2770,6 +2770,22 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2770 return ret; 2770 return ret;
2771} 2771}
2772 2772
2773static void cgroup_exit_cftypes(struct cftype *cfts)
2774{
2775 struct cftype *cft;
2776
2777 for (cft = cfts; cft->name[0] != '\0'; cft++)
2778 cft->ss = NULL;
2779}
2780
2781static void cgroup_init_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
2782{
2783 struct cftype *cft;
2784
2785 for (cft = cfts; cft->name[0] != '\0'; cft++)
2786 cft->ss = ss;
2787}
2788
2773/** 2789/**
2774 * cgroup_add_cftypes - add an array of cftypes to a subsystem 2790 * cgroup_add_cftypes - add an array of cftypes to a subsystem
2775 * @ss: target cgroup subsystem 2791 * @ss: target cgroup subsystem
@@ -2787,15 +2803,13 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2787int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 2803int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
2788{ 2804{
2789 struct cftype_set *set; 2805 struct cftype_set *set;
2790 struct cftype *cft;
2791 int ret; 2806 int ret;
2792 2807
2793 set = kzalloc(sizeof(*set), GFP_KERNEL); 2808 set = kzalloc(sizeof(*set), GFP_KERNEL);
2794 if (!set) 2809 if (!set)
2795 return -ENOMEM; 2810 return -ENOMEM;
2796 2811
2797 for (cft = cfts; cft->name[0] != '\0'; cft++) 2812 cgroup_init_cftypes(ss, cfts);
2798 cft->ss = ss;
2799 2813
2800 cgroup_cfts_prepare(); 2814 cgroup_cfts_prepare();
2801 set->cfts = cfts; 2815 set->cfts = cfts;
@@ -2820,6 +2834,7 @@ EXPORT_SYMBOL_GPL(cgroup_add_cftypes);
2820 */ 2834 */
2821int cgroup_rm_cftypes(struct cftype *cfts) 2835int cgroup_rm_cftypes(struct cftype *cfts)
2822{ 2836{
2837 struct cftype *found = NULL;
2823 struct cftype_set *set; 2838 struct cftype_set *set;
2824 2839
2825 if (!cfts || !cfts[0].ss) 2840 if (!cfts || !cfts[0].ss)
@@ -2831,13 +2846,14 @@ int cgroup_rm_cftypes(struct cftype *cfts)
2831 if (set->cfts == cfts) { 2846 if (set->cfts == cfts) {
2832 list_del(&set->node); 2847 list_del(&set->node);
2833 kfree(set); 2848 kfree(set);
2834 cgroup_cfts_commit(cfts, false); 2849 found = cfts;
2835 return 0; 2850 break;
2836 } 2851 }
2837 } 2852 }
2838 2853
2839 cgroup_cfts_commit(NULL, false); 2854 cgroup_cfts_commit(found, false);
2840 return -ENOENT; 2855 cgroup_exit_cftypes(cfts);
2856 return found ? 0 : -ENOENT;
2841} 2857}
2842 2858
2843/** 2859/**
@@ -4596,6 +4612,8 @@ int __init cgroup_init(void)
4596 if (err) 4612 if (err)
4597 return err; 4613 return err;
4598 4614
4615 cgroup_init_cftypes(NULL, cgroup_base_files);
4616
4599 for_each_subsys(ss, i) { 4617 for_each_subsys(ss, i) {
4600 if (!ss->early_init) 4618 if (!ss->early_init)
4601 cgroup_init_subsys(ss); 4619 cgroup_init_subsys(ss);