Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304792
b: refs/heads/master
c: db0416b
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo committed Apr 1, 2012
1 parent 2cef639 commit eaf4252
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6bc103498f5fe512928496fc7802d639cc2d1d20
refs/heads/master: db0416b64977cb0f382175608286cc80c7573e38
16 changes: 0 additions & 16 deletions trunk/include/linux/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,22 +404,6 @@ struct cgroup_scanner {
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_is_removed(const struct cgroup *cgrp);
Expand Down
51 changes: 20 additions & 31 deletions trunk/kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2615,9 +2615,8 @@ static umode_t cgroup_file_mode(const struct cftype *cft)
return mode;
}

int cgroup_add_file(struct cgroup *cgrp,
struct cgroup_subsys *subsys,
const struct cftype *cft)
static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
const struct cftype *cft)
{
struct dentry *dir = cgrp->dentry;
struct dentry *dentry;
Expand Down Expand Up @@ -2649,22 +2648,23 @@ int cgroup_add_file(struct cgroup *cgrp,
error = PTR_ERR(dentry);
return error;
}
EXPORT_SYMBOL_GPL(cgroup_add_file);

int cgroup_add_files(struct cgroup *cgrp,
struct cgroup_subsys *subsys,
const struct cftype cft[],
int count)
static int cgroup_add_files(struct cgroup *cgrp, struct cgroup_subsys *subsys,
const struct cftype cfts[])
{
int i, err;
for (i = 0; i < count; i++) {
err = cgroup_add_file(cgrp, subsys, &cft[i]);
if (err)
return err;
const struct cftype *cft;
int err, ret = 0;

for (cft = cfts; cft->name[0] != '\0'; cft++) {
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;
return ret;
}
EXPORT_SYMBOL_GPL(cgroup_add_files);

static DEFINE_MUTEX(cgroup_cft_mutex);

Expand All @@ -2688,10 +2688,6 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
{
LIST_HEAD(pending);
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 */
if (cfts && ss->root != &rootnode) {
Expand All @@ -2713,7 +2709,7 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
mutex_lock(&inode->i_mutex);
mutex_lock(&cgroup_mutex);
if (!cgroup_is_removed(cgrp))
cgroup_add_files(cgrp, ss, cfts, count);
cgroup_add_files(cgrp, ss, cfts);
mutex_unlock(&cgroup_mutex);
mutex_unlock(&inode->i_mutex);

Expand Down Expand Up @@ -3739,14 +3735,15 @@ static struct cftype files[] = {
.write_string = cgroup_release_agent_write,
.max_write_len = PATH_MAX,
},
{ } /* terminate */
};

static int cgroup_populate_dir(struct cgroup *cgrp)
{
int err;
struct cgroup_subsys *ss;

err = cgroup_add_files(cgrp, NULL, files, ARRAY_SIZE(files));
err = cgroup_add_files(cgrp, NULL, files);
if (err < 0)
return err;

Expand All @@ -3757,16 +3754,8 @@ static int cgroup_populate_dir(struct cgroup *cgrp)
if (ss->populate && (err = ss->populate(ss, cgrp)) < 0)
return err;

list_for_each_entry(set, &ss->cftsets, node) {
const struct cftype *cft;

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);
}
}
list_for_each_entry(set, &ss->cftsets, node)
cgroup_add_files(cgrp, ss, set->cfts);
}

/* This cgroup is ready now */
Expand Down

0 comments on commit eaf4252

Please sign in to comment.