freezer_cg: simplify freezer_change_state()

Just call unfreeze_cgroup() if goal_state == THAWED, and call
try_to_freeze_cgroup() if goal_state == FROZEN.

No behavior has been changed.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Cedric Le Goater <clg@fr.ibm.com>
Acked-by: Matt Helsley <matthltc@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Li Zefan 2008-10-29 14:00:54 -07:00 committed by Linus Torvalds
parent 00c2e63c31
commit 51308ee59d

View file

@ -296,27 +296,22 @@ static int freezer_change_state(struct cgroup *cgroup,
int retval = 0;
freezer = cgroup_freezer(cgroup);
spin_lock_irq(&freezer->lock);
update_freezer_state(cgroup, freezer);
if (goal_state == freezer->state)
goto out;
switch (freezer->state) {
switch (goal_state) {
case CGROUP_THAWED:
retval = try_to_freeze_cgroup(cgroup, freezer);
break;
case CGROUP_FREEZING:
if (goal_state == CGROUP_FROZEN) {
/* Userspace is retrying after
* "/bin/echo FROZEN > freezer.state" returned -EBUSY */
retval = try_to_freeze_cgroup(cgroup, freezer);
break;
}
/* state == FREEZING and goal_state == THAWED, so unfreeze */
case CGROUP_FROZEN:
unfreeze_cgroup(cgroup, freezer);
break;
default:
case CGROUP_FROZEN:
retval = try_to_freeze_cgroup(cgroup, freezer);
break;
default:
BUG();
}
out:
spin_unlock_irq(&freezer->lock);