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 | |
| 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>
| -rw-r--r-- | include/linux/cgroup.h | 16 | ||||
| -rw-r--r-- | kernel/cgroup.c | 51 |
2 files changed, 20 insertions, 47 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index af6211c7a42b..7a3d96755114 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
| @@ -404,22 +404,6 @@ struct cgroup_scanner { | |||
| 404 | void *data; | 404 | void *data; |
| 405 | }; | 405 | }; |
| 406 | 406 | ||
| 407 | /* | ||
| 408 | * Add a new file to the given cgroup directory. Should only be | ||
| 409 | * called by subsystems from within a populate() method | ||
| 410 | */ | ||
| 411 | int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys, | ||
| 412 | const struct cftype *cft); | ||
| 413 | |||
| 414 | /* | ||
| 415 | * Add a set of new files to the given cgroup directory. Should | ||
| 416 | * only be called by subsystems from within a populate() method | ||
| 417 | */ | ||
| 418 | int cgroup_add_files(struct cgroup *cgrp, | ||
| 419 | struct cgroup_subsys *subsys, | ||
| 420 | const struct cftype cft[], | ||
| 421 | int count); | ||
| 422 | |||
| 423 | int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts); | 407 | int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts); |
| 424 | 408 | ||
| 425 | int cgroup_is_removed(const struct cgroup *cgrp); | 409 | int cgroup_is_removed(const struct cgroup *cgrp); |
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 */ |
