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>
This commit is contained in:
Tejun Heo 2012-04-01 12:09:55 -07:00
parent 6bc103498f
commit db0416b649
2 changed files with 20 additions and 47 deletions

View file

@ -404,22 +404,6 @@ struct cgroup_scanner {
void *data; void *data;
}; };
/*
* Add a new file to the given cgroup directory. Should only be
* called by subsystems from within a populate() method
*/
int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
const struct cftype *cft);
/*
* Add a set of new files to the given cgroup directory. Should
* only be called by subsystems from within a populate() method
*/
int cgroup_add_files(struct cgroup *cgrp,
struct cgroup_subsys *subsys,
const struct cftype cft[],
int count);
int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts); int cgroup_add_cftypes(struct cgroup_subsys *ss, const struct cftype *cfts);
int cgroup_is_removed(const struct cgroup *cgrp); int cgroup_is_removed(const struct cgroup *cgrp);

View file

@ -2615,8 +2615,7 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
return mode; return mode;
} }
int cgroup_add_file(struct cgroup *cgrp, static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
struct cgroup_subsys *subsys,
const struct cftype *cft) const struct cftype *cft)
{ {
struct dentry *dir = cgrp->dentry; struct dentry *dir = cgrp->dentry;
@ -2649,22 +2648,23 @@ int cgroup_add_file(struct cgroup *cgrp,
error = PTR_ERR(dentry); error = PTR_ERR(dentry);
return error; return error;
} }
EXPORT_SYMBOL_GPL(cgroup_add_file);
int cgroup_add_files(struct cgroup *cgrp, static int cgroup_add_files(struct cgroup *cgrp, struct cgroup_subsys *subsys,
struct cgroup_subsys *subsys, const struct cftype cfts[])
const struct cftype cft[],
int count)
{ {
int i, err; const struct cftype *cft;
for (i = 0; i < count; i++) { int err, ret = 0;
err = cgroup_add_file(cgrp, subsys, &cft[i]);
if (err) for (cft = cfts; cft->name[0] != '\0'; cft++) {
return err; err = cgroup_add_file(cgrp, subsys, cft);
if (err) {
pr_warning("cgroup_add_files: failed to create %s, err=%d\n",
cft->name, err);
ret = err;
} }
return 0;
} }
EXPORT_SYMBOL_GPL(cgroup_add_files); return ret;
}
static DEFINE_MUTEX(cgroup_cft_mutex); static DEFINE_MUTEX(cgroup_cft_mutex);
@ -2688,10 +2688,6 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
{ {
LIST_HEAD(pending); LIST_HEAD(pending);
struct cgroup *cgrp, *n; struct cgroup *cgrp, *n;
int count = 0;
while (cfts[count].name[0] != '\0')
count++;
/* %NULL @cfts indicates abort and don't bother if @ss isn't attached */ /* %NULL @cfts indicates abort and don't bother if @ss isn't attached */
if (cfts && ss->root != &rootnode) { if (cfts && ss->root != &rootnode) {
@ -2713,7 +2709,7 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
mutex_lock(&cgroup_mutex); mutex_lock(&cgroup_mutex);
if (!cgroup_is_removed(cgrp)) if (!cgroup_is_removed(cgrp))
cgroup_add_files(cgrp, ss, cfts, count); cgroup_add_files(cgrp, ss, cfts);
mutex_unlock(&cgroup_mutex); mutex_unlock(&cgroup_mutex);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
@ -3739,6 +3735,7 @@ static struct cftype files[] = {
.write_string = cgroup_release_agent_write, .write_string = cgroup_release_agent_write,
.max_write_len = PATH_MAX, .max_write_len = PATH_MAX,
}, },
{ } /* terminate */
}; };
static int cgroup_populate_dir(struct cgroup *cgrp) static int cgroup_populate_dir(struct cgroup *cgrp)
@ -3746,7 +3743,7 @@ static int cgroup_populate_dir(struct cgroup *cgrp)
int err; int err;
struct cgroup_subsys *ss; struct cgroup_subsys *ss;
err = cgroup_add_files(cgrp, NULL, files, ARRAY_SIZE(files)); err = cgroup_add_files(cgrp, NULL, files);
if (err < 0) if (err < 0)
return err; return err;
@ -3757,16 +3754,8 @@ static int cgroup_populate_dir(struct cgroup *cgrp)
if (ss->populate && (err = ss->populate(ss, cgrp)) < 0) if (ss->populate && (err = ss->populate(ss, cgrp)) < 0)
return err; return err;
list_for_each_entry(set, &ss->cftsets, node) { list_for_each_entry(set, &ss->cftsets, node)
const struct cftype *cft; cgroup_add_files(cgrp, ss, set->cfts);
for (cft = set->cfts; cft->name[0] != '\0'; cft++) {
err = cgroup_add_file(cgrp, ss, cft);
if (err)
pr_warning("cgroup_populate_dir: failed to create %s, err=%d\n",
cft->name, err);
}
}
} }
/* This cgroup is ready now */ /* This cgroup is ready now */