cgroups: use Set instead of Apply in Freeze
So Apply function of freezer can be as sample as other subsystems. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
903680701a
commit
a8a798a7c9
|
@ -171,11 +171,16 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
|
|||
return err
|
||||
}
|
||||
|
||||
dir, err := d.path("freezer")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prevState := m.Cgroups.Freezer
|
||||
m.Cgroups.Freezer = state
|
||||
|
||||
freezer := subsystems["freezer"]
|
||||
err = freezer.Apply(d)
|
||||
err = freezer.Set(dir, m.Cgroups)
|
||||
if err != nil {
|
||||
m.Cgroups.Freezer = prevState
|
||||
return err
|
||||
|
|
|
@ -12,21 +12,14 @@ type FreezerGroup struct {
|
|||
}
|
||||
|
||||
func (s *FreezerGroup) Apply(d *data) error {
|
||||
switch d.c.Freezer {
|
||||
case configs.Frozen, configs.Thawed:
|
||||
dir, err := d.path("freezer")
|
||||
if err != nil {
|
||||
dir, err := d.join("freezer")
|
||||
if err != nil && !cgroups.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.Set(dir, d.c); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
if _, err := d.join("freezer"); err != nil && !cgroups.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue